{
  "openapi": "3.0.3",
  "info": {
    "title": "Cherry API",
    "version": "1.0.0",
    "description": "Cherry's public developer API — programmatic access to a business's books as Cherry keeps them: bank transactions with their categorizations, the chart of accounts, the double-entry journal, financial statements, legal entities, the tax-obligation calendar, the fiscal health score, and company incorporations (formation, EIN, and state filings).\n\nAuthenticate every request with an API key: `Authorization: Bearer ck_live_…`. Keys are created in the Cherry app and are scoped to one business (tenant) — there is no tenant id in any URL. Keys carry a `read` and/or `write` scope; every GET needs `read`, mutations need `write`.\n\nOAuth 2.0 (client_credentials) is the alternative for integrations that prefer short-lived credentials. Register an OAuth client in Cherry to get a `ck_client_…` id and a `ck_secret_…` secret (shown once), then exchange them at `POST /oauth/token` (HTTP Basic or `client_id`/`client_secret` form params, `grant_type=client_credentials`, optional space-delimited `scope`). The response's opaque `ck_oat_…` access token (1-hour TTL) is sent exactly like an API key — `Authorization: Bearer ck_oat_…` — and works on every endpoint here with the same scope rules. Revoke tokens at `POST /oauth/revoke` (RFC 7009); server metadata lives at `/.well-known/oauth-authorization-server` (RFC 8414). Note both OAuth endpoints sit at the server root, not under /v1.\n\nConventions: successful responses wrap the payload in `{ \"data\": … }`; list endpoints add `{ \"meta\": { \"pagination\": { limit, offset, nextOffset } } }` — pass `nextOffset` back as `offset` until it is null. Errors are `{ \"error\": string, \"reason\"?: string }` with conventional status codes. Dates are `YYYY-MM-DD`; money amounts are numbers in the row's currency. Requests are rate-limited per key with token buckets (429 + `Retry-After` when exhausted); report generation has a smaller budget than plain reads."
  },
  "servers": [
    {
      "url": "https://api.trycherry.ai/v1"
    }
  ],
  "tags": [
    {
      "name": "Transactions",
      "description": "Bank feed rows and their categorizations."
    },
    {
      "name": "Accounts",
      "description": "The tenant's chart of accounts."
    },
    {
      "name": "Bank accounts",
      "description": "Connected bank accounts — Plaid-linked and manual. Manual institutions are how developers without a Plaid connection bring their own accounts and transactions."
    },
    {
      "name": "Bank statements",
      "description": "Statement uploads — send a statement PDF/image and Cherry transcribes it, verifies the balances reconcile, and lands the transactions on a manual bank account. The no-export alternative to pushing rows yourself."
    },
    {
      "name": "Journal",
      "description": "The double-entry journal (entries and lines)."
    },
    {
      "name": "Reports",
      "description": "Trial balance and financial statements."
    },
    {
      "name": "Entities",
      "description": "Legal entities behind the tenant."
    },
    {
      "name": "Obligations",
      "description": "The tax/compliance calendar Cherry tracks."
    },
    {
      "name": "Health",
      "description": "Cherry's composite fiscal readiness score."
    },
    {
      "name": "Incorporations",
      "description": "Company formation, EIN orders, and the state filings that follow — start a formation and track every filing to completion."
    },
    {
      "name": "Meta",
      "description": "The API's own machine-readable contract."
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ck_live_…",
        "description": "Cherry API key, created in the app. Sent as `Authorization: Bearer ck_live_…`. OAuth access tokens (`ck_oat_…`) are accepted in exactly the same header."
      },
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 client_credentials grant. Register a client in Cherry, then exchange `ck_client_…` + `ck_secret_…` for a 1-hour opaque `ck_oat_…` bearer token. Discovery: `/.well-known/oauth-authorization-server`.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://api.trycherry.ai/oauth/token",
            "scopes": {
              "read": "Read the tenant's books, entities, obligations, and reports.",
              "write": "Push transactions, upload statements, and drive mutations."
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Stable machine-readable error code."
          },
          "reason": {
            "type": "string",
            "description": "Human-readable explanation."
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "nextOffset": {
            "type": "integer",
            "nullable": true,
            "description": "Offset for the next page, or null when this page was the last."
          }
        }
      },
      "TransactionCategory": {
        "type": "object",
        "description": "Where the transaction was filed in the books, and who decided: `source` is the categorization tier (regex/directory/memory/rag/llm/user_override) and `confidence` is that tier's certainty (1.0 for a human decision).",
        "properties": {
          "accountNumber": {
            "type": "string",
            "description": "Ledger account number."
          },
          "accountName": {
            "type": "string",
            "nullable": true
          },
          "confidence": {
            "type": "number",
            "nullable": true,
            "minimum": 0,
            "maximum": 1
          },
          "source": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "Transaction": {
        "type": "object",
        "description": "One bank transaction. Amounts keep the bank-feed sign convention (positive = money OUT), surfaced explicitly as `direction`.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable public transaction id."
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "authorizedDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "description": "Positive = money out, negative = money in."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217, e.g. USD."
          },
          "direction": {
            "type": "string",
            "enum": [
              "in",
              "out"
            ]
          },
          "description": {
            "type": "string",
            "description": "Bank descriptor."
          },
          "merchant": {
            "type": "string",
            "nullable": true
          },
          "pending": {
            "type": "boolean"
          },
          "transactionType": {
            "type": "string",
            "nullable": true,
            "enum": [
              "expense",
              "income",
              "transfer",
              null
            ]
          },
          "category": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TransactionCategory"
              }
            ],
            "nullable": true,
            "description": "Null while the row is uncategorized (or is a transfer)."
          },
          "needsReview": {
            "type": "boolean",
            "description": "True when a human still owes a decision: uncategorized, parked on the uncategorized catch-all account, or categorized below the confidence threshold."
          }
        }
      },
      "BankAccount": {
        "type": "object",
        "description": "One connected bank account — Plaid-linked or manually created. Manual accounts carry a declared opening balance; `derivedBalance` rolls it forward through every settled transaction and is the figure to trust.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Cherry's internal bank-account id."
          },
          "externalAccountId": {
            "type": "string",
            "description": "For manual accounts, 'manual:<institution>:<external-id>'; for Plaid accounts, Plaid's opaque account id."
          },
          "institutionName": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217, e.g. USD."
          },
          "kind": {
            "type": "string",
            "nullable": true,
            "description": "Account subtype, e.g. checking, savings, credit_card."
          },
          "type": {
            "type": "string",
            "nullable": true,
            "description": "Account type, e.g. depository, credit."
          },
          "openingBalance": {
            "type": "number",
            "nullable": true,
            "description": "Declared balance as of openingBalanceDate (manual accounts)."
          },
          "openingBalanceDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "derivedBalance": {
            "type": "number",
            "nullable": true,
            "description": "openingBalance rolled forward through settled transactions — what the account holds today. Null when no opening balance was declared."
          },
          "currentBalance": {
            "type": "number",
            "nullable": true,
            "description": "Last provider-reported balance (Plaid accounts)."
          },
          "ledgerMapped": {
            "type": "boolean",
            "description": "Whether the account is mapped to a ledger account. Transactions on unmapped accounts are not booked to the General Ledger until mapped."
          },
          "ledgerAccountNumber": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "BankStatement": {
        "type": "object",
        "description": "One ingested statement period — the provenance record behind the transactions a statement upload produced. `continuityOk` is null until a neighbouring period exists to compare against.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "documentId": {
            "type": "string",
            "format": "uuid",
            "description": "The uploaded document this period was ingested from."
          },
          "bankAccountId": {
            "type": "string",
            "format": "uuid",
            "description": "Cherry's internal bank-account id (see GET /bank-accounts)."
          },
          "periodStart": {
            "type": "string",
            "format": "date"
          },
          "periodEnd": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217, read off the statement — never defaulted."
          },
          "openingBalance": {
            "type": "number"
          },
          "closingBalance": {
            "type": "number"
          },
          "transactionCount": {
            "type": "integer",
            "description": "Transaction lines the statement carried."
          },
          "continuityOk": {
            "type": "boolean",
            "nullable": true,
            "description": "Whether this period's opening balance joins the previous statement's closing balance. Null when there is no earlier statement to compare against. A false value raises a conflict but does not block ingestion."
          },
          "createdAt": {
            "type": "string"
          }
        }
      },
      "LedgerAccount": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "entityId": {
            "type": "string",
            "format": "uuid"
          },
          "accountNumber": {
            "type": "string",
            "description": "e.g. 5010."
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "asset",
              "liability",
              "equity",
              "revenue",
              "expense"
            ]
          },
          "country": {
            "type": "string",
            "enum": [
              "US",
              "MX"
            ]
          },
          "isActive": {
            "type": "boolean"
          }
        }
      },
      "JournalLine": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "format": "uuid",
            "description": "Ledger account id — join against GET /accounts."
          },
          "debit": {
            "type": "number",
            "nullable": true
          },
          "credit": {
            "type": "number",
            "nullable": true
          },
          "currency": {
            "type": "string"
          },
          "memo": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "JournalEntry": {
        "type": "object",
        "description": "One balanced double-entry posting. Lines debit and credit ledger accounts; debits equal credits within every entry.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "entityId": {
            "type": "string",
            "format": "uuid"
          },
          "entryDate": {
            "type": "string",
            "format": "date"
          },
          "description": {
            "type": "string"
          },
          "sourceType": {
            "type": "string",
            "description": "What produced the entry (bank feed, invoice, manual, …)."
          },
          "postedAt": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JournalLine"
            }
          }
        }
      },
      "TrialBalanceRow": {
        "type": "object",
        "properties": {
          "accountNumber": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "isActive": {
            "type": "boolean"
          },
          "debit": {
            "type": "number",
            "description": "Cumulative debits through asOf."
          },
          "credit": {
            "type": "number",
            "description": "Cumulative credits through asOf."
          },
          "balance": {
            "type": "number",
            "description": "Natural-direction balance: debit-minus-credit for assets/expenses, credit-minus-debit otherwise."
          }
        }
      },
      "TrialBalance": {
        "type": "object",
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date"
          },
          "entityId": {
            "type": "string",
            "format": "uuid"
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrialBalanceRow"
            }
          }
        }
      },
      "Entity": {
        "type": "object",
        "description": "A legal entity. Tax ids are always masked to their last 4 characters.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "country": {
            "type": "string",
            "enum": [
              "US",
              "MX"
            ]
          },
          "legalName": {
            "type": "string"
          },
          "taxIdMasked": {
            "type": "string",
            "nullable": true,
            "description": "e.g. `*****6789`."
          },
          "taxIdType": {
            "type": "string",
            "description": "EIN, RFC, SSN, ITIN, or NIT."
          },
          "entityType": {
            "type": "string",
            "nullable": true,
            "description": "e.g. llc, c_corp."
          },
          "regime": {
            "type": "string",
            "nullable": true,
            "description": "Mexican tax regime, when applicable."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "closed",
              "merged"
            ]
          },
          "isPrimary": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          }
        }
      },
      "Obligation": {
        "type": "object",
        "description": "One filing/payment obligation Cherry is tracking.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "entityId": {
            "type": "string",
            "format": "uuid"
          },
          "country": {
            "type": "string",
            "enum": [
              "US",
              "MX"
            ]
          },
          "type": {
            "type": "string",
            "description": "Obligation kind, e.g. federal_income_tax."
          },
          "period": {
            "type": "string",
            "description": "The period it covers, e.g. 2026-Q2."
          },
          "frequency": {
            "type": "string",
            "enum": [
              "monthly",
              "quarterly",
              "annual",
              "one_time"
            ]
          },
          "deadline": {
            "type": "string",
            "format": "date"
          },
          "status": {
            "type": "string",
            "enum": [
              "upcoming",
              "payment_pending",
              "confirmed",
              "filed"
            ]
          },
          "amountDue": {
            "type": "number",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "filedAt": {
            "type": "string",
            "nullable": true
          },
          "jurisdictionLevel": {
            "type": "string",
            "nullable": true,
            "enum": [
              "federal",
              "state",
              "city",
              null
            ]
          },
          "stateCode": {
            "type": "string",
            "nullable": true
          },
          "authority": {
            "type": "string",
            "nullable": true,
            "description": "e.g. IRS, SAT."
          },
          "formReference": {
            "type": "string",
            "nullable": true,
            "description": "e.g. Form 1120."
          }
        }
      },
      "HealthScore": {
        "type": "object",
        "description": "Composite fiscal readiness: profile completeness, obligation hygiene, and document-detector findings blended into one 0-100 score.",
        "properties": {
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "grade": {
            "type": "string",
            "description": "Letter grade for the score."
          },
          "summary": {
            "type": "string"
          },
          "components": {
            "type": "array",
            "description": "Per-area breakdown with the issues that cost points.",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "IncorporationOrderItem": {
        "type": "object",
        "description": "One order line inside an incorporation bundle.",
        "properties": {
          "orderId": {
            "type": "string",
            "description": "Stable order id."
          },
          "orderType": {
            "type": "string",
            "description": "formation, registered_agent, ein, annual_report, foreign_qualification."
          },
          "filingStatus": {
            "type": "string",
            "enum": [
              "submitted",
              "pending",
              "filed",
              "exception",
              "cancelled"
            ]
          },
          "filingDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          }
        }
      },
      "PendingIncorporation": {
        "type": "object",
        "description": "A company being formed, grouped with its order lines. It has no legal-entity record yet; once the formation files, its orders appear under /filings instead.",
        "properties": {
          "companyId": {
            "type": "string",
            "description": "Cherry's id for the company being formed."
          },
          "legalName": {
            "type": "string",
            "nullable": true
          },
          "entityType": {
            "type": "string",
            "nullable": true,
            "enum": [
              "LLC",
              "CORP",
              null
            ]
          },
          "filingState": {
            "type": "string",
            "nullable": true,
            "description": "US state being formed in."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IncorporationOrderItem"
            }
          }
        }
      },
      "Filing": {
        "type": "object",
        "description": "One filing order linked to a legal entity — the formation itself once filed, registered-agent service, annual reports, EIN. Exception fields are populated only when filingStatus is 'exception'.",
        "properties": {
          "orderId": {
            "type": "string"
          },
          "orderType": {
            "type": "string"
          },
          "entityId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "filingState": {
            "type": "string",
            "nullable": true
          },
          "filingStatus": {
            "type": "string",
            "enum": [
              "submitted",
              "pending",
              "filed",
              "exception",
              "cancelled"
            ]
          },
          "subscriptionStatus": {
            "type": "string",
            "nullable": true,
            "enum": [
              "active",
              "canceled",
              "past_due",
              null
            ],
            "description": "For recurring services (registered agent, annual report)."
          },
          "filingDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "exceptionCode": {
            "type": "string",
            "nullable": true
          },
          "exceptionReason": {
            "type": "string",
            "nullable": true
          },
          "exceptionMessage": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EinApplication": {
        "type": "object",
        "description": "An EIN application Cherry files itself, on paper, for a responsible party with no US SSN or ITIN. Created by POST /incorporations when `einNoSsn` is set. No tax identifier for the responsible party is ever stored on this record — that absence is the reason the record exists.",
        "properties": {
          "waiting": {
            "type": "object",
            "description": "The answer to the only question a founder has once the SS-4 is faxed: is the EIN coming? DERIVED from filedAt against the clock on every read, not stored — the IRS sends no rejection notice, so `status` alone cannot tell an application filed twelve weeks ago from one filed yesterday.",
            "properties": {
              "stage": {
                "type": "string",
                "enum": [
                  "not_filed",
                  "expected",
                  "taking_longer",
                  "likely_rejected",
                  "settled"
                ],
                "description": "not_filed (not yet sent to the IRS), expected (sent, still inside the normal window), taking_longer (past the point it should have arrived; Cherry is chasing it as third-party designee), likely_rejected (far enough past that a rejection nobody was told about is the reading), settled (the EIN arrived, or the application was cancelled)."
              },
              "daysSinceFiled": {
                "type": "integer",
                "nullable": true,
                "description": "Whole days since the SS-4 went to the IRS. Null before it was sent."
              },
              "normalWindowDays": {
                "type": "object",
                "description": "The turnaround window Cherry quotes, so the wait reads against it.",
                "properties": {
                  "min": {
                    "type": "integer"
                  },
                  "max": {
                    "type": "integer"
                  }
                }
              },
              "message": {
                "type": "string",
                "description": "Plain-language status. Always present, always safe to show verbatim."
              }
            }
          },
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "entityId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Null until the formation files and a legal entity exists. Cherry links it automatically; the issued EIN then propagates onto that entity."
          },
          "legalName": {
            "type": "string"
          },
          "entityType": {
            "type": "string",
            "enum": [
              "LLC",
              "CORP"
            ]
          },
          "filingState": {
            "type": "string",
            "description": "US state the company was formed in."
          },
          "status": {
            "type": "string",
            "enum": [
              "ready_to_file",
              "awaiting_signature",
              "signed",
              "filed",
              "ein_received",
              "cancelled"
            ],
            "description": "Lifecycle: ready_to_file -> awaiting_signature -> signed -> filed -> ein_received. `ready_to_file -> filed` is also legal, for an operator who prepares and sends the form without e-signature. `cancelled` is terminal."
          },
          "ein": {
            "type": "string",
            "nullable": true,
            "description": "Nine digits, no dash. Present once the IRS has issued it."
          },
          "ss4DocumentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "signatureEnvelopeId": {
            "type": "string",
            "nullable": true
          },
          "signedDocumentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "filedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "signatureRequestedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "signedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    },
    {
      "oauth2": []
    }
  ],
  "paths": {
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "tags": [
          "Meta"
        ],
        "summary": "Get the OpenAPI spec",
        "description": "The machine-readable contract for the whole /v1 surface. The only unauthenticated endpoint — it discloses the API's shape, never data.",
        "security": [],
        "responses": {
          "200": {
            "description": "The OpenAPI 3.0 document"
          }
        }
      }
    },
    "/transactions": {
      "get": {
        "operationId": "listTransactions",
        "tags": [
          "Transactions"
        ],
        "summary": "List bank transactions",
        "description": "Bank transactions in a date window (default: the last 30 days), newest first, with each row's categorization and whether it still needs human review. Filter with `category` (a ledger account number from GET /accounts) to see everything filed under one account, or `search` for a case-insensitive substring match on the descriptor and merchant. This is the raw money stream the books are built from — use it for spend questions, per-merchant digs, and review queues.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200. Default 50.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Row offset. Pass the previous page's `meta.pagination.nextOffset` to fetch the next page; `nextOffset` is null once the last page is reached.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Window start, YYYY-MM-DD (default 30 days ago).",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-07-01"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Window end, YYYY-MM-DD (default today).",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-07-31"
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Only rows categorized to this ledger account number.",
            "schema": {
              "type": "string"
            },
            "example": "6110"
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Case-insensitive substring match on descriptor/merchant.",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "example": "aws"
          }
        ],
        "responses": {
          "200": {
            "description": "Transactions, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Transaction"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/PaginationMeta"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "aB8cD1eF2gH3iJ4kL5mN6oP7qR9sT0uVwXyZ",
                      "date": "2026-07-15",
                      "authorizedDate": null,
                      "amount": -2500,
                      "currency": "USD",
                      "direction": "in",
                      "description": "STRIPE PAYOUT ACME STUDIO",
                      "merchant": "Stripe",
                      "pending": false,
                      "transactionType": "income",
                      "category": {
                        "accountNumber": "4010",
                        "accountName": "Revenue",
                        "confidence": 1,
                        "source": "user_override"
                      },
                      "needsReview": false
                    },
                    {
                      "id": "kQ3vX9nLm8wPzR4aT1bYc6dJf7gHe2iS5oNu",
                      "date": "2026-07-14",
                      "authorizedDate": "2026-07-13",
                      "amount": 129.99,
                      "currency": "USD",
                      "direction": "out",
                      "description": "AWS EMEA aws.amazon.com",
                      "merchant": "Amazon Web Services",
                      "pending": false,
                      "transactionType": "expense",
                      "category": {
                        "accountNumber": "6110",
                        "accountName": "Software & Subscriptions",
                        "confidence": 0.94,
                        "source": "memory"
                      },
                      "needsReview": false
                    }
                  ],
                  "meta": {
                    "pagination": {
                      "limit": 50,
                      "offset": 0,
                      "nextOffset": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "pushTransactions",
        "tags": [
          "Transactions"
        ],
        "summary": "Push transactions to a manual bank account",
        "description": "Import transactions into a manual bank institution previously created with POST /bank-accounts — the no-Plaid path for bringing your own bank feed. Rows land in the same pipeline Plaid-synced transactions use; Cherry categorizes and books them asynchronously (they appear uncategorized at first and are filed by the next sync sweep).\n\n**Sign convention (Plaid):** a POSITIVE `amount` means money LEFT the account (an expense/outflow); a NEGATIVE `amount` means money came in. Negate first if your export uses the opposite sign.\n\n**Idempotency:** each row's identity is the optional client `id` (reuse it across pushes for clean dedup) or, when omitted, a hash of date + amount + description. Re-posting the same payload updates rows in place instead of duplicating; duplicates within one payload are collapsed and counted in `deduplicated`. Requires the `write` scope. Body limit: 5 MB.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "institutionName",
                  "transactions"
                ],
                "properties": {
                  "entityId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional assertion: must match the entity that owns the institution (409 otherwise). Omit to use the institution's entity."
                  },
                  "institutionName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "description": "Name of a manual institution created via POST /bank-accounts."
                  },
                  "transactions": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 1000,
                    "items": {
                      "type": "object",
                      "required": [
                        "accountExternalId",
                        "date",
                        "amount",
                        "description"
                      ],
                      "properties": {
                        "accountExternalId": {
                          "type": "string",
                          "maxLength": 64,
                          "description": "externalId of an account created via POST /bank-accounts."
                        },
                        "id": {
                          "type": "string",
                          "maxLength": 64,
                          "pattern": "^[A-Za-z0-9._-]+$",
                          "description": "Your stable transaction id — reuse it across pushes so re-imports update instead of duplicate."
                        },
                        "date": {
                          "type": "string",
                          "format": "date",
                          "description": "YYYY-MM-DD, 2000-01-01 or later, at most 7 days in the future."
                        },
                        "amount": {
                          "type": "number",
                          "description": "Plaid sign: positive = money OUT of the account, negative = money in. Major units in the row's currency."
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 500
                        },
                        "merchant": {
                          "type": "string",
                          "maxLength": 200,
                          "description": "Optional merchant label. Catch-all labels like \"Other\" or \"Unknown\" are dropped rather than stored."
                        },
                        "currency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$",
                          "description": "ISO 4217; defaults to the account's currency."
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "institutionName": "First Community Bank",
                "transactions": [
                  {
                    "accountExternalId": "checking-1234",
                    "id": "stmt-2026-07-000041",
                    "date": "2026-07-14",
                    "amount": 129.99,
                    "description": "AWS EMEA aws.amazon.com",
                    "merchant": "Amazon Web Services",
                    "currency": "USD"
                  },
                  {
                    "accountExternalId": "checking-1234",
                    "date": "2026-07-15",
                    "amount": -2500,
                    "description": "STRIPE PAYOUT"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Import result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "received": {
                          "type": "integer",
                          "description": "Rows in the request payload."
                        },
                        "imported": {
                          "type": "integer",
                          "description": "Rows inserted or updated in the books."
                        },
                        "deduplicated": {
                          "type": "integer",
                          "description": "In-payload duplicates collapsed before writing (same computed identity)."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "received": 2,
                    "imported": 2,
                    "deduplicated": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{id}": {
      "get": {
        "operationId": "getTransaction",
        "tags": [
          "Transactions"
        ],
        "summary": "Get a bank transaction",
        "description": "A single transaction by the id returned from the list endpoint.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Public transaction id from listTransactions.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The transaction",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Transaction"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "kQ3vX9nLm8wPzR4aT1bYc6dJf7gHe2iS5oNu",
                    "date": "2026-07-14",
                    "authorizedDate": "2026-07-13",
                    "amount": 129.99,
                    "currency": "USD",
                    "direction": "out",
                    "description": "AWS EMEA aws.amazon.com",
                    "merchant": "Amazon Web Services",
                    "pending": false,
                    "transactionType": "expense",
                    "category": {
                      "accountNumber": "6110",
                      "accountName": "Software & Subscriptions",
                      "confidence": 0.94,
                      "source": "memory"
                    },
                    "needsReview": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "recategorizeTransaction",
        "tags": [
          "Transactions"
        ],
        "summary": "Recategorize a transaction",
        "description": "File the transaction under a different ledger account — the same correction a person makes in the app. The decision is recorded as a human override (confidence 1.0), the prior ledger posting is reversed and re-booked against the new account, and Cherry learns the merchant→account preference for future categorizations. Pass the literal `\"transfer\"` as the category to mark an inter-account move instead (transfers have no category account). Requires the `write` scope.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Public transaction id from listTransactions.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "category"
                ],
                "properties": {
                  "category": {
                    "type": "string",
                    "description": "Ledger account number from GET /accounts, or the literal \"transfer\"."
                  },
                  "reason": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "Optional one-line reason, recorded with the override."
                  }
                }
              },
              "example": {
                "category": "6110",
                "reason": "AWS is infrastructure spend, not office software."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The applied categorization",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "category": {
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/TransactionCategory"
                            }
                          ],
                          "nullable": true
                        },
                        "transactionType": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "kQ3vX9nLm8wPzR4aT1bYc6dJf7gHe2iS5oNu",
                    "category": {
                      "accountNumber": "6110",
                      "accountName": "Software & Subscriptions",
                      "confidence": 1,
                      "source": "user_override"
                    },
                    "transactionType": "expense"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/accounts": {
      "get": {
        "operationId": "listAccounts",
        "tags": [
          "Accounts"
        ],
        "summary": "List accounts",
        "description": "Every ledger account: number, name, category (asset/liability/equity/revenue/expense), and active flag. Account numbers are the vocabulary the rest of the API speaks — transaction categories and journal lines both resolve against this list. Small enough to return whole; not paginated.",
        "responses": {
          "200": {
            "description": "The full chart of accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LedgerAccount"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "b47a9c2e-1d3f-4a5b-8c6d-0e9f8a7b6c5d",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "accountNumber": "1010",
                      "name": "Checking",
                      "category": "asset",
                      "country": "US",
                      "isActive": true
                    },
                    {
                      "id": "a36f8b1d-0c2e-4f4a-8b5c-7d6e5f4a3b2c",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "accountNumber": "3000",
                      "name": "Opening Balance Equity",
                      "category": "equity",
                      "country": "US",
                      "isActive": true
                    },
                    {
                      "id": "c58b0d3f-2e4a-4b6c-9d7e-1f0a9b8c7d6e",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "accountNumber": "4010",
                      "name": "Revenue",
                      "category": "revenue",
                      "country": "US",
                      "isActive": true
                    },
                    {
                      "id": "d69c1e4a-3f5b-4c7d-0e8f-2a1b0c9d8e7f",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "accountNumber": "6110",
                      "name": "Software & Subscriptions",
                      "category": "expense",
                      "country": "US",
                      "isActive": true
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/bank-accounts": {
      "get": {
        "operationId": "listBankAccounts",
        "tags": [
          "Bank accounts"
        ],
        "summary": "List bank accounts",
        "description": "Every bank account the tenant has connected — Plaid-linked and manual — with its institution, currency, kind, balances, and whether it is mapped to a ledger account. `derivedBalance` (opening balance rolled forward through settled transactions) is the current figure for manual accounts; Plaid accounts report `currentBalance` instead. Small enough to return whole; not paginated.",
        "parameters": [
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Scope to one legal entity (UUID from GET /entities). Defaults to the tenant's primary entity.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tenant's bank accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BankAccount"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "22222222-2222-2222-2222-222222222222",
                      "externalAccountId": "manual:first-community-bank:checking-1234",
                      "institutionName": "First Community Bank",
                      "name": "Business Checking ••1234",
                      "currency": "USD",
                      "kind": "checking",
                      "type": "depository",
                      "openingBalance": 18250.75,
                      "openingBalanceDate": "2026-01-01",
                      "derivedBalance": 42850.75,
                      "currentBalance": null,
                      "ledgerMapped": true,
                      "ledgerAccountNumber": "1010"
                    },
                    {
                      "id": "7c1d9e3f-5a2b-4c8d-9e0f-6a4b2c8d0e1f",
                      "externalAccountId": "BxDpQ4Kv8zRmW2nYoJ7LgT3aVfE9c1hSb5uM",
                      "institutionName": "Chase",
                      "name": "Ink Business Card ••7733",
                      "currency": "USD",
                      "kind": "credit_card",
                      "type": "credit",
                      "openingBalance": null,
                      "openingBalanceDate": null,
                      "derivedBalance": null,
                      "currentBalance": 1240.5,
                      "ledgerMapped": false,
                      "ledgerAccountNumber": null
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createBankAccounts",
        "tags": [
          "Bank accounts"
        ],
        "summary": "Create a manual bank institution",
        "description": "Create (or idempotently update) a manual bank institution and its accounts — the first step of the no-Plaid flow: create accounts here, then push their transactions through POST /transactions using the same `institutionName` and each account's `externalId`.\n\nIdempotent per (institution, account externalId): re-posting the same institution upserts onto the same synthetic bank item, and accounts absent from a later POST are left in place. An institution stays pinned to the entity it was first created under; posting it with a different `entityId` is a 409 conflict.\n\nDeclare `openingBalance` (+ `openingBalanceDate`) so the books start from the real balance — Cherry posts it to the General Ledger and rolls it forward as transactions arrive. New accounts are auto-mapped to ledger accounts by kind (`ledgerMapped` in the response says whether that succeeded). Requires the `write` scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "institutionName",
                  "accounts"
                ],
                "properties": {
                  "entityId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Legal entity to attach the institution to (UUID from GET /entities). Defaults to the tenant's primary entity."
                  },
                  "institutionName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "description": "Display name of the bank — also the key you pass to POST /transactions."
                  },
                  "accounts": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "required": [
                        "externalId",
                        "name",
                        "kind"
                      ],
                      "properties": {
                        "externalId": {
                          "type": "string",
                          "maxLength": 64,
                          "pattern": "^[A-Za-z0-9._-]+$",
                          "description": "Your stable key for the account (account number, IBAN, nickname). Referenced by every pushed transaction."
                        },
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 120
                        },
                        "currency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$",
                          "default": "USD",
                          "description": "ISO 4217, e.g. USD."
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "checking",
                            "savings",
                            "credit_card"
                          ],
                          "description": "Drives ledger auto-mapping and keeps credit cards out of the cash position."
                        },
                        "openingBalance": {
                          "type": "number",
                          "description": "Balance as of openingBalanceDate, major units (positive for money held; Plaid sign applies to transactions, not this figure)."
                        },
                        "openingBalanceDate": {
                          "type": "string",
                          "format": "date"
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "institutionName": "First Community Bank",
                "accounts": [
                  {
                    "externalId": "checking-1234",
                    "name": "Business Checking ••1234",
                    "currency": "USD",
                    "kind": "checking",
                    "openingBalance": 18250.75,
                    "openingBalanceDate": "2026-01-01"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created (or updated) institution and its accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "itemId": {
                          "type": "string",
                          "description": "Synthetic id of the manual bank item."
                        },
                        "accounts": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "externalId": {
                                "type": "string"
                              },
                              "bankAccountId": {
                                "type": "string",
                                "format": "uuid"
                              },
                              "ledgerMapped": {
                                "type": "boolean"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "itemId": "manual:11111111-1111-1111-1111-111111111111:first-community-bank",
                    "accounts": [
                      {
                        "externalId": "checking-1234",
                        "bankAccountId": "22222222-2222-2222-2222-222222222222",
                        "ledgerMapped": true
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/bank-statements": {
      "post": {
        "operationId": "uploadBankStatement",
        "tags": [
          "Bank statements"
        ],
        "summary": "Upload a bank statement",
        "description": "Send a statement file and Cherry does the rest: transcribes it, verifies the transactions roll the opening balance forward to the printed closing balance (a statement that doesn't reconcile is rejected whole), creates or matches the manual institution + account, and lands the transactions — deduplicated against rows pushed via POST /transactions.\n\nProcessing is asynchronous: the response is a `202` with a `documentId`; poll GET /bank-statements/{documentId} for the outcome (typically well under a minute). Re-uploading the same statement is a no-op: the period is keyed by (account, periodStart, periodEnd) and each transaction by its content, so nothing duplicates.\n\nPDF is the best input; images of statements work too. 25 MB max. Requires the `write` scope. Rate-limited more tightly than other writes — each upload costs a transcription pass.\n\nSend the file as RAW BYTES. A file read as text first (`readFileSync(path, \"utf8\")`, `open(path).read()`) arrives with its binary content replaced by U+FFFD: it still looks like a PDF but every page renders blank. Cherry detects this and answers `400 file_corrupted`.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The statement file (PDF or image). Max 25 MB."
                  },
                  "entityId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Legal entity the account belongs to (UUID from GET /entities). Defaults to the tenant's primary entity."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted — processing has started.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "documentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "documentId": "9f8e7d6c-5b4a-4321-8765-4321fedcba98",
                    "status": "processing"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listBankStatements",
        "tags": [
          "Bank statements"
        ],
        "summary": "List bank statements",
        "description": "Every statement period in the books, newest first — the freshness record for statement-fed accounts: books are current through the latest `periodEnd`. Filter by `bankAccountId` for one account's history.",
        "parameters": [
          {
            "name": "bankAccountId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Restrict to one bank account (id from GET /bank-accounts)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ingested statement periods, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BankStatement"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/bank-statements/{documentId}": {
      "get": {
        "operationId": "getBankStatementUpload",
        "tags": [
          "Bank statements"
        ],
        "summary": "Get bank statement upload status",
        "description": "Where an uploaded statement landed. `processing` — no outcome yet; `ingested` — the period is in the books (the `statement` object says what); `rejected` — the `rejection.reason` says why, e.g. `did_not_reconcile` (the transactions don't roll the opening balance to the printed closing — re-upload a complete, legible copy), `not_a_bank_statement`, `document_unreadable`, or `no_transactions`.",
        "parameters": [
          {
            "name": "documentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The id returned by POST /bank-statements."
          }
        ],
        "responses": {
          "200": {
            "description": "The upload's status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "documentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "processing",
                            "ingested",
                            "rejected"
                          ]
                        },
                        "statement": {
                          "$ref": "#/components/schemas/BankStatement",
                          "description": "Present when status is `ingested`."
                        },
                        "rejection": {
                          "type": "object",
                          "description": "Present when status is `rejected`.",
                          "properties": {
                            "reason": {
                              "type": "string"
                            },
                            "detail": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "documentId": "9f8e7d6c-5b4a-4321-8765-4321fedcba98",
                    "status": "ingested",
                    "statement": {
                      "id": "1a2b3c4d-5e6f-4a8b-9c0d-1e2f3a4b5c6d",
                      "documentId": "9f8e7d6c-5b4a-4321-8765-4321fedcba98",
                      "bankAccountId": "22222222-2222-2222-2222-222222222222",
                      "periodStart": "2026-07-01",
                      "periodEnd": "2026-07-31",
                      "currency": "MXN",
                      "openingBalance": 128450.3,
                      "closingBalance": 115359.75,
                      "transactionCount": 42,
                      "continuityOk": true,
                      "createdAt": "2026-08-05T14:02:11.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/journal-entries": {
      "get": {
        "operationId": "listJournalEntries",
        "tags": [
          "Journal"
        ],
        "summary": "List journal entries",
        "description": "The double-entry journal between `from` and `to` (both required), oldest first, each entry with its balanced debit/credit lines. Add `accountNumber` to see only the entries touching one account — the drill-down behind any statement or trial-balance figure.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "Period start, YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-07-01"
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "Period end, YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-07-31"
          },
          {
            "name": "accountNumber",
            "in": "query",
            "required": false,
            "description": "Only entries with a line on this ledger account.",
            "schema": {
              "type": "string"
            },
            "example": "6110"
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Scope to one legal entity (UUID from GET /entities). Defaults to the tenant's primary entity.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200. Default 50.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Row offset. Pass the previous page's `meta.pagination.nextOffset` to fetch the next page; `nextOffset` is null once the last page is reached.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Journal entries, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/JournalEntry"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "pagination": {
                          "$ref": "#/components/schemas/PaginationMeta"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "e7ad2f5b-4a6c-4d8e-9f0a-3b2c1d0e9f8a",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "entryDate": "2026-07-14",
                      "description": "AWS EMEA aws.amazon.com",
                      "sourceType": "bank_feed",
                      "postedAt": "2026-07-15T02:10:44.000Z",
                      "lines": [
                        {
                          "accountId": "d69c1e4a-3f5b-4c7d-0e8f-2a1b0c9d8e7f",
                          "debit": 129.99,
                          "credit": null,
                          "currency": "USD",
                          "memo": "Amazon Web Services"
                        },
                        {
                          "accountId": "b47a9c2e-1d3f-4a5b-8c6d-0e9f8a7b6c5d",
                          "debit": null,
                          "credit": 129.99,
                          "currency": "USD",
                          "memo": null
                        }
                      ]
                    },
                    {
                      "id": "f8be3a6c-5b7d-4e9f-0a1b-4c3d2e1f0a9b",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "entryDate": "2026-07-15",
                      "description": "STRIPE PAYOUT ACME STUDIO",
                      "sourceType": "bank_feed",
                      "postedAt": "2026-07-16T02:09:12.000Z",
                      "lines": [
                        {
                          "accountId": "b47a9c2e-1d3f-4a5b-8c6d-0e9f8a7b6c5d",
                          "debit": 2500,
                          "credit": null,
                          "currency": "USD",
                          "memo": null
                        },
                        {
                          "accountId": "c58b0d3f-2e4a-4b6c-9d7e-1f0a9b8c7d6e",
                          "debit": null,
                          "credit": 2500,
                          "currency": "USD",
                          "memo": "Stripe payout"
                        }
                      ]
                    }
                  ],
                  "meta": {
                    "pagination": {
                      "limit": 50,
                      "offset": 0,
                      "nextOffset": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/journal-entries/{id}": {
      "get": {
        "operationId": "getJournalEntry",
        "tags": [
          "Journal"
        ],
        "summary": "Get a journal entry",
        "description": "A single journal entry with its lines, by UUID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The journal entry",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JournalEntry"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "e7ad2f5b-4a6c-4d8e-9f0a-3b2c1d0e9f8a",
                    "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                    "entryDate": "2026-07-14",
                    "description": "AWS EMEA aws.amazon.com",
                    "sourceType": "bank_feed",
                    "postedAt": "2026-07-15T02:10:44.000Z",
                    "lines": [
                      {
                        "accountId": "d69c1e4a-3f5b-4c7d-0e8f-2a1b0c9d8e7f",
                        "debit": 129.99,
                        "credit": null,
                        "currency": "USD",
                        "memo": "Amazon Web Services"
                      },
                      {
                        "accountId": "b47a9c2e-1d3f-4a5b-8c6d-0e9f8a7b6c5d",
                        "debit": null,
                        "credit": 129.99,
                        "currency": "USD",
                        "memo": null
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/reports/trial-balance": {
      "get": {
        "operationId": "getTrialBalance",
        "tags": [
          "Reports"
        ],
        "summary": "Get trial balance",
        "description": "One row per ledger account with cumulative debits, credits, and the natural-direction balance through `asOf` (inclusive) — where everything is sitting right now. The backbone for any custom management report.",
        "parameters": [
          {
            "name": "asOf",
            "in": "query",
            "required": true,
            "description": "Balance cutoff date, YYYY-MM-DD (inclusive).",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-06-30"
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Scope to one legal entity (UUID from GET /entities). Defaults to the tenant's primary entity.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The trial balance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/TrialBalance"
                    }
                  }
                },
                "example": {
                  "data": {
                    "asOf": "2026-06-30",
                    "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                    "accounts": [
                      {
                        "accountNumber": "1010",
                        "name": "Checking",
                        "category": "asset",
                        "isActive": true,
                        "debit": 46750.75,
                        "credit": 3900,
                        "balance": 42850.75
                      },
                      {
                        "accountNumber": "3000",
                        "name": "Opening Balance Equity",
                        "category": "equity",
                        "isActive": true,
                        "debit": 0,
                        "credit": 18250.75,
                        "balance": 18250.75
                      },
                      {
                        "accountNumber": "4010",
                        "name": "Revenue",
                        "category": "revenue",
                        "isActive": true,
                        "debit": 0,
                        "credit": 28500,
                        "balance": 28500
                      },
                      {
                        "accountNumber": "6110",
                        "name": "Software & Subscriptions",
                        "category": "expense",
                        "isActive": true,
                        "debit": 3900,
                        "credit": 0,
                        "balance": 3900
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/reports/statements/{type}": {
      "get": {
        "operationId": "getFinancialStatement",
        "tags": [
          "Reports"
        ],
        "summary": "Generate a financial statement",
        "description": "A financial statement computed from the live ledger — the exact generator the Cherry app uses, so figures here always match the product. `profit_and_loss` and `cash_flow` cover the `from`..`to` period (both required); `balance_sheet` is a snapshot as of `to` (`from` is ignored). The response shape varies by statement type: revenue/expense breakdowns for P&L, asset/liability/equity sections for the balance sheet, inflow/outflow for cash flow.",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "profit_and_loss",
                "balance_sheet",
                "cash_flow"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Period start, YYYY-MM-DD. Required for profit_and_loss and cash_flow.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-01-01"
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "Period end, YYYY-MM-DD. For balance_sheet this is the as-of snapshot date.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-06-30"
          }
        ],
        "responses": {
          "200": {
            "description": "The generated statement (shape varies by type)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "type": "income_statement",
                    "periodStart": "2026-01-01",
                    "periodEnd": "2026-06-30",
                    "currency": "USD",
                    "revenue": {
                      "total": 28500,
                      "breakdown": [
                        {
                          "accountNumber": "4010",
                          "accountName": "Revenue",
                          "amount": 28500
                        }
                      ]
                    },
                    "expenses": {
                      "total": 3900,
                      "breakdown": [
                        {
                          "accountNumber": "6110",
                          "accountName": "Software & Subscriptions",
                          "amount": 3900
                        }
                      ]
                    },
                    "netIncome": 24600
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/entities": {
      "get": {
        "operationId": "listEntities",
        "tags": [
          "Entities"
        ],
        "summary": "List legal entities",
        "description": "Every legal entity behind the tenant (a business can have several — e.g. a Delaware C-Corp and a Mexican operating company). Tax ids are masked to their last 4 characters. Use the entity ids to scope journal and report reads.",
        "responses": {
          "200": {
            "description": "The tenant's entities",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Entity"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "country": "US",
                      "legalName": "Acme Studio LLC",
                      "taxIdMasked": "*****4821",
                      "taxIdType": "EIN",
                      "entityType": "llc",
                      "regime": null,
                      "status": "active",
                      "isPrimary": true,
                      "createdAt": "2025-11-04T18:22:31.000Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/entities/{id}": {
      "get": {
        "operationId": "getEntity",
        "tags": [
          "Entities"
        ],
        "summary": "Get a legal entity",
        "description": "A single entity by UUID, tax id masked.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The entity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Entity"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                    "country": "US",
                    "legalName": "Acme Studio LLC",
                    "taxIdMasked": "*****4821",
                    "taxIdType": "EIN",
                    "entityType": "llc",
                    "regime": null,
                    "status": "active",
                    "isPrimary": true,
                    "createdAt": "2025-11-04T18:22:31.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/obligations": {
      "get": {
        "operationId": "listObligations",
        "tags": [
          "Obligations"
        ],
        "summary": "List tax obligations",
        "description": "Every confirmed tax/compliance obligation Cherry is tracking, deadline ascending: type, period, frequency, deadline, status, jurisdiction, authority, and form reference. Filter with `status` (comma-separated: upcoming, payment_pending, confirmed, filed) — e.g. `status=upcoming` for what's due next — and `from` to drop past deadlines.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Comma-separated status filter: upcoming, payment_pending, confirmed, filed.",
            "schema": {
              "type": "string"
            },
            "example": "upcoming,payment_pending"
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Only obligations with deadline on/after this date.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-07-01"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Max rows, 1-500. Default 100.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Obligations, deadline ascending",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Obligation"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "5e2f7a9b-1c3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "country": "US",
                      "type": "federal_estimated_tax",
                      "period": "2026-Q3",
                      "frequency": "quarterly",
                      "deadline": "2026-09-15",
                      "status": "upcoming",
                      "amountDue": 6150,
                      "currency": "USD",
                      "filedAt": null,
                      "jurisdictionLevel": "federal",
                      "stateCode": null,
                      "authority": "IRS",
                      "formReference": "Form 1040-ES"
                    },
                    {
                      "id": "6f3a8b0c-2d4e-4f6a-9b7c-8d9e0f1a2b3c",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "country": "US",
                      "type": "state_annual_report",
                      "period": "2026",
                      "frequency": "annual",
                      "deadline": "2026-06-01",
                      "status": "filed",
                      "amountDue": 300,
                      "currency": "USD",
                      "filedAt": "2026-05-20T16:03:00.000Z",
                      "jurisdictionLevel": "state",
                      "stateCode": "DE",
                      "authority": "Delaware Division of Corporations",
                      "formReference": null
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/health-score": {
      "get": {
        "operationId": "getHealthScore",
        "tags": [
          "Health"
        ],
        "summary": "Get fiscal health score",
        "description": "Cherry's composite fiscal readiness score (0-100 with a grade): profile completeness of the primary entity, obligation hygiene (overdue filings cost points), and the latest document-detector findings. The single number to watch for \"is this business's fiscal house in order\", with the issues that cost points itemized per component.",
        "responses": {
          "200": {
            "description": "The health score",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/HealthScore"
                    }
                  }
                },
                "example": {
                  "data": {
                    "country": "US",
                    "score": 94,
                    "grade": "A",
                    "summary": "94/100 (A). Profile + obligations look healthy.",
                    "components": [
                      {
                        "label": "Business profile",
                        "penalty": 6,
                        "issues": [
                          {
                            "severity": "warning",
                            "code": "missing_address_line1",
                            "message": "Profile field missing: address.line1."
                          }
                        ]
                      },
                      {
                        "label": "Obligations",
                        "penalty": 0,
                        "issues": []
                      }
                    ],
                    "criticalIssues": [],
                    "warningIssues": [
                      {
                        "severity": "warning",
                        "code": "missing_address_line1",
                        "message": "Profile field missing: address.line1."
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/incorporations": {
      "get": {
        "operationId": "listIncorporations",
        "tags": [
          "Incorporations"
        ],
        "summary": "In-flight incorporations",
        "description": "Companies being formed that have no legal-entity record yet, each grouped with its order lines (formation, registered agent, EIN) and their filing status. Once the formation files and the entity exists, its orders move to GET /filings.",
        "responses": {
          "200": {
            "description": "Pending incorporations, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PendingIncorporation"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "companyId": "comp_x1y2z3a4b5c6d7e8",
                      "legalName": "Acme Ventures LLC",
                      "entityType": "LLC",
                      "filingState": "DE",
                      "createdAt": "2026-08-19T18:04:11.000Z",
                      "items": [
                        {
                          "orderId": "ord_a1b2c3d4e5f6a7b8",
                          "orderType": "formation",
                          "filingStatus": "pending",
                          "filingDate": null
                        },
                        {
                          "orderId": "ord_b2c3d4e5f6a7b8c9",
                          "orderType": "registered_agent",
                          "filingStatus": "submitted",
                          "filingDate": null
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "startIncorporation",
        "tags": [
          "Incorporations"
        ],
        "summary": "Form a new company (write scope)",
        "description": "Start a company formation in any US state — LLC or corporation — optionally bundling an EIN order. **This files real state paperwork and incurs filing costs.**\n\n**International founders:** the company's principal/mailing addresses and every officer address accept ANY country — set the `*Country` fields to a two-letter ISO code (default `US`). For non-US addresses the state field is free text (e.g. `CDMX`) and the zip field takes any postal code. Only `filingState` must be a US state.\n\n**LLCs must set `structureType`** (`MEMBER` or `MANAGER`). A registered agent in the filing state is required: supply your own via `registeredAgent`, or leave `useRegisteredAgentService` at its default (true) and Cherry provides one.\n\n**EIN:** include `ein` to apply for the company's EIN in the same bundle. When the responsible party has no SSN or ITIN, omit `responsiblePartySsn` and set `einNoSsn: true` — Cherry then prepares and files the EIN application with the IRS on the company's behalf, and the response carries an `einApplication` describing its status. The flag is required rather than inferred: dropping an SSN by accident and silently taking the slower route would be the wrong default, so the two are rejected as a pair (send the SSN, or send `einNoSsn`, never both).\n\n**Idempotency:** send an `Idempotency-Key` header; a retried POST with the same key replays the original result instead of forming a second company.\n\n**Credits:** every formation spends one prepaid incorporation credit. With none left the request is refused with `402 payment_required` and a `topUpUrl` — a hosted checkout where the account owner buys credits (one, or a pack). Nothing is ordered on a 402; retry the same request (same `Idempotency-Key`) once the credits have landed. `topUpUrl` is null when checkout is unavailable; contact support.\n\n**Errors specific to this endpoint:** `registered_agent_required` (400 — supply `registeredAgent` or leave `useRegisteredAgentService` unset), `payment_required` (402 — no credit; see `topUpUrl`), `filing_account_conflict` / `company_conflict` (409 — a filing account or company with this identity exists but is not linked; contact support), `formation_not_filed` (502 — the order was accepted but no formation filing came back; recorded for review, do NOT retry), `billing_unavailable` (503 — the credit could not be confirmed; nothing was ordered, retry shortly), `incorporations_unavailable` (503).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "legalName",
                  "entityType",
                  "filingState",
                  "addressStreet",
                  "addressCity",
                  "addressState",
                  "addressZip",
                  "mailingAddressStreet",
                  "mailingAddressCity",
                  "mailingAddressState",
                  "mailingAddressZip",
                  "officers"
                ],
                "properties": {
                  "legalName": {
                    "type": "string",
                    "description": "Exact legal name including the suffix (LLC, Inc.)."
                  },
                  "entityType": {
                    "type": "string",
                    "enum": [
                      "LLC",
                      "CORP"
                    ]
                  },
                  "filingState": {
                    "type": "string",
                    "description": "Two-letter US state to form in."
                  },
                  "structureType": {
                    "type": "string",
                    "enum": [
                      "MEMBER",
                      "MANAGER"
                    ],
                    "description": "Required for LLCs."
                  },
                  "llcMemberCount": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "How many members the LLC has. LLCs only. Supply it when ordering an EIN: it answers SS-4 line 8b and decides line 9a (one member is a disregarded entity, several a partnership)."
                  },
                  "taxElection": {
                    "type": "string",
                    "enum": [
                      "C Corporation",
                      "S Corporation"
                    ],
                    "description": "Corporations only."
                  },
                  "authorizedShares": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Shares the certificate of incorporation authorises. Corporations only. Required in the states that price the certificate by its stock (CT, DE, KY, MA, MD, MI, MO, NM, NV, OH, OK, VA), where the published fee is a minimum rather than the price; optional elsewhere."
                  },
                  "parValuePerShare": {
                    "type": "string",
                    "description": "Par value per share as a decimal string, e.g. \"0.0001\", or \"0\" for no par value. Corporations only. Required in the states whose fee depends on it (DE, MD, MO, NV, OK) because the two answers differ by orders of magnitude and neither is safe to assume."
                  },
                  "fiscalEndMonth": {
                    "type": "string",
                    "description": "e.g. December."
                  },
                  "addressStreet": {
                    "type": "string"
                  },
                  "addressCity": {
                    "type": "string"
                  },
                  "addressState": {
                    "type": "string",
                    "description": "Two-letter state code for US addresses; free text elsewhere."
                  },
                  "principalCounty": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "County of the principal place of business — SS-4 line 6. US addresses only; sending one with a foreign address is rejected. Optional: Cherry derives the county from the ZIP wherever two independent public datasets agree the ZIP sits in a single county, and only needs this for the ZIPs that straddle a county line."
                  },
                  "addressZip": {
                    "type": "string",
                    "description": "ZIP for US addresses; any postal code elsewhere."
                  },
                  "addressCountry": {
                    "type": "string",
                    "description": "Two-letter ISO country code, uppercase. Default US."
                  },
                  "mailingAddressStreet": {
                    "type": "string"
                  },
                  "mailingAddressCity": {
                    "type": "string"
                  },
                  "mailingAddressState": {
                    "type": "string"
                  },
                  "mailingAddressZip": {
                    "type": "string"
                  },
                  "mailingAddressCountry": {
                    "type": "string"
                  },
                  "officers": {
                    "type": "array",
                    "minItems": 1,
                    "description": "At least one officer (PERSON or COMPANY), each with their own address — any country.",
                    "items": {
                      "type": "object"
                    }
                  },
                  "registeredAgent": {
                    "type": "object",
                    "description": "Bring your own registered agent (must be in the filing state). Omit to use Cherry's registered-agent service."
                  },
                  "useRegisteredAgentService": {
                    "type": "boolean",
                    "description": "Default true when no registeredAgent is supplied: Cherry provides the agent as a separate order line."
                  },
                  "ein": {
                    "type": "object",
                    "description": "Apply for the company's EIN in the same bundle. Omit responsiblePartySsn when the responsible party has no SSN/ITIN, and set einNoSsn alongside it."
                  },
                  "einNoSsn": {
                    "type": "boolean",
                    "description": "The responsible party has no US SSN or ITIN, so Cherry prepares and files the EIN application itself and the EIN arrives later. Required when ein omits responsiblePartySsn, and rejected when sent alongside one."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The incorporation order bundle",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "companyId": {
                          "type": "string"
                        },
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/IncorporationOrderItem"
                          }
                        },
                        "einApplication": {
                          "type": "object",
                          "nullable": true,
                          "description": "Present when Cherry is filing the EIN application on the company's behalf (responsible party without an SSN/ITIN)."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "companyId": "comp_x1y2z3a4b5c6d7e8",
                    "items": [
                      {
                        "orderId": "ord_a1b2c3d4e5f6a7b8",
                        "orderType": "formation",
                        "filingStatus": "submitted"
                      },
                      {
                        "orderId": "ord_b2c3d4e5f6a7b8c9",
                        "orderType": "registered_agent",
                        "filingStatus": "submitted"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "No incorporation credit on the account. Nothing was ordered. `topUpUrl` is the hosted checkout where the account owner buys credits; retry the same request once they have landed.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "topUpUrl": {
                          "type": "string",
                          "nullable": true,
                          "description": "Hosted checkout for buying incorporation credits. Null when checkout is unavailable on the server."
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "error": "payment_required",
                  "reason": "This account has no incorporation credits left. Buy credits at `topUpUrl`, then retry the same request (with the same Idempotency-Key, if one was sent).",
                  "topUpUrl": "https://checkout.stripe.com/c/pay/cs_live_a1b2c3"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications": {
      "get": {
        "operationId": "listEinApplications",
        "tags": [
          "Incorporations"
        ],
        "summary": "EIN applications Cherry files on paper",
        "description": "Applications created by POST /incorporations with `einNoSsn` — the route for a responsible party who has no US SSN or ITIN and therefore cannot use the IRS online tool. Cherry prepares Form SS-4, collects the responsible party's signature, and files it with the IRS on the company's behalf as third-party designee. The IRS issues these by fax to applicants without a US tax identifier and typically takes several weeks — commonly four to eight — against same-day for an applicant with an SSN. The company is formed either way; the EIN is what opens a bank account.",
        "responses": {
          "200": {
            "description": "EIN applications for this tenant, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/EinApplication"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "8a6f1e2c-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
                      "entityId": null,
                      "legalName": "Acme Ventures LLC",
                      "entityType": "LLC",
                      "filingState": "DE",
                      "status": "ready_to_file",
                      "ein": null,
                      "ss4DocumentId": null,
                      "signatureEnvelopeId": null,
                      "signedDocumentId": null,
                      "filedAt": null,
                      "receivedAt": null,
                      "signatureRequestedAt": null,
                      "signedAt": null,
                      "createdAt": "2026-08-19T18:04:11.000Z",
                      "updatedAt": "2026-08-19T18:04:11.000Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}": {
      "get": {
        "operationId": "getEinApplication",
        "tags": [
          "Incorporations"
        ],
        "summary": "Get an EIN application",
        "description": "A single application by id, for polling its status.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The EIN application",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/EinApplication"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "8a6f1e2c-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
                    "entityId": null,
                    "legalName": "Acme Ventures LLC",
                    "entityType": "LLC",
                    "filingState": "DE",
                    "status": "ready_to_file",
                    "ein": null,
                    "ss4DocumentId": null,
                    "signatureEnvelopeId": null,
                    "signedDocumentId": null,
                    "filedAt": null,
                    "receivedAt": null,
                    "signatureRequestedAt": null,
                    "signedAt": null,
                    "createdAt": "2026-08-19T18:04:11.000Z",
                    "updatedAt": "2026-08-19T18:04:11.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/generate-ss4": {
      "post": {
        "operationId": "generateEinApplicationForm",
        "tags": [
          "Incorporations"
        ],
        "summary": "Render Form SS-4 (write scope)",
        "description": "Renders the application's answers onto the official IRS Form SS-4 and stores the result, so the document the responsible party signs is the same artefact Cherry files. Allowed only while `ready_to_file`: once the form is out for signature, regenerating it would mean the thing they signed is not the thing Cherry holds.\n\n`gaps` lists what the IRS expects that Cherry cannot fill yet, in plain language — surface it as the outstanding-items list. `problems` lists values that could not be written onto the form at all.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The form was rendered and attached to the application",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "documentId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "filled": {
                          "type": "integer",
                          "description": "Fields written onto the form."
                        },
                        "gaps": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "field": {
                                "type": "string"
                              },
                              "why": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "problems": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "field": {
                                "type": "string"
                              },
                              "detail": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "application": {
                          "$ref": "#/components/schemas/EinApplication"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "documentId": "1f2e3d4c-5b6a-4988-9a0b-1c2d3e4f5a6b",
                    "filled": 27,
                    "gaps": [
                      {
                        "field": "Date the business started",
                        "why": "the formation has not filed yet, so there is no start date"
                      }
                    ],
                    "problems": [],
                    "application": {
                      "id": "8a6f1e2c-3b4d-4e5f-9a0b-1c2d3e4f5a6b",
                      "entityId": null,
                      "legalName": "Acme Ventures LLC",
                      "entityType": "LLC",
                      "filingState": "DE",
                      "status": "ready_to_file",
                      "ein": null,
                      "ss4DocumentId": null,
                      "signatureEnvelopeId": null,
                      "signedDocumentId": null,
                      "filedAt": null,
                      "receivedAt": null,
                      "signatureRequestedAt": null,
                      "signedAt": null,
                      "createdAt": "2026-08-19T18:04:11.000Z",
                      "updatedAt": "2026-08-19T18:04:11.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/ss4.pdf": {
      "get": {
        "operationId": "downloadEinApplicationForm",
        "tags": [
          "Incorporations"
        ],
        "summary": "Download Form SS-4",
        "description": "The stored PDF: the executed copy once it has been signed, otherwise the draft. Streamed through this authenticated endpoint rather than a shareable link — the form carries the responsible party's name, address and phone.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/request-signature": {
      "post": {
        "operationId": "requestEinApplicationSignature",
        "tags": [
          "Incorporations"
        ],
        "summary": "Email the responsible party for signature (write scope)",
        "description": "Sends the rendered SS-4 to the responsible party to sign. They sign under penalties of perjury as the person named on line 7a — Cherry is only the third-party designee and can never be the signer.\n\n`signerEmail` is resolved to a person Cherry already knows: the address must belong to a workspace member or trusted contact, AND the name Cherry holds for that address must be the responsible party named on the form. A colleague cannot be nominated in their place. `signerName` is optional and treated as a confirmation; if it disagrees with the record the request is refused rather than overridden.\n\nThe signing link is never returned. It is a bearer credential — anyone holding it can sign — so it is mailed to the recipient and nowhere else. Poll the application's status to see when it has been signed.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "signerEmail"
                ],
                "properties": {
                  "signerEmail": {
                    "type": "string",
                    "format": "email",
                    "description": "The responsible party's own address."
                  },
                  "signerName": {
                    "type": "string",
                    "description": "Optional confirmation of the name on file."
                  }
                }
              },
              "example": {
                "signerEmail": "maria@acmeventures.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The form is out for signature",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "application": {
                          "$ref": "#/components/schemas/EinApplication"
                        },
                        "envelopeId": {
                          "type": "string",
                          "description": "Signature envelope id. Not a signing link."
                        },
                        "signer": {
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "string",
                              "format": "email"
                            },
                            "name": {
                              "type": "string",
                              "description": "The name Cherry holds on file."
                            },
                            "standing": {
                              "type": "string",
                              "enum": [
                                "member",
                                "stakeholder"
                              ]
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/cancel-signature": {
      "post": {
        "operationId": "cancelEinApplicationSignature",
        "tags": [
          "Incorporations"
        ],
        "summary": "Void an outstanding signature request (write scope)",
        "description": "Cancels the outstanding request and returns the application to `ready_to_file`, so it can be regenerated, re-sent, or filed by hand. The envelope is voided with the signing service FIRST; if that cannot be confirmed nothing changes, because forgetting a still-signable envelope is worse than leaving the application where it is.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request was voided",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "application": {
                          "$ref": "#/components/schemas/EinApplication"
                        },
                        "envelopeCancelled": {
                          "type": "boolean",
                          "description": "False when no envelope had been raised yet."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/reconcile-signature": {
      "post": {
        "operationId": "reconcileEinApplicationSignature",
        "tags": [
          "Incorporations"
        ],
        "summary": "Re-check an outstanding signature with the signing service (write scope)",
        "description": "Recovers an application whose signature completion never reached Cherry — a dropped callback, an outage, exhausted retries. Cherry asks the signing service what really happened to the outstanding envelope and, only if it is genuinely complete AND belongs to this application, records the signed form and moves the application to `signed`: exactly what the callback would have done. Safe to call repeatedly — an application that is already signed is reported rather than rewritten, and a form still out for signature comes back with `reconciled: false`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What the signing service reported, and whether anything changed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "application": {
                          "$ref": "#/components/schemas/EinApplication"
                        },
                        "reconciled": {
                          "type": "boolean",
                          "description": "True only when this call moved the application to `signed`."
                        },
                        "reason": {
                          "type": "string",
                          "enum": [
                            "signed",
                            "already_signed",
                            "not_complete",
                            "not_advanceable"
                          ],
                          "description": "`not_complete` means the form has not been signed yet — not an error."
                        },
                        "envelopeStatus": {
                          "type": "string",
                          "nullable": true,
                          "description": "The signing service's own status for the request, when one was read."
                        },
                        "signedDocumentId": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/reconcile-transmission": {
      "post": {
        "operationId": "reconcileEinApplicationTransmission",
        "tags": [
          "Incorporations"
        ],
        "summary": "Re-check an outstanding fax transmission with the carrier (write scope)",
        "description": "Recovers an application whose fax delivery report never reached Cherry — a dropped callback, an outage, an endpoint that was not reachable. For a responsible party with no US taxpayer id the fax IS the filing, so a delivered form that Cherry never recorded leaves the application stuck at `signed` forever. Cherry asks the carrier what really happened to the outstanding transmission and, only on a genuine success, records the delivery and moves the application to `filed` with the carrier's own completion time: exactly what the delivery report would have done. It never re-sends the fax. Safe to call repeatedly — an application already filed is reported rather than rewritten, a transmission still connecting comes back with `reconciled: false`, and a failed transmission leaves the application at `signed` so it can be retried.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What the carrier reported, and whether anything changed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "application": {
                          "$ref": "#/components/schemas/EinApplication"
                        },
                        "reconciled": {
                          "type": "boolean",
                          "description": "True only when this call moved the application to `filed`."
                        },
                        "reason": {
                          "type": "string",
                          "enum": [
                            "filed",
                            "already_filed",
                            "in_flight",
                            "failed",
                            "unconfirmable",
                            "delivery_in_progress",
                            "not_advanceable"
                          ],
                          "description": "`in_flight` means the fax has not connected yet — not an error. `failed` means the carrier could not deliver it; the application stays `signed` and can be transmitted again. `unconfirmable` means the fax outlived the window the carrier will report on, so whether it arrived can no longer be established: the transmission is recorded as terminally unconfirmable, the application is left `signed` rather than assumed filed, and a human must decide between re-transmitting and marking it filed."
                        },
                        "carrierStatus": {
                          "type": "string",
                          "nullable": true,
                          "description": "The carrier's own status for the fax, when one was read."
                        },
                        "transmission": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid"
                            },
                            "status": {
                              "type": "string"
                            },
                            "providerFaxId": {
                              "type": "string",
                              "nullable": true
                            },
                            "completedAt": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/mark-filed": {
      "post": {
        "operationId": "markEinApplicationFiled",
        "tags": [
          "Incorporations"
        ],
        "summary": "Record that the form went to the IRS (write scope)",
        "description": "Marks a signed application as filed. Cherry cannot observe the fax itself, so this is you telling it the form was sent. A `ready_to_file` application may also be marked filed directly, for the operator who prepares and sends it without e-signature.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The application is marked filed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "application": {
                          "$ref": "#/components/schemas/EinApplication"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ein-applications/{id}/complete": {
      "post": {
        "operationId": "completeEinApplication",
        "tags": [
          "Incorporations"
        ],
        "summary": "Record the issued EIN (write scope)",
        "description": "Records the EIN the IRS issued and propagates it: onto the legal entity (only when that entity has no tax id yet — an existing, different one is never overwritten) and onto the company record held with the filing partner.\n\nIdempotent for the same EIN: a retry re-runs the propagation rather than failing, which matters because a first attempt can record the number and still fail to propagate it. A DIFFERENT EIN is refused — a recorded EIN is never silently replaced.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "EIN application id, from listEinApplications or the incorporation response.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ein"
                ],
                "properties": {
                  "ein": {
                    "type": "string",
                    "pattern": "^\\d{2}-?\\d{7}$",
                    "description": "12-3456789 or 123456789."
                  }
                }
              },
              "example": {
                "ein": "12-3456789"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The EIN is recorded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "application": {
                          "$ref": "#/components/schemas/EinApplication"
                        },
                        "entityTaxIdSet": {
                          "type": "boolean",
                          "description": "True when this call wrote the EIN onto the entity. False when there is no entity yet, or it already carried a tax id."
                        },
                        "companyRecordUpdated": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/filings": {
      "get": {
        "operationId": "listFilings",
        "tags": [
          "Incorporations"
        ],
        "summary": "Filings linked to an entity",
        "description": "Filing orders attached to a legal entity, newest first — the formation once filed, registered-agent service, annual reports, EIN. Defaults to the tenant's primary entity; pass entity_id for another. Exception code/reason are populated when a filing hit an exception.",
        "parameters": [
          {
            "name": "entity_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Entity UUID from GET /entities. Defaults to the primary entity."
          }
        ],
        "responses": {
          "200": {
            "description": "Filings, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Filing"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "orderId": "ord_a1b2c3d4e5f6a7b8",
                      "orderType": "formation",
                      "entityId": "3f9c1e0a-8b2d-4e6f-9a01-5c7d2b8e4f10",
                      "filingState": "DE",
                      "filingStatus": "filed",
                      "subscriptionStatus": null,
                      "filingDate": "2026-08-24",
                      "exceptionCode": null,
                      "exceptionReason": null,
                      "exceptionMessage": null,
                      "createdAt": "2026-08-19T18:04:11.000Z",
                      "updatedAt": "2026-08-24T09:12:45.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
