{"openapi":"3.1.0","info":{"title":"GET /api/v1/businesses/{business_id}/cash-flow-statement/periodic","version":"1.0.0","description":"Get cash flow statements for multiple periods"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/businesses/{business_id}/cash-flow-statement/periodic":{"get":{"tags":["businesses"],"summary":"Get cash flow statements for multiple periods","description":"Batch endpoint returning a cash flow statement for each period in the requested date range. Avoids N round-trips for monthly, quarterly and yearly views. All amounts in cents.","operationId":"get_cash_flow_statements_periodic","parameters":[{"name":"business_id","in":"path","required":true,"schema":{"type":"string","title":"Business Id"}},{"name":"start_date","in":"query","required":true,"schema":{"type":"string","format":"date","description":"Start date (YYYY-MM-DD)","title":"Start Date"},"description":"Start date (YYYY-MM-DD)"},{"name":"end_date","in":"query","required":true,"schema":{"type":"string","format":"date","description":"End date (YYYY-MM-DD)","title":"End Date"},"description":"End date (YYYY-MM-DD)"},{"name":"grouping","in":"query","required":false,"schema":{"type":"string","pattern":"^(monthly|quarterly|yearly)$","description":"Period grouping: 'monthly', 'quarterly' or 'yearly'","default":"monthly","title":"Grouping"},"description":"Period grouping: 'monthly', 'quarterly' or 'yearly'"},{"name":"hide_zero_rows","in":"query","required":false,"schema":{"type":"boolean","description":"Exclude line items with zero cash impact","default":false,"title":"Hide Zero Rows"},"description":"Exclude line items with zero cash impact"},{"name":"basis","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis. On the cash basis Net Income is cash-basis net income and AR/AP carry no balance.","title":"Basis"},"description":"Accounting basis: `accrual` or `cash`. Defaults to the business's configured basis. On the cash basis Net Income is cash-basis net income and AR/AP carry no balance."},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_GetCashFlowStatementsPeriodicResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"get_cash_flow_statements_periodic_api_v1_businesses__business_id__cash_flow_statement_periodic_get"}}},"components":{"schemas":{"CashFlowLedgerDetail":{"properties":{"ledger_id":{"type":"string","title":"Ledger Id","description":"Ledger UUID"},"ledger_name":{"type":"string","title":"Ledger Name","description":"Chart-of-accounts name"},"change":{"type":"integer","title":"Change","description":"This ledger's signed contribution to the row (cents)"}},"type":"object","required":["ledger_id","ledger_name","change"],"title":"CashFlowLedgerDetail","description":"One chart-of-accounts row contributing to a statement line item.\n\nThe ``change`` values of a line item's breakdown always sum to the\nline item's own ``change``, so exports can render the ledgers as\nindented children of the total without the two disagreeing."},"CashFlowLineItem":{"properties":{"ledger_id":{"type":"string","title":"Ledger Id","description":"Stable identifier for this row"},"ledger_name":{"type":"string","title":"Ledger Name","description":"Human label shown to the reader"},"external_ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Ledger Id","description":"External ledger ID if this row corresponds to a single externally linked account; null for synthetic indirect-method rows."},"change":{"type":"integer","title":"Change","description":"Signed amount for this row in cents"},"cfs_class":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cfs Class","description":"Source ``cfs_class`` aggregation key for this row (e.g. 'ar', 'ppe'); null for opener / subtotal rows."},"ledger_breakdown":{"items":{"$ref":"#/components/schemas/CashFlowLedgerDetail"},"type":"array","title":"Ledger Breakdown","description":"Chart-of-accounts rows that make up this line. Their ``change`` values sum to this row's ``change``. Empty when the row has no ledger-level detail."}},"type":"object","required":["ledger_id","ledger_name","change"],"title":"CashFlowLineItem","description":"A single line on the Statement of Cash Flows.\n\nEach line has a stable string identifier (``ledger_id``) so the\nfrontend can key React components and treat synthetic rows\nconsistently with real-ledger rows. For indirect-method rows the\nid has the shape ``\"indirect:<key>\"`` (e.g. ``\"indirect:net_income\"``,\n``\"indirect:ar\"``, ``\"indirect:da\"``); for ledger-level rows it's\nthe ledger UUID. ``ledger_name`` is the human-readable label."},"CashFlowPeriodicPeriod":{"properties":{"start_date":{"type":"string","title":"Start Date"},"end_date":{"type":"string","title":"End Date"}},"additionalProperties":true,"type":"object","required":["start_date","end_date"],"title":"CashFlowPeriodicPeriod","description":"Date range for one periodic cash-flow statement."},"CashFlowSection":{"properties":{"name":{"type":"string","title":"Name","description":"Section name"},"line_items":{"items":{"$ref":"#/components/schemas/CashFlowLineItem"},"type":"array","title":"Line Items","description":"Line items in this section"},"total":{"type":"integer","title":"Total","description":"Net cash flow for this section (cents)","default":0}},"type":"object","required":["name"],"title":"CashFlowSection","description":"Operating / Investing / Financing section of the statement."},"CashFlowStatement":{"properties":{"business_id":{"type":"string","title":"Business Id","description":"Business ID"},"business_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Business Name","description":"Business name"},"start_date":{"type":"string","format":"date","title":"Start Date","description":"Report start date"},"end_date":{"type":"string","format":"date","title":"End Date","description":"Report end date"},"generated_at":{"type":"string","format":"date-time","title":"Generated At","description":"When the report was generated"},"method":{"type":"string","const":"indirect","title":"Method","description":"Construction method. The indirect method is canonical.","default":"indirect"},"basis":{"type":"string","enum":["accrual","cash"],"title":"Basis","description":"Accounting basis the statement is built on. On the cash basis Net Income is cash-basis net income and AR/AP carry no balance.","default":"accrual"},"net_income":{"type":"integer","title":"Net Income","description":"Net Income (accrual) for the period in cents. Also appears as the first line item of ``operating_activities``."},"operating_activities":{"$ref":"#/components/schemas/CashFlowSection","description":"Section A — operating activities"},"investing_activities":{"$ref":"#/components/schemas/CashFlowSection","description":"Section B — investing activities"},"financing_activities":{"$ref":"#/components/schemas/CashFlowSection","description":"Section C — financing activities"},"net_cash_from_operating":{"type":"integer","title":"Net Cash From Operating","description":"Subtotal of Section A (cents)"},"net_cash_from_investing":{"type":"integer","title":"Net Cash From Investing","description":"Subtotal of Section B (cents)"},"net_cash_from_financing":{"type":"integer","title":"Net Cash From Financing","description":"Subtotal of Section C (cents)"},"net_change_in_cash":{"type":"integer","title":"Net Change In Cash","description":"Sum of Sections A+B+C (cents)"},"beginning_cash":{"type":"integer","title":"Beginning Cash","description":"Σ beginning natural balance for cfs_class='cash' (cents)"},"ending_cash":{"type":"integer","title":"Ending Cash","description":"Beginning cash + Net change in cash (cents)"},"supplemental_disclosures":{"$ref":"#/components/schemas/SupplementalDisclosures","description":"ASC 230 supplemental disclosures"},"validation_results":{"items":{"$ref":"#/components/schemas/CashFlowValidationResult"},"type":"array","title":"Validation Results","description":"Outcome of §5 validation rules"},"validation_passed":{"type":"boolean","title":"Validation Passed","description":"True iff every §5 validation rule passed","default":true},"warnings":{"items":{"type":"string"},"type":"array","title":"Warnings","description":"Non-fatal accuracy warnings. Validation failures are duplicated here so legacy callers that ignore ``validation_results`` still see the diagnostic."}},"type":"object","required":["business_id","start_date","end_date","net_income","operating_activities","investing_activities","financing_activities","net_cash_from_operating","net_cash_from_investing","net_cash_from_financing","net_change_in_cash","beginning_cash","ending_cash"],"title":"CashFlowStatement","description":"Indirect-method Statement of Cash Flows for one period.\n\nSection A (Operating) walks Net Income through non-cash add-backs\nand working-capital changes to Net Cash from Operating Activities.\nSections B (Investing) and C (Financing) carry the corresponding\nbalance deltas on long-term assets, debt, and equity. Section D\n(Reconciliation) is exposed as ``net_change_in_cash`` /\n``beginning_cash`` / ``ending_cash``.\n\nThe §5 validation results are attached so callers can render a\nPASS/FAIL banner without re-deriving the checks."},"CashFlowValidationResult":{"properties":{"rule":{"type":"string","title":"Rule","description":"Stable rule identifier"},"passed":{"type":"boolean","title":"Passed","description":"Whether the rule was satisfied"},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message","description":"Human-readable detail when the rule failed"}},"type":"object","required":["rule","passed"],"title":"CashFlowValidationResult","description":"Outcome of one §5 validation rule applied to a generated statement.\n\nA rule passes when its condition holds within the spec's tolerance\n(typically $1 / 100 cents). Failed rules carry a human-readable\nmessage that explains the gap and any remediation. The full list of\nrules is reported on every statement -- a \"PASS\" report shows them\nall green, a \"FAIL\" shows the failing ones with detail."},"GetCashFlowStatementsPeriodicResponse":{"properties":{"grouping":{"type":"string","enum":["monthly","quarterly","yearly"],"title":"Grouping"},"periods":{"items":{"$ref":"#/components/schemas/CashFlowPeriodicPeriod"},"type":"array","title":"Periods"},"statements":{"items":{"$ref":"#/components/schemas/CashFlowStatement"},"type":"array","title":"Statements"}},"additionalProperties":true,"type":"object","required":["grouping","periods","statements"],"title":"GetCashFlowStatementsPeriodicResponse","description":"Response for ``get_cash_flow_statements_periodic``."},"IndirectReconciliationItem":{"properties":{"label":{"type":"string","title":"Label","description":"Description of the adjustment"},"amount":{"type":"integer","title":"Amount","description":"Adjustment amount (cents)"}},"type":"object","required":["label","amount"],"title":"IndirectReconciliationItem","description":"Legacy memo line preserved for backwards-compat with callers that\nconsumed the ASC 230 indirect reconciliation as a separate list.\n\nUnder the indirect method this content lives on\n``operating_activities.line_items`` directly; the supplemental memo\nre-emits the same data so existing UI/AI consumers keep working."},"NonCashActivity":{"properties":{"description":{"type":"string","title":"Description","description":"Description of the activity"},"amount":{"type":"integer","title":"Amount","description":"Amount of the activity (cents)"},"category":{"type":"string","pattern":"^(investing|financing)$","title":"Category","description":"'investing' or 'financing'"}},"type":"object","required":["description","amount","category"],"title":"NonCashActivity","description":"A non-cash investing or financing activity (ASC 230 disclosure)."},"SuccessEnvelope_GetCashFlowStatementsPeriodicResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/GetCashFlowStatementsPeriodicResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[GetCashFlowStatementsPeriodicResponse]"},"SupplementalDisclosures":{"properties":{"cash_paid_for_interest":{"type":"integer","title":"Cash Paid For Interest","description":"Cash paid for interest during the period (cents)","default":0},"cash_paid_for_income_taxes":{"type":"integer","title":"Cash Paid For Income Taxes","description":"Cash paid for income taxes during the period (cents)","default":0},"indirect_reconciliation":{"items":{"$ref":"#/components/schemas/IndirectReconciliationItem"},"type":"array","title":"Indirect Reconciliation","description":"Mirror of the operating-section line items as a flat label/amount list; preserved for backwards compatibility with consumers built against the prior schema."},"non_cash_activities":{"items":{"$ref":"#/components/schemas/NonCashActivity"},"type":"array","title":"Non Cash Activities","description":"Significant non-cash investing and financing activities"}},"type":"object","title":"SupplementalDisclosures","description":"ASC 230 supplemental disclosures.\n\nEven under the indirect method, businesses must disclose cash paid\nfor interest and income taxes, plus significant non-cash investing\nand financing activities. We surface those here."},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}