{"openapi":"3.1.0","info":{"title":"GET /api/v1/reports/subledger-gl-reconciliation","version":"1.0.0","description":"Sub-ledger to GL reconciliation"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/reports/subledger-gl-reconciliation":{"get":{"tags":["reports"],"summary":"Sub-ledger to GL reconciliation","description":"Compare AR/AP sub-ledger open balances against their GL control-account balances, as of a date, with one row per customer and per vendor.","operationId":"get_subledger_gl_reconciliation","parameters":[{"name":"as_of_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"description":"Balances and open documents as of this date (default today).","title":"As Of Date"},"description":"Balances and open documents as of this date (default today)."},{"name":"parent_ledger_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Reconcile only this control account (and its sub-ledgers); a liability ledger is read as the payables side.","title":"Parent Ledger Id"},"description":"Reconcile only this control account (and its sub-ledgers); a liability ledger is read as the payables side."},{"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_SubledgerGlReconciliationResponse_"}}}},"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_subledger_gl_reconciliation_api_v1_reports_subledger_gl_reconciliation_get"}}},"components":{"schemas":{"SubledgerGlExplanation":{"properties":{"tag":{"type":"string","enum":["fee_shortfall","unapplied_credit","unposted_payment","rounding"],"title":"Tag","description":"fee_shortfall: an invoice short by exactly a processor fee on a processor deposit; unapplied_credit: an issued credit memo or vendor credit not yet applied; unposted_payment: a payment whose bank transaction has no journal entry; rounding: a cent or so per open document."},"amount_cents":{"type":"integer","title":"Amount Cents","description":"Cents this cause accounts for."},"document_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Document Id","description":"Invoice, bill or credit the cause sits on."},"document_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Document Number","description":"Its number."},"matches_difference":{"type":"boolean","title":"Matches Difference","description":"True when this cause (or all causes with this tag) equals the row's difference, within a cent.","default":false},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note","description":"What to do about it."}},"type":"object","required":["tag","amount_cents"],"title":"SubledgerGlExplanation","description":"A known cause of (part of) a row's difference."},"SubledgerGlReconciliationResponse":{"properties":{"generated_at":{"type":"string","format":"date-time","title":"Generated At","description":"Timestamp when reconciliation was computed."},"as_of_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"As Of Date","description":"Date the balances and open documents are taken at."},"parent_ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Ledger Id","description":"Control account reconciled, when one was asked for."},"ar":{"$ref":"#/components/schemas/SubledgerGlSectionResponse","description":"Accounts receivable sub-ledger vs AR control account."},"ap":{"$ref":"#/components/schemas/SubledgerGlSectionResponse","description":"Accounts payable sub-ledger vs AP control account."},"rows":{"items":{"$ref":"#/components/schemas/SubledgerGlReconciliationRow"},"type":"array","title":"Rows","description":"Per customer (AR) and per vendor (AP), largest difference first."}},"type":"object","required":["generated_at","ar","ap"],"title":"SubledgerGlReconciliationResponse","description":"AR/AP sub-ledger to GL control-account reconciliation snapshot."},"SubledgerGlReconciliationRow":{"properties":{"kind":{"type":"string","enum":["customer","vendor"],"title":"Kind"},"customer_or_vendor":{"type":"string","title":"Customer Or Vendor","description":"Name; lines no document explains share one row."},"party_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Party Id","description":"Customer or vendor UUID; null for unattributed lines."},"subledger_ledger_ids":{"items":{"type":"string"},"type":"array","title":"Subledger Ledger Ids","description":"The party's own sub-ledgers ('AR - <Customer>') that hold lines."},"subledger_balance_cents":{"type":"integer","title":"Subledger Balance Cents","description":"The party's balance in the GL as of the date (its sub-ledger plus its lines on the control account), natural sign."},"open_documents_cents":{"type":"integer","title":"Open Documents Cents","description":"Open invoices (or bills) as of the date."},"difference_cents":{"type":"integer","title":"Difference Cents","description":"subledger_balance_cents minus open_documents_cents."},"explanations":{"items":{"$ref":"#/components/schemas/SubledgerGlExplanation"},"type":"array","title":"Explanations"}},"type":"object","required":["kind","customer_or_vendor","subledger_balance_cents","open_documents_cents","difference_cents"],"title":"SubledgerGlReconciliationRow","description":"One customer's (or vendor's) GL balance against its open documents."},"SubledgerGlSectionResponse":{"properties":{"subledger_open_balance_cents":{"type":"integer","title":"Subledger Open Balance Cents","description":"Open-balance total from the sub-ledger in cents."},"gl_control_balance_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Gl Control Balance Cents","description":"Control-account balance from the GL in cents, including its sub-ledgers (e.g. 'AR - <Customer>'), normalized to natural sign."},"difference_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Difference Cents","description":"Sub-ledger minus GL control balance in cents."},"is_reconciled":{"type":"boolean","title":"Is Reconciled","description":"True when sub-ledger and GL balances match exactly."},"control_ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Control Ledger Id","description":"Control ledger UUID when one is configured."},"control_ledger_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Control Ledger Name","description":"Control ledger display name when one is configured."},"control_ledger_system_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Control Ledger System Key","description":"Control ledger system key (for example, accounts_receivable)."},"control_ledger_normal_balance":{"anyOf":[{"type":"string","enum":["debit","credit"]},{"type":"null"}],"title":"Control Ledger Normal Balance","description":"Normal-balance side for the control ledger."}},"type":"object","required":["subledger_open_balance_cents","is_reconciled"],"title":"SubledgerGlSectionResponse","description":"One side of sub-ledger versus GL control-account reconciliation."},"SuccessEnvelope_SubledgerGlReconciliationResponse_":{"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/SubledgerGlReconciliationResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[SubledgerGlReconciliationResponse]"},"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":[]}]}