{"openapi":"3.1.0","info":{"title":"GET /api/v1/credit/finance/tie-out","version":"1.0.0","description":"Tie out outstanding three ways"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/finance/tie-out":{"get":{"tags":["credit"],"summary":"Tie out outstanding three ways","description":"Outstanding from the loan tape, from the ledger registers, and from the GL receivable accounts, with the difference and `ties` for each pair and a per-line comparison of tape and register.","operationId":"get_tie_out","parameters":[{"name":"as_of","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"description":"Defaults to today (UTC).","title":"As Of"},"description":"Defaults to today (UTC)."},{"name":"program_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Program Id"}},{"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_TieOutResponse_"}}}},"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_tie_out_api_v1_credit_finance_tie_out_get"}}},"components":{"schemas":{"SuccessEnvelope_TieOutResponse_":{"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/TieOutResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[TieOutResponse]"},"TieOutGLAccount":{"properties":{"ledger_id":{"type":"string","title":"Ledger Id"},"account":{"type":"string","title":"Account"},"balance_cents":{"type":"integer","title":"Balance Cents","description":"Debits minus credits through as_of."}},"type":"object","required":["ledger_id","account","balance_cents"],"title":"TieOutGLAccount","description":"One receivable account's balance in the general ledger."},"TieOutLineRow":{"properties":{"credit_line_id":{"type":"string","title":"Credit Line Id"},"external_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Line Id"},"loan_tape_cents":{"type":"integer","title":"Loan Tape Cents"},"ledger_cents":{"type":"integer","title":"Ledger Cents"},"difference_cents":{"type":"integer","title":"Difference Cents"},"ties":{"type":"boolean","title":"Ties"}},"type":"object","required":["credit_line_id","loan_tape_cents","ledger_cents","difference_cents","ties"],"title":"TieOutLineRow","description":"The loan tape and the ledger register for one line."},"TieOutPair":{"properties":{"left":{"type":"string","title":"Left"},"right":{"type":"string","title":"Right"},"left_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Left Cents"},"right_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Right Cents"},"difference_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Difference Cents","description":"Left minus right. Null when the pair does not apply."},"ties":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Ties","description":"Null when one side does not exist (no GL posting)."}},"type":"object","required":["left","right"],"title":"TieOutPair","description":"Two of the three figures compared."},"TieOutResponse":{"properties":{"as_of":{"type":"string","format":"date","title":"As Of"},"program_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Program Id"},"loan_tape_cents":{"type":"integer","title":"Loan Tape Cents","description":"Outstanding summed over the loan tape (every loan's balance today)."},"ledger_cents":{"type":"integer","title":"Ledger Cents","description":"Every line's register balance: its entries dated on or before as_of."},"gl_posting_enabled":{"type":"boolean","title":"Gl Posting Enabled","description":"Every program in scope posts to the GL, so the GL figure applies."},"gl_scope":{"type":"string","enum":["program_entries","account_balance"],"title":"Gl Scope","description":"program_entries: only the entries the named program posted. account_balance: the receivable accounts' whole balance."},"gl_receivable_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Gl Receivable Cents"},"gl_accounts":{"items":{"$ref":"#/components/schemas/TieOutGLAccount"},"type":"array","title":"Gl Accounts"},"pairs":{"items":{"$ref":"#/components/schemas/TieOutPair"},"type":"array","title":"Pairs"},"ties":{"type":"boolean","title":"Ties","description":"Every pair that applies ties."},"lines":{"items":{"$ref":"#/components/schemas/TieOutLineRow"},"type":"array","title":"Lines"}},"type":"object","required":["as_of","loan_tape_cents","ledger_cents","gl_posting_enabled","gl_scope","ties"],"title":"TieOutResponse","description":"Outstanding three ways, and whether they agree."},"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":[]}]}