{
  "openapi": "3.1.0",
  "info": {
    "title": "Norulo Project Expense Ledger API",
    "version": "0.11.0",
    "description": "Current ledger contract for Norulo, the project expense tracker for\ndevelopers and teams at norulo.com. Users and authorized API clients\nenter expenses; bank or vendor transactions are not imported. Platform\nsubscription payments remain separate from ledger expenses.\nWeb uses its same-origin /api proxy; direct\nclients call these paths on the Server Worker. All private responses are\nCache-Control: no-store. Money is grouped by currency without conversion.\nProduction admits every request through approximate per-Cloudflare-location\nfrequency windows before authentication or storage work: each client\nIPv4 address or IPv6 /64 network may send 300 requests per 10 seconds and\n1,200 per minute, and each presented session or API key 120 per 10 seconds\nand 600 per minute. There is no total request quota. Exceeding a window\nreturns 429 API_RATE_LIMIT with Retry-After; wait instead of retrying in a\nloop. Ledger owner write allowances are separate.\nEach user's existing personal ledger is an immutable workspace. Explicit\ninvitations share all existing and future ledger data after the original\ninviter approves the authenticated applicant. Links do not require a named\nrecipient. Pending or rejected requests grant no ledger access. Invitations\ndo not grant GitHub organization or repository access. Select a ledger with\nX-Norulo-Workspace, or workspaceId on CSV links. Conflicting selectors are\nrejected. API keys are permanently bound to one ledger and intersect the\nissuing member's current role; membership revision changes invalidate team\nkeys. All members use the ledger owner's plan, capacity and model budget.\nAccount billing remains the signed-in user's own account service.\nProjects can be standalone with a nonblank name and no GitHub repository or\norganization association. Connecting repositories is optional and continues\nto require the current actor's GitHub authorization. The shared expense pool\nis shared across projects in a ledger, never publicly accessible. AI assistance\ndepends on the ledger owner's Pro or Max plan, current activation and usage budget;\nan explicit category permits manual entry when assistance is unavailable.\nProject development and product links are optional absolute HTTP(S) URLs.\nOnly the selected ledger Owner using a current cookie session or an API key\nwith projects:write and permission for that project may remove a\nproject. Removal permanently erases that project, its current expenses,\nrecurring plans and attributable business history. Archived projects remain\nrecoverable until explicitly removed. Current expenses already moved to\nanother project or Shared pool survive, while their erased-project snapshots\ndisappear. Unrelated schedules retain consumed-period fences without a\nremoved expense identifier. Project capacity and active expense capacity\nare released;\nprior write and model-fee counters remain charged. Ledger-wide categories,\naccount identity, billing and membership remain.\nRecurring expense rules use the same REST resource for browser sessions and\nAPI keys with explicit expense authority. A key-created or key-resumed rule\nretains only a credential hash; execution rechecks its current key scopes,\nexpiration, revocation, ledger binding and target restrictions. Each\n\ngenerated occurrence uses the current ledger owner's plan and the rule\nsaved execution actor's current membership and GitHub access. A rule records one ordinary\nexpense per calendar period without making a payment or extending a\nsubscription. Each occurrence is a separate expense record, even when its\nother values match a previous occurrence; amounts are never accumulated\ninto an existing expense. A start date on or before today in the schedule's\ntimezone records exactly one initial expense on that start date. A future\nstart waits for its scheduled occurrence. Future plans do not count as spent.\nCapacity failures retain at most ten unresolved occurrences per rule for\nexplicit manual posting and notify the saved execution actor by English\nemail to a usable verified address, otherwise by Norulo inbox. Later\nfailed occurrences are discarded while ten remain unresolved.\nStopping a rule preserves its previously recorded expenses.\nEmail verification codes provide independent registration and sign-in.\nGitHub identity and repository connections are optional. Verified email and\nexplicit GitHub links preserve the immutable account ID, personal ledger,\nmemberships and billing. Matching provider or billing contact emails never\nmerge accounts. Authentication endpoints do not grant API-key scopes.\nProject and shared-pool activity records identify the authenticated actor,\noperation time and exact changed record. Only the latest rolling 24 hours\nare visible, using the Server clock. History starts when activity logging\nis enabled; old financial audit events are not backfilled or deleted.\nMember governance requires explicit members:read or members:write scopes.\nGovernance keys must omit projectIds, and every key remains bound to its\none ledger and issuer's current role. Owner/Admin can manage members; only\nOwner can manage Admin, and only an invitation's original inviter can review\nits applicants. Previewing or applying to an invitation uses the applicant's\nbrowser account session rather than a ledger-bound key.\n"
  },
  "servers": [
    {
      "url": "https://preview-api.norulo.com",
      "description": "Preview environment; use keys created in preview.norulo.com"
    },
    {
      "url": "https://api.norulo.com",
      "description": "Production endpoint; ledger access is currently paused"
    },
    {
      "url": "/",
      "description": "Relative Server paths; Web proxies these through its /api prefix"
    }
  ],
  "security": [
    {
      "cookieSession": []
    },
    {
      "bearerKey": []
    }
  ],
  "tags": [
    {
      "name": "Authentication"
    },
    {
      "name": "Ledger"
    },
    {
      "name": "Reports"
    },
    {
      "name": "API Keys"
    },
    {
      "name": "Account Billing"
    }
  ],
  "paths": {
    "/billing": {
      "get": {
        "operationId": "getAccountBilling",
        "x-norulo-scope": "account:billing",
        "tags": [
          "Account Billing"
        ],
        "security": [
          {
            "cookieSession": []
          }
        ],
        "description": "Read the signed-in actor's own platform subscription account and personal-ledger capacity. API keys and Bearer session tokens are rejected. A workspace selector does not change billing ownership. Platform payments never create ledger expenses; ledgerUsage uses the actor's personal effective plan and current active expense count.",
        "responses": {
          "200": {
            "description": "Private account billing and personal-ledger capacity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "503": {
            "description": "SERVER_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/billing/plan": {
      "get": {
        "operationId": "getPublicBillingPlan",
        "x-norulo-scope": "account:billing",
        "tags": [
          "Account Billing"
        ],
        "security": [],
        "description": "Read the fresh verified public plan catalog and current configured\nentitlements. A current cookie session may additionally receive account\nand ledgerUsage for that actor's personal ledger. Bearer credentials are\nignored for personalization, even if a cookie is also sent; invalid or\nconcurrently revoked cookie authentication falls back to public data.\nPublic responses omit account and ledgerUsage entirely. A missing or\nexpired trusted catalog returns BILLING_CATALOG_UNAVAILABLE rather than\ninventing provider prices. This endpoint never calls the payment provider,\ninitializes capacity or grants a subscription through a GET.\n",
        "responses": {
          "200": {
            "description": "Public catalog with optional cookie-only personal account and capacity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingCatalog"
                }
              }
            }
          },
          "503": {
            "description": "BILLING_CATALOG_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api-keys": {
      "get": {
        "operationId": "listAccountApiKeys",
        "x-norulo-scope": "account:keys",
        "tags": [
          "API Keys"
        ],
        "security": [
          {
            "cookieSession": []
          }
        ],
        "description": "List a bounded page of the signed-in actor's unrevoked key metadata, newest first by creation time and ID. Bearer keys cannot manage credentials. An optional workspace selector filters keys to that accessible ledger before pagination; without a selector the actor's keys across ledgers are listed. Follow nextCursor with the same selector until it is null. Reads never return tokens or hashes or record usage timestamps.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WorkspaceQuery"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 256,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Opaque nextCursor returned by this endpoint"
          }
        ],
        "responses": {
          "200": {
            "description": "Key metadata; apiKeys is a compatibility alias of items",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "apiKeys",
                    "nextCursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    },
                    "apiKeys": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "maxLength": 256
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      },
      "post": {
        "operationId": "createAccountApiKey",
        "x-norulo-scope": "account:keys",
        "tags": [
          "API Keys"
        ],
        "security": [
          {
            "cookieSession": []
          }
        ],
        "description": "Use the signed-in actor's browser session and a trusted app Origin.\nSelect a ledger with X-Norulo-Workspace or restrictions.workspaceId;\nselectors must agree. Omission binds to the actor's personal ledger.\nScopes cannot exceed the actor's current selected-ledger role.\nExplicit members scopes require omitting projectIds, including an empty\nallowlist; conflicting scopes/restrictions return INVALID_RESTRICTION.\nA selected team ledger's current membership revision is stored by the\nServer; role or membership changes invalidate its existing keys.\nThe response displays key once. Store it in your application's secret\nstorage; the Server stores only its hash and cannot recover the token.\nContent-Length is optional. The JSON body is limited to 8192 bytes;\nwhen a length is supplied it must match the received bytes.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiKeyInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Metadata and one-time Bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/ApiKey"
                    },
                    {
                      "type": "object",
                      "required": [
                        "key"
                      ],
                      "properties": {
                        "key": {
                          "type": "string",
                          "pattern": "^nrk_[A-Za-z0-9_-]{43}$"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "INVALID_SCOPE or INVALID_RESTRICTION; malformed input or expiry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "description": "REQUEST_TOO_LARGE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api-keys/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "delete": {
        "operationId": "revokeAccountApiKey",
        "x-norulo-scope": "account:keys",
        "tags": [
          "API Keys"
        ],
        "security": [
          {
            "cookieSession": []
          }
        ],
        "description": "Revoke one key issued by the signed-in actor using its real browser session and a trusted Origin. Revocation is immediate and remains available after commercial write quota exhaustion. Other actors cannot revoke this key. This route returns 200 with JSON rather than 204.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "responses": {
          "200": {
            "description": "Key revoked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "id",
                    "revoked"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "id": {
                      "type": "string"
                    },
                    "revoked": {
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/api/v1/account/expense-retention": {
      "get": {
        "operationId": "getAccountExpenseRetentionPreference",
        "x-norulo-scope": "account:auth",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "tags": [
          "Authentication"
        ],
        "description": "Read the actual cookie account Owner's expense capacity policy for its\npersonal ledger. Ledger selectors cannot select another Owner's policy;\nAPI keys, Bearer sessions and mixed credentials are rejected. Missing\nlegacy fields mean autoRemoveOldestExpense false and revision 1.\nMalformed persisted preferences fail closed. Available on every plan.\nThis read never initializes state, removes expenses or changes usage.\n",
        "responses": {
          "200": {
            "description": "Owner's stored expense capacity policy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountExpenseRetentionPreference"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "503": {
            "description": "RETENTION_PREFERENCE_UNAVAILABLE for malformed persisted preference state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateAccountExpenseRetentionPreference",
        "x-norulo-scope": "account:auth",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "tags": [
          "Authentication"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "description": "Save the actual cookie account Owner's personal-ledger policy using a\ntrusted app Origin or Referer and its independent preference revision.\nChanging the setting does not remove existing expenses, reset usage or\nincur an extra charge. A matching revision and unchanged value returns\n200 without a write. Every plan can change this policy.\nWhen disabled, creating an expense at capacity returns RECORD_LIMIT.\nWhen enabled and exactly at capacity, an otherwise authorized ordinary\nor recurring expense creation atomically soft-removes one globally\noldest active expense and creates the new one. Ordering is occurredOn,\nthen createdAt, then id. The creation actor must currently be authorized\nto delete that actual oldest target; restricted keys cannot skip it for\nanother target (RETENTION_TARGET_FORBIDDEN). Above capacity, creation\nreturns RETENTION_CLEANUP_REQUIRED until manual cleanup brings usage\nwithin the limit. Historical audits, creation replays and occurrence\nidentities remain intact; replay never removes another expense.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "autoRemoveOldestExpense"
                ],
                "properties": {
                  "autoRemoveOldestExpense": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Confirmed policy; revision increments only on an actual change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountExpenseRetentionPreference"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "PREFERENCE_REVISION_EXHAUSTED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          },
          "428": {
            "description": "Current preference If-Match is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "RETENTION_PREFERENCE_UNAVAILABLE or SERVER_UNAVAILABLE; no automatic retry after an unknown write outcome",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/jev": {
      "get": {
        "operationId": "getAccountJevPreference",
        "x-norulo-scope": "account:auth",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "tags": [
          "Authentication"
        ],
        "description": "Read the actual cookie account's persisted Jev preference. Ledger\nselectors do not select another account for this endpoint. API keys and\nmixed credentials are rejected. Missing legacy fields mean enabled true\nand revision 1; malformed persisted preference fields fail closed.\nFree accounts may read their retained preference, but available is false.\nThis read does not initialize state, call providers or change usage.\n",
        "responses": {
          "200": {
            "description": "Stored preference and effective availability for the signed-in account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountJevPreference"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "503": {
            "description": "JEV_PREFERENCE_UNAVAILABLE for malformed persisted preference state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateAccountJevPreference",
        "x-norulo-scope": "account:auth",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "tags": [
          "Authentication"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "description": "Only the actual cookie account with a current Pro or Max plan may change\nits preference. Requires a trusted app Origin or Referer and the current\nindependent preference revision, never a billing or workspace revision.\nSave the complete canonical user record with session and raw-user CAS\nguards, preserving identity, billing, membership and quota state.\nA matching revision and unchanged enabled value returns 200 without writes.\nThe preference controls all model calls for this account's own ledger,\nincluding its members and API keys. Turning it off prevents new model\nadmissions, reservations and events. In-flight calls retain admitted\nfees but cannot publish hints or financial writes from the old authority.\nManual expenses and the paid inspection's local duplicate check remain\navailable. Turning it on does not bypass runtime flags or reset limits.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "enabled"
                ],
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Confirmed preference, with an incremented revision only after an actual change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountJevPreference"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Current account authority forbidden",
            "or UNTRUSTED_ORIGIN": null,
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "AUTHORIZATION_CHANGED or PREFERENCE_REVISION_EXHAUSTED; do not retry automatically",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "412": {
            "description": "PRECONDITION_FAILED for a stale preference revision; reload before choosing again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT for an invalid body or revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "428": {
            "description": "PRECONDITION_REQUIRED when If-Match is absent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "JEV_PREFERENCE_UNAVAILABLE for malformed persisted preference state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/auth/session": {
      "get": {
        "operationId": "getAccountSession",
        "x-norulo-scope": "account:auth",
        "security": [],
        "tags": [
          "Authentication"
        ],
        "description": "Read the current cookie session without initialization, provider calls or token refresh. An absent or expired session returns authenticated false and user null. Verified email sessions remain valid independently of GitHub authorization; GitHub contact email and billing email are not verified login identities.",
        "responses": {
          "200": {
            "description": "Current session; authenticated users may have email, GitHub or both providers",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSession"
                }
              }
            }
          }
        }
      }
    },
    "/auth/sign-out": {
      "post": {
        "operationId": "signOutAccount",
        "x-norulo-scope": "account:auth",
        "security": [],
        "tags": [
          "Authentication"
        ],
        "description": "Requires the current cookie session and a trusted Origin or Referer. Revoke only this session and clear nr_session; account identities, ledger data and billing remain intact. API keys cannot sign out a browser session.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "responses": {
          "200": {
            "description": "Session revoked; nr_session is cleared with Max-Age 0",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              },
              "Set-Cookie": {
                "$ref": "#/components/headers/AuthCookie"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED; a current cookie session is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "UNTRUSTED_ORIGIN",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/auth/email/request-code": {
      "post": {
        "operationId": "requestEmailCode",
        "x-norulo-scope": "account:auth",
        "x-norulo-max-body-bytes": 8192,
        "security": [],
        "tags": [
          "Authentication"
        ],
        "description": "Request a six-digit code for a normalized ASCII email address. purpose\nlogin verifies an existing email identity or registers a new account\nafter successful verification; it does not disclose account existence.\npurpose link requires the current cookie session, binds the challenge\nto that account and session, and never merges accounts. Changing an\nalready verified login email is rejected. Once linked, a login email\ncannot be unlinked or changed.\nAn email already owned by another account is rejected before sending\na code, creating a challenge or starting its send cooldown. Ownership\nis checked only for authenticated linking and rechecked at verification.\nA trusted Origin header and at most 8 KiB of strict JSON are required.\nA Referer header does not replace a missing Origin.\nOnly one challenge is active per email; explicit resend after 60 seconds\ninvalidates the earlier challenge. Codes expire after 600 seconds and\nare never returned or logged. Delivery uncertainty is not retried.\nSet-Cookie issues a random nr_email_challenge browser binding, Secure\nand HttpOnly with a 600-second lifetime; verification must use this same\nbrowser. The binding's SameSite policy follows the configured app origin.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/EmailAuthOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailCodeRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Code request accepted; only challenge metadata is returned",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              },
              "Set-Cookie": {
                "$ref": "#/components/headers/AuthCookie"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailCodeChallenge"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED for link without a current cookie session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "UNTRUSTED_ORIGIN",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "EMAIL_ALREADY_LINKED for authenticated linking to another account's email before code sending or cooldown; EMAIL_CHANGE_NOT_SUPPORTED when replacing a different verified login email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "REQUEST_TOO_LARGE; JSON exceeds 8 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT; unknown fields, invalid email or unsupported purpose",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "EMAIL_RATE_LIMIT; email and source admission or the 60-second resend interval was exceeded",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/AuthRetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "EMAIL_AUTH_NOT_CONFIGURED, EMAIL_AUTH_UNAVAILABLE or EMAIL_SEND_UNAVAILABLE; no automatic resend",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/auth/email/verify-code": {
      "post": {
        "operationId": "verifyEmailCode",
        "x-norulo-scope": "account:auth",
        "x-norulo-max-body-bytes": 8192,
        "security": [],
        "tags": [
          "Authentication"
        ],
        "description": "Verify the email, challenge ID and six-digit code using the original\nnr_email_challenge cookie and a trusted Origin header. A Referer header\ndoes not replace a missing Origin. At most five\nincorrect codes are allowed per challenge. Success consumes the proof\nonce; replay never creates another session. Login atomically initializes\na new account when necessary, retains a previously registered account\nID, and issues Secure HttpOnly nr_session with a seven-day lifetime.\nLink requires the original authenticated session, preserves its cookie,\nuser ID, ledger and billing, and clears nr_email_challenge. An email\nalready owned by another account is rechecked and rejected with 409;\nno automatic account merge occurs. JSON is strict and bounded to 8 KiB.\nAll responses have Cache-Control no-store. Incorrect browser bindings\nnever consume one of the five code attempts.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/EmailAuthOrigin"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailCodeVerification"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified account session; login sets nr_session, link keeps it and clears the challenge cookie",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              },
              "Set-Cookie": {
                "$ref": "#/components/headers/AuthCookie"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSession"
                }
              }
            }
          },
          "400": {
            "description": "EMAIL_CODE_INVALID for wrong, replayed or browser-unbound proof; EMAIL_CODE_EXPIRED at the exact 600-second deadline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED; the original link session was changed, revoked or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "UNTRUSTED_ORIGIN",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "EMAIL_ALREADY_LINKED or ACCOUNT_CHANGED; no account merge or overwrite of concurrent account facts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "REQUEST_TOO_LARGE; JSON exceeds 8 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT; unknown fields or malformed email, challenge ID or code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "EMAIL_RATE_LIMIT or EMAIL_ATTEMPTS_EXCEEDED; no account or session write",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/AuthRetryAfter"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "EMAIL_AUTH_NOT_CONFIGURED, EMAIL_AUTH_UNAVAILABLE or EMAIL_IDENTITY_UNAVAILABLE; no implicit identity repair",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/auth/github/authorize": {
      "get": {
        "operationId": "authorizeGithubAccount",
        "x-norulo-scope": "account:auth",
        "security": [],
        "tags": [
          "Authentication"
        ],
        "description": "Optional GitHub OAuth sign-in or explicit identity link. intent login\n(the default) signs in the account mapped to the stable GitHub numeric\nidentity. intent link requires a current cookie session and a trusted\nOrigin or Referer, binds the one-use ten-minute state to that account\nand session, and preserves its immutable ID and billing. It never\nmatches accounts using GitHub profile email. Repository authorization\nis a separate optional integration. redirectTo must stay within the\ntrusted app origin; an invalid destination falls back to /projects.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthOrigin"
          },
          {
            "name": "intent",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "login",
                "link"
              ],
              "default": "login"
            }
          },
          {
            "name": "redirectTo",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Trusted app destination after OAuth"
          },
          {
            "name": "response",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "redirect"
              ]
            },
            "description": "Return an HTTP redirect instead of the JSON authorization URL"
          }
        ],
        "responses": {
          "200": {
            "description": "OAuth authorization URL",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url",
                    "mode"
                  ],
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "mode": {
                      "type": "string",
                      "const": "github"
                    }
                  }
                }
              }
            }
          },
          "302": {
            "description": "Redirect to the GitHub OAuth authorization URL"
          },
          "401": {
            "description": "UNAUTHENTICATED for explicit link without a current cookie session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "UNTRUSTED_ORIGIN for explicit link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT; unsupported intent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "GITHUB_NOT_CONFIGURED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/auth/github/callback": {
      "get": {
        "operationId": "completeGithubAccountAuthorization",
        "x-norulo-scope": "account:auth",
        "security": [],
        "tags": [
          "Authentication"
        ],
        "description": "Consume the one-use OAuth state and verify the actual GitHub identity. Explicit linking requires the original account and session at callback and commits identity mapping, user and session fences atomically. A GitHub identity already owned by another account returns 409 rather than merging accounts. Successful login sets a seven-day nr_session; successful linking retains the current session. Provider denial redirects to the trusted destination with github_error.",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "error",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Trusted app redirect after sign-in or linking",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              },
              "Set-Cookie": {
                "$ref": "#/components/headers/AuthCookie"
              }
            }
          },
          "400": {
            "description": "OAUTH_STATE_INVALID; absent, expired or consumed state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHENTICATED; original link session is missing or changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "GITHUB_IDENTITY_CONFLICT or ACCOUNT_CHANGED; account IDs and billing are preserved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "GITHUB_PROFILE_INVALID; no trusted numeric identity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/github": {
      "delete": {
        "operationId": "unlinkGithubAccount",
        "x-norulo-scope": "account:auth",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "tags": [
          "Authentication"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "description": "Unlink the current account's GitHub login identity and remove its stored\nGitHub credentials and repository grants. Requires a current cookie\nsession, a trusted Origin or Referer and an independently verified email\nlogin identity belonging to this account. GitHub contact or billing email\nis insufficient. Email remains permanently linked. Account ID, current\nsession, ledger history, projects, project repository associations,\nmemberships, API keys and billing are retained. Pending authorization\ncallbacks cannot restore the removed connection. The released GitHub\nidentity can be linked again explicitly; a later standalone GitHub login\ncannot recover the original email account. No GitHub API call or App\nuninstall is performed. An already unlinked account is a read-only no-op.\n",
        "responses": {
          "200": {
            "description": "GitHub unlinked; current email-backed session",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSession"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "UNTRUSTED_ORIGIN",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "EMAIL_REQUIRED_FOR_GITHUB_UNLINK",
            "GITHUB_IDENTITY_CONFLICT or ACCOUNT_CHANGED; reload before trying again": null,
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/github/refresh": {
      "post": {
        "operationId": "refreshGithubCredential",
        "x-norulo-scope": "account:auth",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "tags": [
          "Authentication"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "description": "Renew the signed-in account's own expiring GitHub App credential using\nits encrypted refresh token. Requires a current cookie session and a\ntrusted Origin or Referer; Bearer credentials cannot refresh an account.\nA credential with more than sixty seconds remaining is a successful\nno-op. One durable claim admits one provider exchange, and publication\nfences the original account, session and token generation. Unknown\nexchange or storage outcomes do not repeat the old refresh token.\nThis operation preserves the Norulo session, memberships, ledger\ndata and repository bindings. It never exposes either token. Old\naccounts without saved refresh credentials require one explicit GitHub\nreconnection. A read with githubRefreshRequired true may be followed\nby this POST and one repeated read; business writes must not be replayed.\nAPI-key clients use the separate /api/v1/integrations/github/refresh route.\n",
        "responses": {
          "200": {
            "description": "Credential renewed or already current",
            "headers": {
              "Cache-Control": {
                "$ref": "#/components/headers/NoStore"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "refreshed"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "refreshed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "UNTRUSTED_ORIGIN or GITHUB_REAUTHORIZATION_REQUIRED; missing",
            "expired or revoked refresh credentials require explicit reconnect": null,
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "GITHUB_REFRESH_PENDING or ACCOUNT_CHANGED; do not repeat a provider exchange while another attempt is pending",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "GITHUB_RESPONSE_INVALID; no automatic retry of an uncertain exchange",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "GitHub rate limit",
            "transport": null,
            "configuration or encrypted credential failure; errors retain distinct safe codes": null,
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workspaces": {
      "get": {
        "operationId": "listWorkspaces",
        "x-norulo-scope": "members:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Cookie sessions list the personal ledger first and explicitly joined ledgers. A members:read key lists only its bound ledger. Reads never initialize data.",
        "responses": {
          "200": {
            "description": "Current accessible ledgers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "$ref": "#/components/schemas/Workspace"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/members": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        }
      ],
      "get": {
        "operationId": "listWorkspaceMembers",
        "x-norulo-scope": "members:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Owner and current members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "workspace"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "$ref": "#/components/schemas/WorkspaceMember"
                      }
                    },
                    "workspace": {
                      "$ref": "#/components/schemas/Workspace"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/members/{userId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        },
        {
          "name": "userId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "patch": {
        "operationId": "updateWorkspaceMember",
        "x-norulo-scope": "members:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Owner can grant Admin/Editor/Viewer. Admin can manage only Editor/Viewer. Owner cannot be changed or removed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "role"
                ],
                "properties": {
                  "role": {
                    "$ref": "#/components/schemas/AssignableRole"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated member with a new revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceMember"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      },
      "delete": {
        "operationId": "removeWorkspaceMember",
        "x-norulo-scope": "members:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Owner removes Admin/Editor/Viewer; Admin removes only Editor/Viewer. This governance endpoint does not support self-service leaving. A member asks the Owner, or an Admin for an Editor/Viewer membership, to remove them. The Owner is immutable; removal retains financial history and invalidates membership-bound keys.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "204": {
            "description": "Removed; subsequent resource and key requests fail current membership checks"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/invites": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        }
      ],
      "get": {
        "operationId": "listWorkspaceInvites",
        "x-norulo-scope": "members:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Owner/Admin only. Tokens and hashes are never returned by reads.",
        "responses": {
          "200": {
            "description": "Pending unexpired invitations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "$ref": "#/components/schemas/WorkspaceInvitation"
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "operationId": "inviteWorkspaceMember",
        "x-norulo-scope": "members:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Create an unassigned 24-hour invitation link with a role. The token is displayed once; the original inviter must approve an authenticated applicant before membership is granted. Financial roles do not grant GitHub access.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "role"
                ],
                "properties": {
                  "role": {
                    "$ref": "#/components/schemas/AssignableRole"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invitation metadata and one-time token",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/WorkspaceInvitation"
                    },
                    {
                      "type": "object",
                      "required": [
                        "token"
                      ],
                      "properties": {
                        "token": {
                          "type": "string",
                          "pattern": "^nri_[A-Za-z0-9_-]{43}$"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/invites/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        },
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "delete": {
        "operationId": "revokeWorkspaceInvitation",
        "x-norulo-scope": "members:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "204": {
            "description": "Invitation permanently revoked"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      }
    },
    "/api/v1/workspace-invitations/preview": {
      "post": {
        "operationId": "previewWorkspaceInvitation",
        "x-norulo-scope": "profile:read",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "description": "Authenticated read without a join or write. Pending tokens check expiry and current inviter authority; legacy targeted tokens also check their stable recipient ID. The response includes the current applicant request when present. Pending requests grant no ledger permissions. An accepted token can recover only its approved applicant's current active membership, without restoring removed membership.",
        "requestBody": {
          "$ref": "#/components/requestBodies/InvitationToken"
        },
        "responses": {
          "200": {
            "description": "Invitation and applicant request or current approved membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceInvitationPreview"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "description": "INVITATION_EXPIRED, INVITATION_REVOKED, or INVITATION_ACCEPTED without a current active membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workspace-invitations/accept": {
      "post": {
        "operationId": "acceptWorkspaceInvitation",
        "x-norulo-scope": "profile:read",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "description": "Submit the authenticated actor's join request and notify the original inviter through their durable inbox. This does not grant membership or consume the link. Each link permits at most 100 lifetime applicants. Existing pending or rejected requests replay read-only. One approved applicant consumes the link; removed-member generations advance only upon approval and old keys do not revive.",
        "requestBody": {
          "$ref": "#/components/requestBodies/InvitationToken"
        },
        "responses": {
          "200": {
            "description": "Existing pending or rejected applicant request without another write",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceInvitationPreview"
                }
              }
            }
          },
          "202": {
            "description": "Join request awaiting original inviter approval",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceInvitationPreview"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "description": "INVITATION_ACCEPTED, INVITATION_REVOKED, or INVITATION_EXPIRED; no request or membership write",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workspace-invitation-requests": {
      "get": {
        "operationId": "listWorkspaceInvitationRequests",
        "x-norulo-scope": "members:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Durable inbox for the current original inviter. Cookie sessions can read across currently authorized ledgers; a members:read key sees only its bound ledger. Returns up to 100 oldest actionable pending requests plus hasMore; expiry, revocation, consumed links and lost inviter authority remove requests from the actionable inbox. Reads never mark notifications or mutate data.",
        "responses": {
          "200": {
            "description": "Pending requests with applicant identity, invitation and ledger",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/WorkspaceJoinRequest"
                          },
                          {
                            "type": "object",
                            "required": [
                              "invitation",
                              "workspace"
                            ],
                            "properties": {
                              "invitation": {
                                "$ref": "#/components/schemas/WorkspaceInvitation"
                              },
                              "workspace": {
                                "$ref": "#/components/schemas/Workspace"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/api/v1/recurring-expense-notifications": {
      "get": {
        "operationId": "listRecurringExpenseNotifications",
        "x-norulo-scope": "account:auth",
        "security": [
          {
            "cookieSession": []
          }
        ],
        "description": "Read the signed-in account's actionable recurring capacity-failure inbox\nacross currently authorized ledgers, independently of the selected\nworkspace. Bearer API keys and Bearer session tokens are rejected with\nCOOKIE_SESSION_REQUIRED. Returns at most 100 oldest actionable retained\nfailures plus hasMore. Current recipient identity, ledger membership and\ntarget access are required; canceled rules and removed targets are\nexcluded. Notifications delivered by email are hidden from this inbox.\nPending email delivery and inbox fallback remain visible until the\nhistorical occurrence is successfully posted. GET never marks read,\nposts an expense or changes notification delivery state.\n",
        "responses": {
          "200": {
            "description": "Current account's actionable recurring failures",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringExpenseNotificationPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "COOKIE_SESSION_REQUIRED for Bearer credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/join-requests": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        }
      ],
      "get": {
        "operationId": "listWorkspaceJoinRequests",
        "x-norulo-scope": "members:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Current Owner/Admin only. Durable inbox scoped to this ledger and invitations created by the current actor. Returns up to 100 oldest actionable pending requests plus hasMore.",
        "responses": {
          "200": {
            "description": "Pending requests with applicant identity and ledger invitation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/WorkspaceJoinRequest"
                          },
                          {
                            "type": "object",
                            "required": [
                              "invitation",
                              "workspace"
                            ],
                            "properties": {
                              "invitation": {
                                "$ref": "#/components/schemas/WorkspaceInvitation"
                              },
                              "workspace": {
                                "$ref": "#/components/schemas/Workspace"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/invites/{id}/requests": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        },
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "operationId": "listWorkspaceInvitationJoinRequests",
        "x-norulo-scope": "members:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Current original inviter only. List up to 100 actionable pending applicants for this invitation.",
        "responses": {
          "200": {
            "description": "Pending join requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "maxItems": 100,
                      "items": {
                        "$ref": "#/components/schemas/WorkspaceJoinRequest"
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/invites/{id}/requests/{requestId}/approve": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        },
        {
          "$ref": "#/components/parameters/Id"
        },
        {
          "$ref": "#/components/parameters/JoinRequestPath"
        }
      ],
      "post": {
        "operationId": "approveWorkspaceJoinRequest",
        "x-norulo-scope": "members:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "description": "Current original inviter only. Atomically approve one pending request, grant the link's role, consume the link and append the audit event. Other pending applicants become unavailable. If-Match is the request revision; stale authority, membership or invitation revisions cannot commit partial changes.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Approved request and granted ledger membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceJoinReview"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "description": "Invitation no longer actionable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      }
    },
    "/api/v1/workspaces/{workspaceId}/invites/{id}/requests/{requestId}/reject": {
      "parameters": [
        {
          "$ref": "#/components/parameters/WorkspacePath"
        },
        {
          "$ref": "#/components/parameters/Id"
        },
        {
          "$ref": "#/components/parameters/JoinRequestPath"
        }
      ],
      "post": {
        "operationId": "rejectWorkspaceJoinRequest",
        "x-norulo-scope": "members:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "description": "Current original inviter only. Reject a pending applicant and append the audit event without granting membership or consuming the invitation. The rejected applicant cannot resubmit on the same link. If-Match is the request revision.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rejected request and ledger summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceJoinReview"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "description": "Invitation no longer actionable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      }
    },
    "/api/v1/me": {
      "get": {
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "operationId": "getLedgerMe",
        "x-norulo-scope": "profile:read",
        "responses": {
          "200": {
            "description": "Current identity, ledger capabilities and entitlements",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/repositories": {
      "get": {
        "operationId": "listLedgerRepositories",
        "x-norulo-scope": "projects:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Current actor GitHub App repositories ordered by stable numeric ID; cursor is the last repository ID. No automatic binding or installation expansion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepositoryPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "502": {
            "description": "Invalid bounded GitHub response; error code GITHUB_RESPONSE_INVALID",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "GitHub temporarily unavailable, rate limited, credential failure or an internal failure; no automatic retry. Internal failures include an opaque requestId for private diagnostics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/github/refresh": {
      "post": {
        "operationId": "refreshLedgerGitHubAccess",
        "x-norulo-scope": "projects:read",
        "security": [
          {
            "bearerKey": []
          }
        ],
        "tags": [
          "Authentication"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "description": "Explicitly renew the API key actor's existing GitHub App credential.\nRequires projects:read in the key's bound ledger and current membership;\nrefreshes the actor's own credentials, never the ledger owner's.\nUses the same durable rotation claim as the browser refresh endpoint.\nRechecks the key, scopes, restrictions, membership and token generation\natomically before the provider exchange and credential publication.\nNo token is returned and no new GitHub permission is granted. When a\nread returns githubRefreshRequired true, make this POST once and repeat\nthe read once after success. Never retry an uncertain exchange or replay\na business write. A pending claim returns 409 GITHUB_REFRESH_PENDING;\nmissing, expired, revoked or uncertain refresh credentials require\nexplicit GitHub reconnection on the Web.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "maxProperties": 0
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credential renewed or already current",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "refreshed"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "refreshed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "GITHUB_REFRESH_PENDING or ACCOUNT_CHANGED; no provider retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          },
          "502": {
            "description": "Invalid GitHub credential response; no retry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Provider or internal failure; no retry of an uncertain exchange",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/projects": {
      "get": {
        "operationId": "listLedgerProjects",
        "x-norulo-scope": "projects:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/From"
          },
          {
            "$ref": "#/components/parameters/To"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Accessible projects in the selected ledger and per-currency totals",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "operationId": "createLedgerProject",
        "x-norulo-scope": "projects:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectInput"
              }
            }
          }
        },
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "201": {
            "description": "Created project",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      }
    },
    "/api/v1/projects/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "operationId": "getLedgerProject",
        "x-norulo-scope": "projects:read",
        "responses": {
          "200": {
            "description": "Project, including authorization state and totals",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateLedgerProject",
        "x-norulo-scope": "projects:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectPatch"
              }
            }
          }
        },
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "200": {
            "description": "Updated project",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      },
      "delete": {
        "operationId": "removeLedgerProject",
        "x-norulo-scope": "projects:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Current actual Owner of the selected ledger only. Owner API keys require projects:write and current permission for this project; Admin, Editor and Viewer are rejected. Cookie writes require a trusted app Origin; both forms require current If-Match revision. One atomic closed transaction erases the project, repository bindings, all currently assigned expenses including soft-deleted rows, its recurring rules and attributable financial/replay/Jev/activity history. Moved-out current expenses and unrelated schedules survive; external consumed periods retain a fence with no erased expense ID. Ledger-wide categories, identity, billing, membership and prior write/model-fee counters remain. Project capacity and active expense capacity are released, and the accepted erasure counts as one ordinary write. An absent project is an explicitly empty outcome in the authorized Owner scope; an existing foreign project is hidden. No deletion activity snapshot is recreated. PATCH cannot restore a physically removed project.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/AuthOrigin"
          }
        ],
        "responses": {
          "204": {
            "description": "Project removed or already removed within the same authorized ledger"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "QUOTA_WINDOW_CHANGED; request clock precedes persisted usage window",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          },
          "428": {
            "description": "If-Match is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/categories": {
      "get": {
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "name": "includeRemoved",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include removed category metadata for existing expense/history labels; accepts one literal true or false"
          }
        ],
        "operationId": "listExpenseCategories",
        "x-norulo-scope": "categories:read",
        "responses": {
          "200": {
            "description": "Selected ledger categories including archived entries; removed entries appear only with includeRemoved=true",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Category"
                  }
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      },
      "post": {
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "operationId": "createExpenseCategory",
        "x-norulo-scope": "categories:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CategoryInput"
              }
            }
          }
        },
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "201": {
            "description": "Created category",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Category"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      }
    },
    "/api/v1/categories/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "patch": {
        "operationId": "updateExpenseCategory",
        "x-norulo-scope": "categories:write",
        "description": "Replace the category label with a required nonblank name. Omitted color becomes null. Archived categories cannot be renamed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CategoryInput"
              }
            }
          }
        },
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "200": {
            "description": "Updated category",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Category"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      },
      "delete": {
        "operationId": "archiveExpenseCategory",
        "x-norulo-scope": "categories:write",
        "description": "Archive only; existing expenses retain their category reference.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "204": {
            "description": "Archived"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      }
    },
    "/api/v1/categories/{id}/remove": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "post": {
        "operationId": "removeExpenseCategory",
        "x-norulo-scope": "categories:write",
        "description": "Remove an active or archived category from management and new choices\nwith a permanent tombstone, even if it has historical references.\nExisting expenses, audit/replay rows and names remain unchanged;\nincludeRemoved=true supplies metadata for those historical labels.\nExisting expense edits may explicitly retain their original removed\ncategory, but new assignments and model choices require an active one.\nReferencing recurring rules are blocked with INVALID_CATEGORY at their\nnext due run until explicitly updated and resumed; removal itself does\nnot rewrite their schedule or consumed periods. Removed categories\ncannot be renamed or restored. Repeating with the current removed\nrevision is read-only.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Category removed from management/new choices",
            "or already removed at the supplied current revision": null
          },
          "409": {
            "description": "REVISION_LIMIT; the tombstone would exceed the safe revision limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "428": {
            "description": "If-Match is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/expenses": {
      "get": {
        "operationId": "listExpenses",
        "x-norulo-scope": "expenses:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Target"
          },
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "$ref": "#/components/parameters/CategoryId"
          },
          {
            "$ref": "#/components/parameters/From"
          },
          {
            "$ref": "#/components/parameters/To"
          },
          {
            "$ref": "#/components/parameters/Currency"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Active expenses only",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExpensePage"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "operationId": "createExpense",
        "x-norulo-scope": "expenses:write",
        "description": "When the ledger owner's Pro or Max plan, activation gates and usage budget allow\nit, this ordinary write attempts Jev assistance for Cookie sessions and\nexpenses:write API keys alike. categoryId may be omitted on create:\na confident existing ledger category is then selected. Explicit\ncategories, targets, money and dates are never changed by inference. If a\ncategory cannot be selected, 422 CATEGORY_REQUIRED preserves the draft and\nreturns assistance for manual completion. Provider failure or exhausted Jev\nbudget does not block a write with an explicit category. Idempotent replay\nreturns the stored result without another model call or budget reservation.\nCapacity counts undeleted expenses in Shared pool and nonremoved\nprojects, including archived projects. If the Owner enabled automatic\nremoval, an at-capacity creation and deletion of the globally oldest\nactive expense share one transaction and one commercial write. The\nactual oldest target must be writable under the caller's current grant;\notherwise RETENTION_TARGET_FORBIDDEN is returned without creating or\ndeleting anything. With automatic removal enabled, above-capacity ledgers\nreturn RETENTION_CLEANUP_REQUIRED and require manual cleanup. With it\ndisabled, full or above-capacity creates return RECORD_LIMIT. Invalid\nwrites and replay never remove expenses.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExpenseInput"
              }
            }
          }
        },
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "201": {
            "description": "Created expense or exact idempotent replay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Expense"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      }
    },
    "/api/v1/expenses/export": {
      "get": {
        "operationId": "exportExpenses",
        "x-norulo-scope": "expenses:read",
        "description": "Uses list filters; active records only. CSV cells must escape spreadsheet formulas.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Target"
          },
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "$ref": "#/components/parameters/CategoryId"
          },
          {
            "$ref": "#/components/parameters/From"
          },
          {
            "$ref": "#/components/parameters/To"
          },
          {
            "$ref": "#/components/parameters/Currency"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          },
          {
            "$ref": "#/components/parameters/WorkspaceQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Streamed CSV",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/expenses/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "operationId": "getExpense",
        "x-norulo-scope": "expenses:read",
        "responses": {
          "200": {
            "description": "Active expense",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Expense"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateExpense",
        "x-norulo-scope": "expenses:write",
        "description": "Send the complete editable expense input, including target, occurredOn,\namount, currency and purpose. This endpoint replaces those fields; it\ndoes not merge a partial body. Omitted note, quantity and unit become null.\nRequires the current If-Match revision before inference. Moving an\nexpense checks write authority on both old and new targets. When the\nledger owner's Pro or Max plan, activation gates and usage budget allow it,\ncategoryId may be omitted to select a confident existing active category.\nThe selected category must remain active at the atomic update, including\nwhen inference chooses the previous category. Explicit categories,\ntargets, money and dates are preserved; explicitly retaining the previous\narchived category is permitted. Unavailable or uncertain automatic\nclassification returns 422 CATEGORY_REQUIRED without updating the expense.\nAssistance uses the same Owner Jev call allowance as expense creation, without a daily attempt cap;\nadvisory target suggestions never move the expense.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExpensePatchInput"
              }
            }
          }
        },
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "200": {
            "description": "Updated expense",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Expense"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      },
      "delete": {
        "operationId": "removeExpense",
        "x-norulo-scope": "expenses:write",
        "description": "Soft delete and audit event; immediately excluded from list, export and reports.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "204": {
            "description": "Removed or already removed within the same authorized ledger"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          }
        }
      }
    },
    "/api/v1/expenses/{id}/review": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "post": {
        "operationId": "reviewExpense",
        "x-norulo-scope": "expenses:write",
        "description": "Explicit advisory review of one current saved expense, bound to If-Match. The request is an empty object; clients cannot replace saved purpose, note, money, category or target. Requires the ledger Owner's current Pro or Max plan and the actual actor's expense-write and target authority. Jev selects and scores existing category/scope choices; it does not generate explanations or reports. Only this saved record's purpose and note and current active category names enter the model. Categories and target kinds are advice only; no expense, financial audit, recent activity, revision, record count or commercial write allowance is changed. Model attempts share the Pro USD 3 / Max USD 12 per UTC month reservation, without a daily attempt cap; admitted failures remain charged. With no active categories the model can still check target kind. Disabled, failed or invalid model context returns partial checks while the local duplicate rule remains available. That rule finds another current record on the same authorized target with the same expense date, currency and integer minor-unit amount; purpose text need not match. It does not prove ledger-wide uniqueness. Duplicate output contains only ID and revision, including for write-only keys. Saved source, permissions, category and duplicate candidate are freshly rechecked and atomically fenced before results are published; a source changed during review returns 412. There is no automatic apply, target move, money update, retry, batch endpoint or idempotent model replay.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "maxProperties": 0,
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured dimension checks for the unchanged saved revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExpenseReview"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Current actor/scope/target authority forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          },
          "428": {
            "description": "If-Match is required before model admission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "JEV_BUDGET_LIMIT at the shared monthly paid or lifetime Free call limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/expense-recurring-rules": {
      "get": {
        "operationId": "listRecurringExpenseRules",
        "x-norulo-scope": "expenses:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Current ledger rules excluding canceled entries. Reads never generate expenses or repair financial state. nextOccurrenceOn is the next future business date in the schedule's timezone, or null when none remains. For an overdue legacy rule, awaitingSync identifies a read-only future projection awaiting the next authorized scheduled write. Retained pendingOccurrences remain separately visible. Session and expenses:read key readers use the same DTO; keys see only targets permitted by their current restrictions.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Target"
          },
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringExpensePage"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      },
      "post": {
        "operationId": "createRecurringExpenseRule",
        "x-norulo-scope": "expenses:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Create an automation for a currently authorized project/shared target.\ncategoryId may be omitted for Jev automatic classification when the\ncurrent Owner's plan, activation, model availability and allowance permit\nit, just as on ordinary expense creation. Only a confident existing\nactive category is saved; an explicit category is never changed.\nCATEGORY_REQUIRED preserves the unsaved input for manual selection.\nBackground execution uses that saved category without model calls.\nThe authenticated key issuer\nor session user is initially its execution actor. Session and key tokens\nare never stored in the rule. Key grants retain a credential hash and\nrecheck expiration, revocation, expenses:write, ledger binding, membership\nrevision and project/shared restrictions before every generated expense.\nAt most 100 noncanceled rules per ledger is an operational bound,\nindependent of the owner's paid plan. An exact repeated creation key\nreplays its original DTO; different input with that key conflicts.\nCreation keys remain scoped to the original creating user even if a\nlater authorized edit or resume changes the saved execution actor.\nA startOn on or before today in the schedule timezone immediately posts\nexactly one ordinary expense dated startOn, without backfilling every\nintervening historical period. A future startOn waits for its exact\ndate as the first occurrence; frequency selectors govern later periods.\nnextOccurrenceOn is strictly after today, or null when no future date\nremains. Every successful occurrence inserts a separate expense; it\nnever increases another expense's amount. Future plans stay outside\nspent totals until their expenses have been recorded.\nGenerated expenses follow the Owner's current automatic-removal policy.\nAt capacity they may atomically replace the globally oldest active\nexpense only when the saved actor and current original credential can\ndelete that target. Expired or revoked grants never remove expenses;\nCapacity failures retain the first ten unresolved frozen occurrences\nper rule for explicit retry and advance the future schedule. English\nemail notifies the saved execution actor when a usable verified email\nexists; otherwise Norulo inbox is used. While ten remain unresolved,\nlater failed occurrences are discarded and do not replace older ones.\nAuthorization, target and category failures still block execution.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecurringExpenseInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created rule or exact original creation response replayed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringExpenseRule"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/expense-recurring-rules/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Id"
        }
      ],
      "get": {
        "operationId": "getRecurringExpenseRule",
        "x-norulo-scope": "expenses:read",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "description": "Read the authorized rule without generating expenses. nextOccurrenceOn is future-only in the schedule timezone; awaitingSync distinguishes a read-only future projection from persisted scheduled progress. Retained capacity failures appear separately in pendingOccurrences.",
        "responses": {
          "200": {
            "description": "Authorized rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringExpenseRule"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "operationId": "updateRecurringExpenseRule",
        "x-norulo-scope": "expenses:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Pause or resume with a status-only body, replace the complete\ntemplate and calendar, or manually post one retained occurrence with\na retryPeriodKey-only body. All forms require the current If-Match.\nThe target is immutable. A complete edit or\nexplicit resume rechecks the current actor's write and project\naccess, then makes that actor the saved execution actor and adopts the\ncredential used for that write. A session edit/resume removes an old key\ngrant; a key edit/resume binds the automation to that key. The original\ncreation key and replay response remain immutable.\nA complete edit may omit categoryId for the same gated Jev automatic\nclassification as create. An explicit category is never changed, and\nCATEGORY_REQUIRED leaves the saved rule unchanged and preserves input.\nCanceled rules cannot resume. Changes affect future occurrences only;\nafter an edit/resume the next occurrence is strictly after the current\ndate in the rule's timezone and excludes periods already posted or\nretained for explicit retry. Deleted expenses still consume their\noriginal period identities. Changing a selector or timezone does not\nrecreate those identities; changing frequency uses that frequency's\nexisting weekly/monthly/quarterly/yearly identity namespace. The next\npointer is checked before saving, with at most 20 indexed candidate\nperiod probes; RECURRING_SCHEDULE_SEARCH_LIMIT returns 409 without\nsaving when that finite search cannot establish the next date. If no\neligible date remains, the active rule completes with a null pointer.\nPausing remains available when commercial\nwrite allowances are exhausted, with all role and revision guards.\nA retry uses the retained occurrence's frozen date, amount, currency,\npurpose and category, together with current actor, target, category,\ncapacity and credential authorization. Success atomically creates one\nindependent expense and immutable period identity, removes that pending\noccurrence, and returns the updated rule. It never merges amounts or\nchanges the future schedule. Failed retries retain the occurrence.\nA settled period retried with the current revision returns the rule\nwithout another expense; a stale revision still returns 412. Canceled\nrules reject historical retries with 409.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/RecurringExpenseInput"
                  },
                  {
                    "$ref": "#/components/schemas/RecurringExpenseRetryInput"
                  },
                  {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "status"
                    ],
                    "properties": {
                      "status": {
                        "type": "string",
                        "enum": [
                          "active",
                          "paused"
                        ]
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecurringExpenseRule"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "428": {
            "description": "If-Match is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "cancelRecurringExpenseRule",
        "x-norulo-scope": "expenses:write",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerKey": []
          }
        ],
        "description": "Permanently cancel automation while retaining all generated expense and occurrence history. This remains available after commercial quota exhaustion.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "204": {
            "description": "Canceled"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "428": {
            "description": "If-Match is required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/activity": {
      "get": {
        "tags": [
          "Ledger"
        ],
        "operationId": "listLedgerActivity",
        "x-norulo-scope": "expenses:read",
        "description": "Indexed history for one project or the shared pool in the selected ledger.\nA project target requires projectId; a shared target forbids projectId.\nResults are newest first by createdAt and id. The opaque nextCursor\nfreezes the first page's upper window boundary; every page still excludes\nrecords at or before the current Server clock minus 24 hours. Clients\ncannot extend the window with dates or their own clock. GET performs no\ncleanup writes and makes no external provider requests.\nCookie members see expense, project settings and recurring-rule activity.\nExpense-read API keys see expense and recurring-rule activity within\ntheir current workspace and target restrictions. Project-setting activity\nadditionally requires projects:read on the same key. A move appears in both affected pools;\na restricted key sees only the target change and the permitted-side\nrecord label when the opposite pool is outside its allowlist.\nActors are immutable name/GitHub-login/user-ID snapshots. Email-only\nidentities are supported; private email, credentials, provider metadata\nand API-key hashes are never exposed. API-key events identify the issuing\nperson and are labeled api_key, without claiming which person used the\ncredential. Generated expenses are labeled system and identify the rule's\nactual saved execution actor.\nNew history is published in the same CAS/idempotency/commercial-quota\ntransaction as its operation. Exact replays, failed operations and\nunchanged revisions publish no activity. At most 16 expired activity\nrows are retired per changed operation or existing hourly maintenance\ntick; original expense/workspace audit and financial rows are preserved.\n",
        "parameters": [
          {
            "name": "target",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "project",
                "shared"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 256,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "description": "Opaque cursor returned by this endpoint; not an expense or project resource ID"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Latest 24-hour activity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityPage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      }
    },
    "/api/v1/reports/summary": {
      "get": {
        "operationId": "getLedgerSummary",
        "x-norulo-scope": "reports:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Target"
          },
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "$ref": "#/components/parameters/CategoryId"
          },
          {
            "$ref": "#/components/parameters/From"
          },
          {
            "$ref": "#/components/parameters/To"
          },
          {
            "$ref": "#/components/parameters/Currency"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Separate project, shared and account totals by currency",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/timeseries": {
      "get": {
        "operationId": "getLedgerTimeseries",
        "x-norulo-scope": "reports:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Target"
          },
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "$ref": "#/components/parameters/CategoryId"
          },
          {
            "$ref": "#/components/parameters/From"
          },
          {
            "$ref": "#/components/parameters/To"
          },
          {
            "$ref": "#/components/parameters/Currency"
          },
          {
            "name": "bucket",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "day",
                "month"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Per-currency date buckets",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/categories": {
      "get": {
        "operationId": "getLedgerCategoriesReport",
        "x-norulo-scope": "reports:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Target"
          },
          {
            "$ref": "#/components/parameters/ProjectId"
          },
          {
            "$ref": "#/components/parameters/CategoryId"
          },
          {
            "$ref": "#/components/parameters/From"
          },
          {
            "$ref": "#/components/parameters/To"
          },
          {
            "$ref": "#/components/parameters/Currency"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Per-currency category buckets including historical archived categories",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/projects/{projectId}/monthly": {
      "get": {
        "operationId": "getProjectMonthlyExpenses",
        "x-norulo-scope": "expenses:read",
        "description": "Project expenses whose business date falls in one calendar month, from its first through its last day. Totals are grouped by currency and never combined or converted; they always cover the whole period, while itemized expenses are paginated in occurredOn,id order. Requires expenses:read because itemized records are returned. Archived projects keep their history; removed or unknown projects return 404.",
        "parameters": [
          {
            "$ref": "#/components/parameters/ReportProjectPath"
          },
          {
            "$ref": "#/components/parameters/Year"
          },
          {
            "$ref": "#/components/parameters/Month"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/PeriodCursor"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Per-currency totals and itemized project expenses for the period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectPeriodReport"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      }
    },
    "/api/v1/reports/projects/{projectId}/quarterly": {
      "get": {
        "operationId": "getProjectQuarterlyExpenses",
        "x-norulo-scope": "expenses:read",
        "description": "Project expenses whose business date falls in one calendar quarter (Q1 January-March through Q4 October-December). Totals are grouped by currency and never combined or converted; they always cover the whole period, while itemized expenses are paginated in occurredOn,id order. Requires expenses:read because itemized records are returned. Archived projects keep their history; removed or unknown projects return 404.",
        "parameters": [
          {
            "$ref": "#/components/parameters/ReportProjectPath"
          },
          {
            "$ref": "#/components/parameters/Year"
          },
          {
            "$ref": "#/components/parameters/Quarter"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/PeriodCursor"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Per-currency totals and itemized project expenses for the period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectPeriodReport"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      }
    },
    "/api/v1/reports/projects/{projectId}/annual": {
      "get": {
        "operationId": "getProjectAnnualExpenses",
        "x-norulo-scope": "expenses:read",
        "description": "Project expenses whose business date falls in one calendar year, January 1 through December 31. Totals are grouped by currency and never combined or converted; they always cover the whole period, while itemized expenses are paginated in occurredOn,id order. Requires expenses:read because itemized records are returned. Archived projects keep their history; removed or unknown projects return 404.",
        "parameters": [
          {
            "$ref": "#/components/parameters/ReportProjectPath"
          },
          {
            "$ref": "#/components/parameters/Year"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/PeriodCursor"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "Per-currency totals and itemized project expenses for the period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectPeriodReport"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/InvalidInput"
          }
        }
      }
    },
    "/api/v1/expense-suggestions": {
      "post": {
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "operationId": "suggestExpense",
        "x-norulo-scope": "suggestions:use",
        "description": "Advanced draft advice only; ordinary expense writes already attempt Free trial or paid assistance without this endpoint or its scope. Never writes an expense. Disabled unless evaluated and enabled. Shares the ledger Owner's call allowance with automatic assistance and review, irrespective of the actor's personal plan. Defaults are Free 20 one-time lifetime trials, Pro 1000/month, Max 4000/month. Paid calls reset by UTC calendar month even on annual subscriptions, without rollover. Each admitted model attempt consumes one call including failures; disabling Jev or changing plans never renews Free trials.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "purpose",
                  "target"
                ],
                "properties": {
                  "purpose": {
                    "type": "string",
                    "maxLength": 500
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "occurredOn": {
                    "type": "string",
                    "format": "date"
                  },
                  "amount": {
                    "type": "string",
                    "description": "Decimal amount in selected currency"
                  },
                  "currency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "target": {
                    "$ref": "#/components/schemas/Target"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Status, optional suggestionId, candidates and probabilities; never an expense write",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "available",
                        "uncertain",
                        "unavailable"
                      ]
                    },
                    "suggestionId": {
                      "type": "string"
                    },
                    "questionVersion": {
                      "type": "string"
                    },
                    "modelVersion": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "suggestions": {
                      "type": "object",
                      "properties": {
                        "categoryId": {
                          "type": "string"
                        },
                        "targetKind": {
                          "type": "string"
                        },
                        "duplicateExpenseId": {
                          "type": "string"
                        }
                      }
                    },
                    "probabilities": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current scope/target authority forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Ledger owner rate or Jev call allowance exhausted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/expense-suggestions/{id}/decision": {
      "post": {
        "operationId": "recordExpenseSuggestionDecision",
        "x-norulo-scope": "suggestions:use",
        "description": "Record the user's selected category and target after reviewing a suggestion; never writes an expense.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/WorkspaceHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "categoryId",
                  "target"
                ],
                "properties": {
                  "categoryId": {
                    "type": "string"
                  },
                  "target": {
                    "$ref": "#/components/schemas/Target"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "204": {
            "description": "Decision recorded"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    }
  },
  "components": {
    "headers": {
      "NoStore": {
        "description": "Authentication responses are never cached",
        "schema": {
          "type": "string",
          "const": "no-store"
        }
      },
      "AuthCookie": {
        "description": "Secure HttpOnly cookie with Path / and the configured SameSite policy; nr_email_challenge lasts 600 seconds, nr_session lasts 604800 seconds, and explicit clearing uses Max-Age 0",
        "schema": {
          "type": "string"
        }
      },
      "AuthRetryAfter": {
        "description": "Minimum whole seconds before another request is admitted",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      },
      "RateRetryAfter": {
        "description": "Present on API_RATE_LIMIT: length in whole seconds of the exceeded window, 10 or 60; wait at least this long before retrying",
        "schema": {
          "type": "integer",
          "enum": [
            10,
            60
          ]
        }
      }
    },
    "requestBodies": {
      "InvitationToken": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "token"
              ],
              "properties": {
                "token": {
                  "type": "string",
                  "pattern": "^nri_[A-Za-z0-9_-]{43}$"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "cookieSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "nr_session"
      },
      "bearerKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "nrk_ API key"
      }
    },
    "parameters": {
      "AuthOrigin": {
        "name": "Origin",
        "in": "header",
        "schema": {
          "type": "string",
          "format": "uri"
        },
        "description": "Trusted app Origin for sign-out and explicit GitHub link; a trusted Referer origin is accepted when Origin is absent"
      },
      "EmailAuthOrigin": {
        "name": "Origin",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uri"
        },
        "description": "Trusted app Origin required for both email POSTs; Referer is never a substitute"
      },
      "WorkspacePath": {
        "name": "workspaceId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,120}$"
        }
      },
      "WorkspaceHeader": {
        "name": "X-Norulo-Workspace",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "Explicit ledger selection; never grants membership and cannot override a key binding"
      },
      "WorkspaceQuery": {
        "name": "workspaceId",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "CSV/native-link selector; must agree with any header"
      },
      "JoinRequestPath": {
        "name": "requestId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,120}$"
        }
      },
      "Id": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,120}$"
        }
      },
      "IfMatch": {
        "name": "If-Match",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "maxLength": 18,
          "pattern": "^\"[1-9][0-9]{0,15}\"$"
        },
        "description": "Quoted revision ETag in the exact integer range 1 through 9007199254740991"
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        }
      },
      "Target": {
        "name": "target",
        "in": "query",
        "schema": {
          "type": "string",
          "enum": [
            "all",
            "project",
            "shared"
          ],
          "default": "all"
        }
      },
      "ProjectId": {
        "name": "projectId",
        "in": "query",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,120}$"
        }
      },
      "CategoryId": {
        "name": "categoryId",
        "in": "query",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,120}$"
        }
      },
      "From": {
        "name": "from",
        "in": "query",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "Inclusive business date"
      },
      "To": {
        "name": "to",
        "in": "query",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "Exclusive business date"
      },
      "Currency": {
        "name": "currency",
        "in": "query",
        "schema": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,120}$"
        }
      },
      "ReportProjectPath": {
        "name": "projectId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,120}$"
        }
      },
      "Year": {
        "name": "year",
        "in": "query",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[0-9]{4}$"
        },
        "description": "Four-digit calendar year 0001 through 9999"
      },
      "Month": {
        "name": "month",
        "in": "query",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[0-9]{1,2}$"
        },
        "description": "Calendar month 1 through 12; a leading zero is accepted"
      },
      "Quarter": {
        "name": "quarter",
        "in": "query",
        "required": true,
        "schema": {
          "type": "string",
          "enum": [
            "1",
            "2",
            "3",
            "4"
          ]
        }
      },
      "PeriodCursor": {
        "name": "cursor",
        "in": "query",
        "schema": {
          "type": "string",
          "maxLength": 131,
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}_[A-Za-z0-9_-]{1,120}$"
        },
        "description": "Opaque nextCursor returned by the same period report"
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 50
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Authentication required",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Scope, target, GitHub authorization or plan capacity insufficient",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource absent or outside the authorized ledger",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "Idempotency conflict or a quota window changed; reload before retrying",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PreconditionFailed": {
        "description": "Revision does not match If-Match",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InvalidInput": {
        "description": "Invalid or missing field. CATEGORY_REQUIRED on ordinary expense or recurring rule create or complete edit may include top-level assistance when eligible Pro or Max inference is unavailable or cannot confidently select an existing active category. No expense or rule is created or updated in that case.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "API_RATE_LIMIT when a request-frequency window is exceeded, or a ledger owner write allowance code such as WRITE_RATE_LIMIT or MONTHLY_WRITE_LIMIT. Jev call exhaustion falls back to manual completion for ordinary expense writes and does not block a write with an explicit category.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RateRetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "BillingPage": {
        "type": "object",
        "required": [
          "page",
          "account",
          "ledgerUsage"
        ],
        "properties": {
          "page": {
            "type": "object",
            "required": [
              "id",
              "subscriptionAction",
              "checkoutAction"
            ],
            "properties": {
              "id": {
                "const": "billing"
              },
              "subscriptionAction": {
                "type": "object",
                "required": [
                  "label",
                  "href"
                ],
                "properties": {
                  "label": {
                    "const": "View pricing"
                  },
                  "href": {
                    "const": "/pricing"
                  }
                }
              },
              "checkoutAction": {
                "type": "null"
              }
            }
          },
          "account": {
            "$ref": "#/components/schemas/BillingAccount"
          },
          "ledgerUsage": {
            "$ref": "#/components/schemas/LedgerUsage"
          }
        }
      },
      "BillingCatalog": {
        "type": "object",
        "required": [
          "provider",
          "enabled",
          "currency",
          "plans",
          "page"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "creem",
              "disabled"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "plans": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": {
              "$ref": "#/components/schemas/BillingPlan"
            }
          },
          "page": {
            "type": "object",
            "required": [
              "id",
              "checkoutAction",
              "billingRoute"
            ],
            "properties": {
              "id": {
                "const": "pricing"
              },
              "checkoutAction": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "Null when provider billing is disabled; Free remains available without checkout.",
                "required": [
                  "method",
                  "href"
                ],
                "properties": {
                  "method": {
                    "const": "POST"
                  },
                  "href": {
                    "const": "/billing/checkout-sessions"
                  }
                }
              },
              "billingRoute": {
                "const": "/billing"
              }
            }
          },
          "account": {
            "$ref": "#/components/schemas/BillingAccount"
          },
          "ledgerUsage": {
            "$ref": "#/components/schemas/LedgerUsage"
          },
          "name": {
            "type": "string",
            "description": "Optional compatibility label for the Pro plan"
          },
          "description": {
            "type": "string"
          },
          "interval": {
            "type": "string",
            "enum": [
              "month",
              "year"
            ]
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional compatibility Pro monthly price; use the plan's explicit prices instead"
          }
        }
      },
      "BillingPlan": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "entitlements",
          "prices"
        ],
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "free",
              "pro",
              "max"
            ]
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "entitlements": {
            "$ref": "#/components/schemas/Entitlements"
          },
          "prices": {
            "type": "object",
            "required": [
              "month"
            ],
            "properties": {
              "month": {
                "$ref": "#/components/schemas/BillingPrice"
              },
              "year": {
                "$ref": "#/components/schemas/BillingPrice"
              }
            }
          }
        }
      },
      "BillingPrice": {
        "type": "object",
        "required": [
          "amount",
          "currency",
          "interval",
          "configured"
        ],
        "properties": {
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Verified decimal price; null means unavailable rather than zero"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "interval": {
            "type": "string",
            "enum": [
              "month",
              "year"
            ]
          },
          "configured": {
            "type": "boolean"
          },
          "productId": {
            "type": [
              "string",
              "null"
            ]
          },
          "billingPeriod": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "every-month",
              "every-year",
              null
            ]
          }
        }
      },
      "BillingAccount": {
        "type": "object",
        "required": [
          "provider",
          "status",
          "plan",
          "interval",
          "customerId",
          "subscriptionId",
          "subscriptionItemId",
          "customerEmail",
          "currentPeriodStart",
          "currentPeriodEnd",
          "cancelAtPeriodEnd",
          "canceledAt",
          "lastEventId",
          "lastEventType",
          "lastEventCreated",
          "updatedAt",
          "entitlements",
          "previewPlanGrant",
          "pendingChange",
          "subscriptionEvents"
        ],
        "properties": {
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "none",
              "active",
              "trialing",
              "canceling",
              "past_due",
              "unpaid",
              "paused",
              "canceled"
            ]
          },
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "pro",
              "max"
            ]
          },
          "interval": {
            "type": "string",
            "enum": [
              "month",
              "year"
            ]
          },
          "customerId": {
            "type": [
              "string",
              "null"
            ]
          },
          "subscriptionId": {
            "type": [
              "string",
              "null"
            ]
          },
          "subscriptionItemId": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerEmail": {
            "type": [
              "string",
              "null"
            ],
            "description": "Billing contact; does not prove a login identity"
          },
          "currentPeriodStart": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "currentPeriodEnd": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "cancelAtPeriodEnd": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "canceledAt": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "lastEventId": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastEventType": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastEventCreated": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "updatedAt": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "entitlements": {
            "type": "null",
            "description": "Account compatibility field; read ledger entitlements through /api/v1/me or catalog plans"
          },
          "previewPlanGrant": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "grantId",
                  "plan",
                  "startsAt",
                  "expiresAt",
                  "issuedAt",
                  "active"
                ],
                "properties": {
                  "grantId": {
                    "type": "string"
                  },
                  "plan": {
                    "type": "string",
                    "enum": [
                      "pro",
                      "max"
                    ]
                  },
                  "startsAt": {
                    "type": "integer"
                  },
                  "expiresAt": {
                    "type": "integer"
                  },
                  "issuedAt": {
                    "type": "integer"
                  },
                  "active": {
                    "type": "boolean"
                  }
                }
              }
            ]
          },
          "pendingChange": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "plan",
                  "interval",
                  "requestedAt"
                ],
                "properties": {
                  "plan": {
                    "type": "string",
                    "enum": [
                      "pro",
                      "max"
                    ]
                  },
                  "interval": {
                    "type": "string",
                    "enum": [
                      "month",
                      "year"
                    ]
                  },
                  "requestedAt": {
                    "$ref": "#/components/schemas/NullableEpochSeconds"
                  }
                }
              }
            ]
          },
          "subscriptionEvents": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/BillingSubscriptionEvent"
            }
          }
        }
      },
      "BillingSubscriptionEvent": {
        "type": "object",
        "required": [
          "provider",
          "customerId",
          "customerEmail",
          "subscriptionId",
          "subscriptionItemId",
          "status",
          "plan",
          "interval",
          "currentPeriodStart",
          "currentPeriodEnd",
          "cancelAtPeriodEnd",
          "canceledAt",
          "eventType",
          "eventId",
          "eventCreated",
          "processedAt",
          "stale"
        ],
        "properties": {
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerId": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerEmail": {
            "type": [
              "string",
              "null"
            ]
          },
          "subscriptionId": {
            "type": [
              "string",
              "null"
            ]
          },
          "subscriptionItemId": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "none",
              "active",
              "trialing",
              "canceling",
              "past_due",
              "unpaid",
              "paused",
              "canceled"
            ]
          },
          "plan": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "free",
              "pro",
              "max",
              null
            ]
          },
          "interval": {
            "type": "string",
            "enum": [
              "month",
              "year"
            ]
          },
          "currentPeriodStart": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "currentPeriodEnd": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "cancelAtPeriodEnd": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "canceledAt": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "eventType": {
            "type": [
              "string",
              "null"
            ]
          },
          "eventId": {
            "type": [
              "string",
              "null"
            ]
          },
          "eventCreated": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "processedAt": {
            "$ref": "#/components/schemas/NullableEpochSeconds"
          },
          "stale": {
            "type": "boolean"
          }
        }
      },
      "NullableEpochSeconds": {
        "type": [
          "integer",
          "null"
        ],
        "description": "UTC epoch seconds or null when the provider has not supplied a fact"
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code"
            ],
            "properties": {
              "code": {
                "type": "string",
                "minLength": 1
              },
              "requestId": {
                "type": "string",
                "pattern": "^[a-f0-9]{32}$",
                "description": "Opaque correlation ID for private Server diagnostics; no request or credential data"
              },
              "message": {
                "type": "string",
                "description": "Optional human-readable detail; branch client logic on code"
              }
            }
          },
          "assistance": {
            "$ref": "#/components/schemas/ExpenseAssistance"
          }
        },
        "examples": [
          {
            "error": {
              "code": "PRECONDITION_FAILED"
            }
          },
          {
            "error": {
              "code": "CATEGORY_REQUIRED"
            },
            "assistance": {
              "status": "unavailable",
              "categorySource": null,
              "suggestions": {}
            }
          }
        ]
      },
      "ApiKeyScope": {
        "type": "string",
        "enum": [
          "profile:read",
          "projects:read",
          "projects:write",
          "categories:read",
          "categories:write",
          "expenses:read",
          "expenses:write",
          "reports:read",
          "suggestions:use",
          "members:read",
          "members:write"
        ]
      },
      "ApiKeyRestrictions": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "projectIds": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "string",
              "pattern": "^prj_[A-Za-z0-9_-]{1,100}$"
            },
            "description": "Omit for all projects; an empty array grants no project access. Does not grant shared access. Cannot be supplied with members scopes."
          },
          "shared": {
            "type": "boolean",
            "default": false,
            "description": "Explicit shared-pool permission; project access never implies shared access"
          },
          "workspaceId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,120}$",
            "description": "Bound ledger; cannot be overridden by a later request header"
          },
          "workspaceMemberRevision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Server records the current selected-ledger membership revision; changing membership invalidates team keys"
          }
        }
      },
      "ApiKeyInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120,
            "not": {
              "pattern": "[\\r\\n\\x00]"
            },
            "description": "Optional display label of at most 120 characters before trimming; omission or blank uses API key. CR/LF and NUL are rejected."
          },
          "scopes": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ApiKeyScope"
              },
              {
                "type": "array",
                "minItems": 1,
                "maxItems": 11,
                "items": {
                  "$ref": "#/components/schemas/ApiKeyScope"
                }
              }
            ],
            "description": "Explicit scope or list. Omission uses the five read-only defaults and excludes members scopes. Names are trimmed and lowercased; duplicates are normalized.",
            "default": [
              "profile:read",
              "projects:read",
              "categories:read",
              "expenses:read",
              "reports:read"
            ]
          },
          "restrictions": {
            "$ref": "#/components/schemas/ApiKeyRestrictions"
          },
          "expiresAt": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Optional UTC epoch seconds; must be after Server time"
          },
          "expiresInSeconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Positive values set expiry relative to Server time; zero leaves expiresAt unchanged"
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "name",
          "userId",
          "prefix",
          "scopes",
          "createdAt",
          "expiresAt",
          "lastUsedAt",
          "revokedAt",
          "restrictions"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "prefix": {
            "type": "string",
            "description": "Public token prefix; never a usable credential"
          },
          "scopes": {
            "type": "array",
            "maxItems": 11,
            "items": {
              "$ref": "#/components/schemas/ApiKeyScope"
            }
          },
          "createdAt": {
            "type": "integer",
            "minimum": 0,
            "description": "UTC epoch seconds"
          },
          "expiresAt": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "lastUsedAt": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Reserved compatibility metadata. Usage tracking is currently disabled and this field is null for newly issued keys; null does not mean the key has never been used. Reads do not write usage timestamps."
          },
          "revokedAt": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "restrictions": {
            "$ref": "#/components/schemas/ApiKeyRestrictions"
          }
        }
      },
      "AccountSession": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "authenticated",
          "user",
          "github"
        ],
        "properties": {
          "authenticated": {
            "type": "boolean"
          },
          "user": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SessionUser"
              },
              {
                "type": "null"
              }
            ]
          },
          "github": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "identityConnected",
              "repositoriesConnected"
            ],
            "properties": {
              "identityConnected": {
                "type": "boolean",
                "description": "Account has its own GitHub identity credential; email sign-in does not require it"
              },
              "repositoriesConnected": {
                "type": "boolean",
                "description": "The account has a current authorized repository connection"
              }
            }
          }
        }
      },
      "SessionUser": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "avatarUrl",
          "email",
          "emailVerified",
          "providers"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Immutable account and personal-ledger identity; preserved across explicit provider links"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "avatarUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Verified login email only; never an unverified provider or billing contact"
          },
          "emailVerified": {
            "type": "boolean"
          },
          "providers": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string"
            },
            "description": "Explicit login identities such as email and github; legacy accounts may omit an explicit provider in stored facts"
          }
        }
      },
      "EmailCodeRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "email",
          "purpose"
        ],
        "properties": {
          "email": {
            "type": "string",
            "minLength": 3,
            "maxLength": 254,
            "description": "ASCII mailbox normalized by trimming and lowercasing; provider aliases and plus tags remain distinct"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "login",
              "link"
            ]
          }
        }
      },
      "EmailCodeChallenge": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "challengeId",
          "expiresIn",
          "retryAfter"
        ],
        "properties": {
          "challengeId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{43}$"
          },
          "expiresIn": {
            "type": "integer",
            "const": 600
          },
          "retryAfter": {
            "type": "integer",
            "const": 60
          }
        }
      },
      "EmailCodeVerification": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "email",
          "challengeId",
          "code"
        ],
        "properties": {
          "email": {
            "type": "string",
            "minLength": 3,
            "maxLength": 254
          },
          "challengeId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{43}$"
          },
          "code": {
            "type": "string",
            "pattern": "^[0-9]{6}$",
            "description": "Six ASCII digits, including leading zeros"
          }
        }
      },
      "AssignableRole": {
        "type": "string",
        "enum": [
          "admin",
          "editor",
          "viewer"
        ]
      },
      "Workspace": {
        "type": "object",
        "required": [
          "id",
          "ownerId",
          "name",
          "role",
          "revision",
          "permissions"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Immutable ledger owner partition; existing data is preserved"
          },
          "ownerId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "editor",
              "viewer"
            ]
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Current member generation; Owner has implicit revision 1"
          },
          "permissions": {
            "type": "object",
            "required": [
              "writeExpenses",
              "manageProjects",
              "manageCategories",
              "manageMembers",
              "manageAdmins"
            ],
            "properties": {
              "writeExpenses": {
                "type": "boolean"
              },
              "manageProjects": {
                "type": "boolean"
              },
              "manageCategories": {
                "type": "boolean"
              },
              "manageMembers": {
                "type": "boolean"
              },
              "manageAdmins": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "WorkspaceMember": {
        "type": "object",
        "required": [
          "userId",
          "role",
          "revision"
        ],
        "properties": {
          "userId": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "githubLogin": {
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "editor",
              "viewer"
            ]
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "joinedAt": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WorkspaceInvitation": {
        "type": "object",
        "required": [
          "id",
          "recipient",
          "createdByUserId",
          "canReview",
          "role",
          "status",
          "revision",
          "expiresAt",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "recipient": {
            "type": [
              "object",
              "null"
            ],
            "description": "Null for unassigned links; preserved identity for legacy targeted links",
            "required": [
              "githubId",
              "login"
            ],
            "properties": {
              "githubId": {
                "type": "string"
              },
              "login": {
                "type": "string"
              }
            }
          },
          "createdByUserId": {
            "type": "string"
          },
          "canReview": {
            "type": "boolean",
            "description": "Current actor is the original inviter with current management authority"
          },
          "role": {
            "$ref": "#/components/schemas/AssignableRole"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "accepted",
              "revoked"
            ]
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WorkspaceJoinRequest": {
        "type": "object",
        "required": [
          "id",
          "invitationId",
          "workspaceId",
          "applicant",
          "status",
          "revision",
          "createdAt",
          "updatedAt",
          "reviewedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "invitationId": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "applicant": {
            "type": "object",
            "required": [
              "userId",
              "name",
              "githubLogin"
            ],
            "properties": {
              "userId": {
                "type": "string",
                "description": "Authenticated Norulo account identity"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "githubLogin": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "rejected"
            ]
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "reviewedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "WorkspaceInvitationPreview": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WorkspaceInvitation"
          },
          {
            "type": "object",
            "required": [
              "request",
              "workspace"
            ],
            "properties": {
              "request": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/WorkspaceJoinRequest"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "workspace": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Workspace"
                  }
                ],
                "description": "Before approval all permissions are false; only an approved applicant receives its current active role and generation"
              }
            }
          }
        ]
      },
      "WorkspaceJoinReview": {
        "type": "object",
        "required": [
          "request",
          "workspace"
        ],
        "properties": {
          "request": {
            "$ref": "#/components/schemas/WorkspaceJoinRequest"
          },
          "workspace": {
            "$ref": "#/components/schemas/Workspace"
          }
        }
      },
      "Me": {
        "type": "object",
        "required": [
          "id",
          "scopes",
          "entitlements",
          "workspace",
          "ledgerUsage"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "workspace": {
            "$ref": "#/components/schemas/Workspace"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "entitlements": {
            "$ref": "#/components/schemas/Entitlements"
          },
          "ledgerUsage": {
            "$ref": "#/components/schemas/LedgerUsage"
          }
        }
      },
      "LedgerUsage": {
        "type": "object",
        "required": [
          "workspaceId",
          "projects",
          "expenseRecords",
          "jev"
        ],
        "description": "Read-only selected-ledger capacity. Project counts include current undeleted projects, including archived projects. Removed projects release project capacity. Expense counts include undeleted Shared pool expenses and undeleted expenses in nonremoved projects, including archived projects and recurring-generated expenses. Soft deletion releases expense capacity while preserving financial audit and replay history. Permanent project removal releases its project place and active expense places and erases its attributable business history. Legacy cumulative usage counters do not determine current capacity. Current effective plan and operator configuration set the limits.",
        "properties": {
          "workspaceId": {
            "type": "string"
          },
          "projects": {
            "$ref": "#/components/schemas/CapacityUsage"
          },
          "expenseRecords": {
            "$ref": "#/components/schemas/CapacityUsage"
          },
          "jev": {
            "description": "Current UTC-month conservative model reservations and configured allowance for the ledger Owner's effective Pro or Max plan. Null for Free. Reads never initialize or reset usage; older-month reservations display as zero. Billing always uses the actor's personal ledger, independently of workspace selection.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/JevUsage"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "JevUsage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "month",
          "period",
          "usedCalls",
          "limitCalls",
          "remainingCalls",
          "currency",
          "usedMicrousd",
          "limitMicrousd"
        ],
        "properties": {
          "month": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9]{4}-[0-9]{2}$",
            "description": "UTC month for paid calls; null for the lifetime Free trial"
          },
          "period": {
            "type": "string",
            "enum": [
              "lifetime",
              "utc-calendar-month"
            ]
          },
          "usedCalls": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Admitted model attempts including failed or ambiguous outcomes; historical partial reservations round up"
          },
          "limitCalls": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Current count allowance; Free 20 lifetime trials, Pro 1000/month, Max 4000/month by default"
          },
          "remainingCalls": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "currency": {
            "type": "string",
            "const": "USD",
            "deprecated": true
          },
          "usedMicrousd": {
            "deprecated": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Conservative pre-call reservation in millionths of USD, including admitted failed or ambiguous attempts; not actual invoiced usage"
          },
          "limitMicrousd": {
            "deprecated": true,
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000,
            "description": "Current configured monthly allowance in millionths of USD"
          }
        }
      },
      "CapacityUsage": {
        "type": "object",
        "required": [
          "used",
          "limit",
          "remaining"
        ],
        "properties": {
          "used": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1
          },
          "remaining": {
            "type": "integer",
            "minimum": 0,
            "description": "max(0; limit minus used)"
          }
        }
      },
      "AccountExpenseRetentionPreference": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "autoRemoveOldestExpense",
          "revision"
        ],
        "properties": {
          "autoRemoveOldestExpense": {
            "type": "boolean",
            "default": false,
            "description": "Owner policy for at-capacity ordinary and recurring expense creation; changing it never immediately removes history"
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Independent preference CAS revision; defaults to 1 for legacy accounts"
          }
        }
      },
      "AccountJevPreference": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "enabled",
          "revision",
          "eligible",
          "available",
          "monthlyCalls",
          "trialCalls",
          "period",
          "monthlyBudgetUsd"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Persisted preference; true for a legacy account without preference fields. Free uses this preference for its one-time trial"
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Independent preference CAS revision"
          },
          "eligible": {
            "type": "boolean",
            "description": "The actual signed-in account supports Jev trial or paid calls"
          },
          "available": {
            "type": "boolean",
            "description": "Current entitlement, persisted preference and runtime activation gates all passed"
          },
          "monthlyCalls": {
            "type": "integer",
            "minimum": 0,
            "maximum": 36324,
            "description": "Paid monthly calls; zero for Free"
          },
          "trialCalls": {
            "type": "integer",
            "minimum": 0,
            "maximum": 20,
            "description": "Free lifetime allowance; zero for paid plans"
          },
          "period": {
            "type": "string",
            "enum": [
              "lifetime",
              "utc-calendar-month"
            ]
          },
          "monthlyBudgetUsd": {
            "deprecated": true,
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          }
        }
      },
      "Entitlements": {
        "type": "object",
        "required": [
          "plan",
          "limits",
          "jev"
        ],
        "properties": {
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "pro",
              "max"
            ]
          },
          "limits": {
            "type": "object",
            "required": [
              "projects",
              "expenseRecords",
              "writesPerMinute",
              "writesPerMonth"
            ],
            "properties": {
              "projects": {
                "type": "integer",
                "minimum": 1,
                "description": "Current undeleted projects including archived projects"
              },
              "expenseRecords": {
                "type": "integer",
                "minimum": 1,
                "description": "Current undeleted expenses in Shared pool or nonremoved projects. Default limits are Free 300; Pro 20000; Max 200000. Read the current configured limit from the response."
              },
              "writesPerMinute": {
                "type": "integer",
                "minimum": 1,
                "description": "Fixed UTC minute bucket shared by the ledger owner's members and API keys"
              },
              "writesPerMonth": {
                "type": "integer",
                "minimum": 1,
                "description": "UTC calendar month shared by the ledger owner's members and API keys"
              }
            }
          },
          "jev": {
            "type": "object",
            "required": [
              "eligible",
              "available",
              "monthlyCalls",
              "trialCalls",
              "monthlyBudgetUsd",
              "period",
              "rollover"
            ],
            "properties": {
              "eligible": {
                "type": "boolean",
                "description": "Current ledger owner's Free trial or paid entitlement; actor's personal plan does not grant extra calls"
              },
              "enabled": {
                "type": "boolean",
                "description": "Private account entitlements include the ledger owner's persisted model preference; malformed state fails closed. Public plan templates have no user preference"
              },
              "available": {
                "type": "boolean",
                "description": "Eligibility, current activation gates and the ledger owner's preference all passed for private entitlements"
              },
              "monthlyCalls": {
                "type": "integer",
                "minimum": 0,
                "maximum": 36324,
                "description": "Paid monthly calls; zero for Free"
              },
              "trialCalls": {
                "type": "integer",
                "minimum": 0,
                "maximum": 20,
                "description": "Free lifetime allowance; zero for paid plans"
              },
              "monthlyBudgetUsd": {
                "deprecated": true,
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
              },
              "period": {
                "type": "string",
                "enum": [
                  "lifetime",
                  "utc-calendar-month"
                ]
              },
              "rollover": {
                "type": "boolean",
                "const": false
              }
            }
          }
        }
      },
      "Repository": {
        "type": "object",
        "required": [
          "githubRepoId",
          "fullName",
          "installationId",
          "account"
        ],
        "properties": {
          "githubRepoId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "fullName": {
            "type": "string"
          },
          "isBound": {
            "type": "boolean",
            "description": "A repository binding exists in the selected ledger, including archived projects. API keys consider only their explicitly allowed projects. No project ID or cached metadata is disclosed."
          },
          "installationId": {
            "type": "string",
            "pattern": "^[1-9][0-9]{0,15}$"
          },
          "account": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/GitHubAccount"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "GitHubAccount": {
        "type": "object",
        "required": [
          "id",
          "login",
          "type"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "login": {
            "type": "string",
            "maxLength": 100
          },
          "type": {
            "type": "string",
            "enum": [
              "User",
              "Organization"
            ]
          }
        }
      },
      "RepositoryPage": {
        "type": "object",
        "required": [
          "items",
          "nextCursor",
          "githubAccess",
          "organizations"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Repository"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "organizations": {
            "type": "array",
            "maxItems": 10,
            "description": "Current actor authorized installation account metadata only; organization membership does not grant ledger access.",
            "items": {
              "$ref": "#/components/schemas/GitHubAccount"
            }
          },
          "githubAccess": {
            "type": "string",
            "enum": [
              "authorized",
              "not_connected",
              "lost",
              "reauthorization_required"
            ],
            "description": "Expired or revoked credentials never revoke the Norulo session or write on a GET. When githubRefreshRequired is true, cookie clients may POST /integrations/github/refresh and API keys may POST /api/v1/integrations/github/refresh, then repeat this read once after success. Otherwise reconnect requires explicit GitHub login. Unavailable/unknown grants return an error rather than a successful empty page."
          },
          "githubRefreshRequired": {
            "type": "boolean",
            "description": "A saved refresh credential permits one separate authenticated refresh attempt; no token material is returned"
          }
        }
      },
      "Target": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "kind",
              "projectId"
            ],
            "additionalProperties": false,
            "properties": {
              "kind": {
                "const": "project"
              },
              "projectId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,120}$"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "kind"
            ],
            "additionalProperties": false,
            "properties": {
              "kind": {
                "const": "shared"
              }
            }
          }
        ]
      },
      "ProjectInput": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "not": {
          "required": [
            "githubRepoId",
            "githubRepoIds"
          ]
        },
        "allOf": [
          {
            "if": {
              "anyOf": [
                {
                  "required": [
                    "githubRepoIds"
                  ],
                  "properties": {
                    "githubRepoIds": {
                      "maxItems": 0
                    }
                  }
                },
                {
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "githubRepoId"
                        ]
                      },
                      {
                        "required": [
                          "githubRepoIds"
                        ]
                      }
                    ]
                  }
                }
              ]
            },
            "then": {
              "required": [
                "name"
              ],
              "properties": {
                "name": {
                  "minLength": 1,
                  "pattern": "\\S"
                },
                "githubOrganizationId": {
                  "type": "null"
                }
              }
            }
          }
        ],
        "properties": {
          "githubRepoId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "deprecated": true,
            "description": "Compatible singular repository selection"
          },
          "githubRepoIds": {
            "type": "array",
            "minItems": 0,
            "maxItems": 30,
            "uniqueItems": true,
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "description": "Omit or use an empty array for a standalone project with a nonblank name. A nonempty set explicitly selects currently actor-authorized repositories; a repository belongs to one project per ledger, including archived projects. Cross-organization selections are allowed."
          },
          "name": {
            "type": "string",
            "maxLength": 120,
            "description": "Financial project name that persists independently of GitHub grants. Required and nonblank for standalone projects; optional for compatible repository-backed creation."
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "developmentUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "productUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "adminConsoleUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "githubOrganizationId": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Optional association on a repository-backed project, verified against current actor installation account metadata; never selects all organization repositories. Must be absent or null on standalone creation."
          }
        }
      },
      "ProjectPatch": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "not": {
          "required": [
            "githubRepoId",
            "githubRepoIds"
          ]
        },
        "allOf": [
          {
            "if": {
              "required": [
                "githubRepoIds"
              ],
              "properties": {
                "githubRepoIds": {
                  "maxItems": 0
                }
              }
            },
            "then": {
              "properties": {
                "githubOrganizationId": {
                  "type": "null"
                }
              }
            }
          }
        ],
        "properties": {
          "githubRepoId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991,
            "deprecated": true
          },
          "githubRepoIds": {
            "type": "array",
            "minItems": 0,
            "maxItems": 30,
            "uniqueItems": true,
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "description": "Atomically replace the full explicit repository set under If-Match. Every selected repository must currently be authorized to the actor. Omit to retain historical lost bindings. An explicit empty array disconnects all repositories and clears the organization association while preserving the project ID and expenses; the final project name must be nonblank (supply name in the same patch when needed)."
          },
          "name": {
            "type": "string",
            "maxLength": 120,
            "description": "The final name must be nonblank when no repositories are linked; omission retains the existing name."
          },
          "githubOrganizationId": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "developmentUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "productUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "adminConsoleUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          }
        }
      },
      "ProjectUrl": {
        "type": [
          "string",
          "null"
        ],
        "minLength": 1,
        "maxLength": 2048,
        "pattern": "^[Hh][Tt][Tt][Pp][Ss]?://",
        "description": "Absolute HTTP(S) URL, at most 2048 UTF-8 bytes. Server rejects missing/invalid hosts or ports, userinfo, whitespace, control characters and backslashes. Null clears the link; omission preserves it on PATCH and defaults to null on POST. Empty strings are invalid. Development, product and admin console links are ledger metadata and never grant repository access."
      },
      "BoundRepository": {
        "type": "object",
        "required": [
          "githubRepoId",
          "githubFullName",
          "githubAccess",
          "installationId",
          "account"
        ],
        "properties": {
          "githubRepoId": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "githubFullName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null when the actor's current GitHub access cannot be verified; cached names are never exposed"
          },
          "githubAccess": {
            "type": "string",
            "enum": [
              "authorized",
              "lost",
              "reauthorization_required",
              "unavailable"
            ]
          },
          "installationId": {
            "type": [
              "string",
              "null"
            ]
          },
          "account": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/GitHubAccount"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ProjectOrganization": {
        "type": "object",
        "required": [
          "id",
          "login",
          "type",
          "githubAccess"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "login": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "const": "Organization"
          },
          "githubAccess": {
            "type": "string",
            "enum": [
              "authorized",
              "lost",
              "reauthorization_required",
              "unavailable"
            ]
          }
        }
      },
      "Project": {
        "type": "object",
        "required": [
          "id",
          "name",
          "githubRepoId",
          "githubRepoIds",
          "repositories",
          "githubOrganizationId",
          "githubOrganization",
          "description",
          "developmentUrl",
          "productUrl",
          "adminConsoleUrl",
          "status",
          "githubAccess",
          "canCreateExpense",
          "revision",
          "totals"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "githubRepoId": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 9007199254740991,
            "description": "Null for a standalone project; otherwise a compatibility anchor among the currently bound repositories. Never a fabricated repository ID."
          },
          "githubRepoIds": {
            "type": "array",
            "minItems": 0,
            "maxItems": 30,
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          },
          "repositories": {
            "type": "array",
            "minItems": 0,
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/BoundRepository"
            }
          },
          "githubOrganizationId": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "githubOrganization": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ProjectOrganization"
              },
              {
                "type": "null"
              }
            ]
          },
          "githubFullName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Compatibility anchor name from the actor's current grant; ledger financial history remains available"
          },
          "description": {
            "type": "string"
          },
          "developmentUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "productUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "adminConsoleUrl": {
            "$ref": "#/components/schemas/ProjectUrl"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "githubAccess": {
            "type": "string",
            "enum": [
              "not_linked",
              "authorized",
              "partial",
              "lost",
              "reauthorization_required",
              "unavailable"
            ],
            "description": "not_linked identifies an explicitly standalone project, with null GitHub anchor and organization and empty repository arrays; loss or unavailability of a bound grant never implicitly disconnects a project."
          },
          "githubRefreshRequired": {
            "type": "boolean",
            "description": "The actual actor may renew their own GitHub credential through the separate cookie or API-key authenticated refresh endpoint"
          },
          "canCreateExpense": {
            "type": "boolean",
            "description": "Active standalone project, or an active repository-backed project with at least one bound repository currently authorized to the actor. Ledger role, key target scopes and plan limits still apply. Historical edits and deletion do not require a live GitHub grant."
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "totals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MoneyTotal"
            }
          }
        }
      },
      "ProjectPage": {
        "type": "object",
        "required": [
          "items",
          "nextCursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Project"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "githubRefreshRequired": {
            "type": "boolean",
            "description": "One or more linked projects require the actual actor's separate GitHub credential refresh"
          }
        }
      },
      "CategoryInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 32
          }
        }
      },
      "Category": {
        "type": "object",
        "required": [
          "id",
          "name",
          "revision",
          "archivedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "color": {
            "type": [
              "string",
              "null"
            ]
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "archivedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "removedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Present only for a removed row requested with includeRemoved=true"
          }
        }
      },
      "CurrencyCode": {
        "type": "string",
        "enum": [
          "AED",
          "AFN",
          "ALL",
          "AMD",
          "ANG",
          "AOA",
          "ARS",
          "AUD",
          "AWG",
          "AZN",
          "BAM",
          "BBD",
          "BDT",
          "BGN",
          "BHD",
          "BIF",
          "BMD",
          "BND",
          "BOB",
          "BOV",
          "BRL",
          "BSD",
          "BTN",
          "BWP",
          "BYN",
          "BZD",
          "CAD",
          "CDF",
          "CHE",
          "CHF",
          "CHW",
          "CLF",
          "CLP",
          "CNY",
          "COP",
          "COU",
          "CRC",
          "CUC",
          "CUP",
          "CVE",
          "CZK",
          "DJF",
          "DKK",
          "DOP",
          "DZD",
          "EGP",
          "ERN",
          "ETB",
          "EUR",
          "FJD",
          "FKP",
          "GBP",
          "GEL",
          "GHS",
          "GIP",
          "GMD",
          "GNF",
          "GTQ",
          "GYD",
          "HKD",
          "HNL",
          "HRK",
          "HTG",
          "HUF",
          "IDR",
          "ILS",
          "INR",
          "IQD",
          "IRR",
          "ISK",
          "JMD",
          "JOD",
          "JPY",
          "KES",
          "KGS",
          "KHR",
          "KMF",
          "KPW",
          "KRW",
          "KWD",
          "KYD",
          "KZT",
          "LAK",
          "LBP",
          "LKR",
          "LRD",
          "LSL",
          "LYD",
          "MAD",
          "MDL",
          "MGA",
          "MKD",
          "MMK",
          "MNT",
          "MOP",
          "MRU",
          "MUR",
          "MVR",
          "MWK",
          "MXN",
          "MXV",
          "MYR",
          "MZN",
          "NAD",
          "NGN",
          "NIO",
          "NOK",
          "NPR",
          "NZD",
          "OMR",
          "PAB",
          "PEN",
          "PGK",
          "PHP",
          "PKR",
          "PLN",
          "PYG",
          "QAR",
          "RON",
          "RSD",
          "RUB",
          "RWF",
          "SAR",
          "SBD",
          "SCR",
          "SDG",
          "SEK",
          "SGD",
          "SHP",
          "SLE",
          "SLL",
          "SOS",
          "SRD",
          "SSP",
          "STN",
          "SVC",
          "SYP",
          "SZL",
          "THB",
          "TJS",
          "TMT",
          "TND",
          "TOP",
          "TRY",
          "TTD",
          "TWD",
          "TZS",
          "UAH",
          "UGX",
          "USD",
          "USN",
          "UYI",
          "UYU",
          "UYW",
          "UZS",
          "VED",
          "VES",
          "VND",
          "VUV",
          "WST",
          "YER",
          "ZAR",
          "ZMW",
          "ZWL"
        ],
        "description": "Supported uppercase currencies. Writes use decimal strings and fixed currency exponents; JPY has zero fractional digits, USD has two, KWD has three, and CLF has four. Amount minor units must not exceed 9007199254740991. Values across currencies are never combined or converted."
      },
      "ExpenseFields": {
        "type": "object",
        "required": [
          "target",
          "occurredOn",
          "amount",
          "currency",
          "purpose"
        ],
        "properties": {
          "target": {
            "$ref": "#/components/schemas/Target"
          },
          "occurredOn": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$",
            "description": "Currency exponent and safe integer bound enforced by server"
          },
          "currency": {
            "$ref": "#/components/schemas/CurrencyCode"
          },
          "categoryId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Required for a Free ledger. Omit on create or edit when the ledger owner's Pro or Max plan and assistance gates permit automatic classification; a confident existing active category is selected. Unavailable or uncertain inference returns CATEGORY_REQUIRED. An explicit nonempty value is preserved, including the previous archived category on edit."
          },
          "purpose": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000
          },
          "quantity": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40,
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"
          },
          "unit": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          }
        }
      },
      "ExpenseInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ExpenseFields"
          }
        ],
        "unevaluatedProperties": false
      },
      "RecurringExpenseSchedule": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "frequency",
          "timezone",
          "startOn"
        ],
        "description": "Calendar in a validated IANA timezone. Weekly weekday is ISO Monday=1\nthrough Sunday=7. Quarterly quarterMonth is 1, 2 or 3 within each\ncalendar quarter. Days beyond a month's length use its final day;\nFebruary 29 therefore becomes February 28 in a nonleap year.\nThe occurrence becomes due at local midnight or the first valid\ninstant after a timezone gap. Start and optional end dates are\ninclusive. On creation, startOn on or before today in this timezone\nrecords exactly one initial expense on startOn; a future start waits for\nthe exact startOn date even when its frequency selector differs.\nIntervening historical periods are not backfilled on creation. Each\nfuture due period creates its own expense; delayed dispatch catches up\nunder a bounded hourly tick without charging a card or polling the client.\n",
        "properties": {
          "frequency": {
            "type": "string",
            "enum": [
              "weekly",
              "monthly",
              "quarterly",
              "yearly"
            ]
          },
          "timezone": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Valid IANA zone available to the runtime, for example Asia/Shanghai or UTC"
          },
          "startOn": {
            "type": "string",
            "format": "date",
            "description": "On or before local today records one initial expense dated startOn; a future date waits for scheduled posting"
          },
          "endOn": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Inclusive last eligible business date; must be on or after startOn"
          },
          "weekday": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7
          },
          "day": {
            "type": "integer",
            "minimum": 1,
            "maximum": 31
          },
          "quarterMonth": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3
          },
          "month": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "frequency": {
                  "const": "weekly"
                }
              }
            },
            "then": {
              "required": [
                "weekday"
              ],
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "day"
                    ]
                  },
                  {
                    "required": [
                      "quarterMonth"
                    ]
                  },
                  {
                    "required": [
                      "month"
                    ]
                  }
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "frequency": {
                  "const": "monthly"
                }
              }
            },
            "then": {
              "required": [
                "day"
              ],
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "weekday"
                    ]
                  },
                  {
                    "required": [
                      "quarterMonth"
                    ]
                  },
                  {
                    "required": [
                      "month"
                    ]
                  }
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "frequency": {
                  "const": "quarterly"
                }
              }
            },
            "then": {
              "required": [
                "day",
                "quarterMonth"
              ],
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "weekday"
                    ]
                  },
                  {
                    "required": [
                      "month"
                    ]
                  }
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "frequency": {
                  "const": "yearly"
                }
              }
            },
            "then": {
              "required": [
                "day",
                "month"
              ],
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "weekday"
                    ]
                  },
                  {
                    "required": [
                      "quarterMonth"
                    ]
                  }
                ]
              }
            }
          }
        ]
      },
      "RecurringExpenseFields": {
        "type": "object",
        "required": [
          "target",
          "amount",
          "currency",
          "purpose",
          "schedule"
        ],
        "properties": {
          "target": {
            "$ref": "#/components/schemas/Target"
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$",
            "description": "Same currency-exponent and integer bounds as an ordinary expense"
          },
          "currency": {
            "$ref": "#/components/schemas/CurrencyCode"
          },
          "categoryId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Required when Jev is unavailable or calls are exhausted. Omit on create or complete edit for gated automatic classification, like ordinary expenses. Only a confident existing active category is saved; an explicit category is never changed. CATEGORY_REQUIRED preserves the draft. Background execution uses the saved category without model calls."
          },
          "purpose": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000
          },
          "quantity": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40,
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"
          },
          "unit": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "schedule": {
            "$ref": "#/components/schemas/RecurringExpenseSchedule"
          }
        }
      },
      "RecurringExpenseInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RecurringExpenseFields"
          }
        ],
        "unevaluatedProperties": false
      },
      "RecurringExpenseRetryInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "retryPeriodKey"
        ],
        "properties": {
          "retryPeriodKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40,
            "description": "Exact periodKey from a retained pendingOccurrences item",
            "examples": [
              "M2026-09"
            ]
          }
        }
      },
      "RecurringExpensePendingOccurrence": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "periodKey",
          "scheduledOn",
          "amount",
          "currency",
          "purpose",
          "categoryId",
          "blockedCode",
          "createdAt"
        ],
        "description": "Frozen historical values from a capacity failure. Editing the rule affects future expenses and never changes these retained values. At most ten unresolved occurrences are retained per rule; later failures are discarded until space is available.",
        "properties": {
          "periodKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "scheduledOn": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"
          },
          "currency": {
            "$ref": "#/components/schemas/CurrencyCode"
          },
          "purpose": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "categoryId": {
            "type": "string",
            "minLength": 1
          },
          "blockedCode": {
            "type": "string",
            "enum": [
              "RECORD_LIMIT",
              "RETENTION_CLEANUP_REQUIRED",
              "RETENTION_TARGET_FORBIDDEN"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RecurringExpenseRule": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RecurringExpenseFields"
          },
          {
            "type": "object",
            "required": [
              "id",
              "categoryId",
              "status",
              "revision",
              "nextOccurrenceOn",
              "nextRunAt",
              "blockedCode",
              "pendingOccurrences",
              "awaitingSync",
              "createdAt",
              "updatedAt"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "categoryId": {
                "type": "string",
                "minLength": 1,
                "description": "Saved active category selected explicitly or confidently by Jev at create or complete edit"
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "paused",
                  "blocked",
                  "completed",
                  "canceled"
                ]
              },
              "revision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              "nextOccurrenceOn": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date",
                "description": "Future business date strictly after today in the schedule timezone, or null when none remains. Historical capacity failures are separate pendingOccurrences."
              },
              "nextRunAt": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 9007199254740991,
                "description": "UTC epoch seconds for the same future occurrence as nextOccurrenceOn; both values are projected together when awaitingSync is true"
              },
              "blockedCode": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 80,
                "description": "Current authorization, target, category or plan stop reason; blocked rules do not keep executing automatically"
              },
              "pendingOccurrences": {
                "type": "array",
                "maxItems": 10,
                "items": {
                  "$ref": "#/components/schemas/RecurringExpensePendingOccurrence"
                }
              },
              "awaitingSync": {
                "type": "boolean",
                "description": "An active rule's stored due pointer awaits scheduled synchronization; GET only projects future dates and never creates expenses or repairs state."
              },
              "assistance": {
                "$ref": "#/components/schemas/ExpenseAssistance"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "RecurringExpensePage": {
        "type": "object",
        "required": [
          "items",
          "nextCursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/RecurringExpenseRule"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RecurringExpenseNotification": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "ruleId",
          "periodKey",
          "scheduledOn",
          "workspaceId",
          "workspaceName",
          "target",
          "amount",
          "currency",
          "failedCode",
          "createdAt",
          "purpose"
        ],
        "description": "Actionable retained failure for the current saved recipient; target and expense values are frozen at the failed occurrence.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Rule ID and period key joined by a colon"
          },
          "ruleId": {
            "type": "string"
          },
          "periodKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "scheduledOn": {
            "type": "string",
            "format": "date"
          },
          "workspaceId": {
            "type": "string"
          },
          "workspaceName": {
            "type": "string"
          },
          "target": {
            "$ref": "#/components/schemas/Target"
          },
          "amount": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"
          },
          "currency": {
            "$ref": "#/components/schemas/CurrencyCode"
          },
          "failedCode": {
            "type": "string",
            "enum": [
              "RECORD_LIMIT",
              "RETENTION_CLEANUP_REQUIRED",
              "RETENTION_TARGET_FORBIDDEN"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "purpose": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        }
      },
      "RecurringExpenseNotificationPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "hasMore"
        ],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/RecurringExpenseNotification"
            }
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      },
      "ExpensePatchInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ExpenseInput"
          }
        ]
      },
      "ExpenseReview": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expenseId",
          "revision",
          "questionVersion",
          "modelVersion",
          "checks"
        ],
        "properties": {
          "expenseId": {
            "type": "string"
          },
          "revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "questionVersion": {
            "type": "string",
            "const": "ledger-suggest-v2"
          },
          "modelVersion": {
            "type": [
              "string",
              "null"
            ]
          },
          "suggestionId": {
            "type": "string",
            "description": "Existing suggestion event when a model attempt was admitted; no saved-expense mutation"
          },
          "checks": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "category",
              "target",
              "duplicate"
            ],
            "properties": {
              "category": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status",
                  "current"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "checked",
                      "issue",
                      "uncertain",
                      "unavailable"
                    ]
                  },
                  "current": {
                    "type": "string",
                    "description": "Saved category ID, including historical archived categories"
                  },
                  "suggested": {
                    "type": "string",
                    "description": "Confident currently active category; never automatically assigned"
                  },
                  "confidence": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Validated choice confidence; uncertainty never establishes correctness"
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "disabled",
                      "provider_unavailable",
                      "invalid_context",
                      "no_categories"
                    ]
                  }
                }
              },
              "target": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status",
                  "current"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "checked",
                      "issue",
                      "uncertain",
                      "unavailable"
                    ]
                  },
                  "current": {
                    "$ref": "#/components/schemas/Target"
                  },
                  "suggested": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "kind"
                    ],
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "project",
                          "shared"
                        ],
                        "description": "Scope-kind advice only; no destination project or automatic move"
                      }
                    }
                  },
                  "confidence": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "disabled",
                      "provider_unavailable",
                      "invalid_context"
                    ]
                  }
                }
              },
              "duplicate": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "checked",
                      "issue"
                    ],
                    "description": "Bounded local same-target rule, independent of provider availability"
                  },
                  "candidate": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "id",
                      "revision"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "revision": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 9007199254740991
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ExpenseAssistance": {
        "type": "object",
        "required": [
          "status",
          "suggestions",
          "categorySource"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "available",
              "uncertain",
              "unavailable"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Provider configuration or Jev call exhaustion fallback code; advisory only"
          },
          "categorySource": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "user",
              "jev",
              null
            ]
          },
          "suggestionId": {
            "type": "string"
          },
          "questionVersion": {
            "type": "string"
          },
          "modelVersion": {
            "type": [
              "string",
              "null"
            ]
          },
          "suggestions": {
            "type": "object",
            "properties": {
              "categoryId": {
                "type": "string",
                "description": "Confident existing active category; assigned on create or edit when caller omits categoryId"
              },
              "targetKind": {
                "type": "string",
                "enum": [
                  "project",
                  "shared"
                ],
                "description": "Advice only; never moves an expense"
              },
              "duplicateExpenseId": {
                "type": "string",
                "description": "Matching active expense on the same authorized target, expense date, currency and integer minor-unit amount, excluding the expense being edited; purpose text need not match; advisory only"
              }
            }
          },
          "probabilities": {
            "type": "object"
          }
        }
      },
      "Expense": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ExpenseFields"
          },
          {
            "type": "object",
            "required": [
              "id",
              "categoryId",
              "amountMinor",
              "revision",
              "createdAt",
              "updatedAt"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "categoryId": {
                "type": "string",
                "minLength": 1
              },
              "amountMinor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "revision": {
                "type": "integer",
                "minimum": 1
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "lastSource": {
                "$ref": "#/components/schemas/ExpenseLastSource"
              },
              "assistance": {
                "$ref": "#/components/schemas/ExpenseAssistance"
              }
            }
          }
        ]
      },
      "ExpenseLastSource": {
        "type": [
          "object",
          "null"
        ],
        "readOnly": true,
        "description": "Last successful creation or edit, atomically replaced with the expense. Owner/member refers to the actual writer at save time. Recurring creation includes immediate, background and explicit pending-occurrence generation. Older records return null until their next successful edit; failed writes and creation replays leave the saved source unchanged. Only public display identity is exposed, never private email or credential identifiers.",
        "additionalProperties": false,
        "required": [
          "kind",
          "action",
          "userId",
          "name",
          "githubLogin",
          "via"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "owner",
              "member",
              "recurring"
            ]
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update"
            ]
          },
          "userId": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "githubLogin": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 39
          },
          "via": {
            "type": "string",
            "enum": [
              "web",
              "api_key",
              "schedule"
            ]
          }
        }
      },
      "ExpensePage": {
        "type": "object",
        "required": [
          "items",
          "nextCursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Expense"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ActivityActor": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "userId",
          "name",
          "githubLogin"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "user",
              "api_key",
              "system"
            ]
          },
          "userId": {
            "type": "string",
            "maxLength": 120
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "githubLogin": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 39
          }
        }
      },
      "ActivityChange": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "field",
          "before",
          "after"
        ],
        "properties": {
          "field": {
            "type": "string",
            "enum": [
              "target",
              "purpose",
              "amount",
              "currency",
              "occurredOn",
              "categoryId",
              "note",
              "quantity",
              "unit",
              "name",
              "description",
              "developmentUrl",
              "productUrl",
              "adminConsoleUrl",
              "status",
              "githubRepoIds",
              "githubOrganizationId",
              "schedule"
            ]
          },
          "before": {
            "$ref": "#/components/schemas/ActivityValue"
          },
          "after": {
            "$ref": "#/components/schemas/ActivityValue"
          }
        }
      },
      "ActivityValue": {
        "description": "A bounded safe JSON value. Amount values are exact decimal/currency\nobjects such as {amount: \"12.30\", currency: \"USD\"}; they never expose raw\nminor units as display amounts. Category values are {id, name}; target\nvalues are {kind, projectId?, projectName?}, or {kind: restricted} for\nthe opposite side of a move outside an API key's permission. Schedule\nvalues contain the saved calendar schedule. Other fields contain their\noriginal string, safe integer, bounded array or null. Removed/created\nvalues use null for the absent side.\n",
        "type": [
          "string",
          "number",
          "boolean",
          "object",
          "array",
          "null"
        ]
      },
      "ActivityEvent": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "operationId",
          "createdAt",
          "actor",
          "resource",
          "action",
          "target",
          "changes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 120
          },
          "operationId": {
            "type": "string",
            "maxLength": 160,
            "description": "Shared across the two activity rows of a cross-pool move"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "actor": {
            "$ref": "#/components/schemas/ActivityActor"
          },
          "resource": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "id",
              "label"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "expense",
                  "project",
                  "recurring_rule"
                ]
              },
              "id": {
                "type": "string",
                "maxLength": 160
              },
              "label": {
                "type": "string",
                "maxLength": 500,
                "description": "Saved purpose or financial project name; falls back to record ID and never to a protected GitHub repository name"
              }
            }
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "delete",
              "archive",
              "restore",
              "pause",
              "resume",
              "cancel",
              "move",
              "generate"
            ]
          },
          "target": {
            "$ref": "#/components/schemas/Target"
          },
          "changes": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/ActivityChange"
            }
          }
        }
      },
      "ActivityPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "nextCursor",
          "windowStart",
          "windowEnd"
        ],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ActivityEvent"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 256
          },
          "windowStart": {
            "type": "string",
            "format": "date-time",
            "description": "Exclusive Server-clock 24-hour floor, refreshed on every page"
          },
          "windowEnd": {
            "type": "string",
            "format": "date-time",
            "description": "Inclusive upper window boundary anchored by the first page"
          }
        }
      },
      "MoneyTotal": {
        "type": "object",
        "required": [
          "currency",
          "amountMinor"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "amountMinor": {
            "$ref": "#/components/schemas/AggregateMinor"
          }
        }
      },
      "AggregateMinor": {
        "description": "Exact total in minor currency units. Totals above the JSON safe integer bound use a decimal integer string; clients must not convert those strings to floating point.",
        "oneOf": [
          {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          {
            "type": "string",
            "pattern": "^[0-9]+$"
          }
        ]
      },
      "ProjectPeriodReport": {
        "type": "object",
        "required": [
          "project",
          "period",
          "totals",
          "items",
          "nextCursor"
        ],
        "properties": {
          "project": {
            "type": "object",
            "required": [
              "id",
              "name",
              "status"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "archived"
                ]
              }
            }
          },
          "period": {
            "type": "object",
            "required": [
              "granularity",
              "year",
              "startOn",
              "endOn"
            ],
            "description": "Inclusive business-date bounds. Expense dates have no time or zone, so no timezone conversion applies.",
            "properties": {
              "granularity": {
                "type": "string",
                "enum": [
                  "month",
                  "quarter",
                  "year"
                ]
              },
              "year": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9999
              },
              "month": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12
              },
              "quarter": {
                "type": "integer",
                "minimum": 1,
                "maximum": 4
              },
              "startOn": {
                "type": "string",
                "format": "date"
              },
              "endOn": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "totals": {
            "type": "array",
            "description": "One entry per currency present in the period, sorted by currency code. Amounts in different currencies are never combined.",
            "items": {
              "type": "object",
              "required": [
                "currency",
                "amount",
                "amountMinor",
                "expenseCount"
              ],
              "properties": {
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "amount": {
                  "type": "string",
                  "description": "Exact decimal total in the currency's standard exponent"
                },
                "amountMinor": {
                  "$ref": "#/components/schemas/AggregateMinor"
                },
                "expenseCount": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Expense"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Report": {
        "type": "object",
        "required": [
          "groups"
        ],
        "properties": {
          "groups": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "currency",
                "amountMinor"
              ],
              "properties": {
                "target": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "project",
                    "shared",
                    "account",
                    null
                  ]
                },
                "projectId": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "categoryId": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "bucket": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "currency": {
                  "type": "string"
                },
                "amountMinor": {
                  "$ref": "#/components/schemas/AggregateMinor"
                }
              }
            }
          }
        }
      }
    }
  },
  "x-norulo-source-sha256": "9b25e15942f0867a7baa7a9a1c95bb0ce64398f56aa07d1180369be94abaa47f"
}
