{"openapi":"3.1.0","info":{"title":"GET /api/v1/credit/lines/{credit_line_id}/statements/{cycle_id}","version":"1.0.0","description":"Get a rendered statement"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/lines/{credit_line_id}/statements/{cycle_id}":{"get":{"tags":["credit"],"summary":"Get a rendered statement","description":"The statement document for one period: the roll-forward, every loan on it with its term, due date, interest and payments, and the amount due. `format=pdf` returns the document carrying the program's branding and lending entity; `format=csv` returns the transaction-level spreadsheet; `format=html` the printable page. The partner provides the download affordance and nothing else. The issued part is the snapshot written at close and never changes; `since_statement` lists what has touched the statement's loans since it was issued and ends in what they owe now. `view=issued` (the default for json, pdf and html) returns the loan rows as issued; `view=current` (the default for csv) recomputes them from today's records. pdf and html are always the issued document.","operationId":"get_statement","parameters":[{"name":"credit_line_id","in":"path","required":true,"schema":{"type":"string","title":"Credit Line Id"}},{"name":"cycle_id","in":"path","required":true,"schema":{"type":"string","title":"Cycle Id"}},{"name":"format","in":"query","required":false,"schema":{"enum":["json","html","pdf","csv"],"type":"string","description":"json (the default): the statement as data. html, pdf: the issued document. csv: the transaction-level spreadsheet.","default":"json","title":"Format"},"description":"json (the default): the statement as data. html, pdf: the issued document. csv: the transaction-level spreadsheet."},{"name":"view","in":"query","required":false,"schema":{"anyOf":[{"type":"string","enum":["issued","current"]},{"type":"null"}],"description":"issued: the loan rows exactly as the statement was issued. current: recomputed from today's records. Defaults to current for csv and issued otherwise; current is refused for pdf and html (CREDIT_641), and any other value is CREDIT_640.","title":"View"},"description":"issued: the loan rows exactly as the statement was issued. current: recomputed from today's records. Defaults to current for csv and issued otherwise; current is refused for pdf and html (CREDIT_641), and any other value is CREDIT_640."},{"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":"The statement: the JSON envelope, or with `format` the printable page (`text/html`), the spreadsheet (`text/csv`) or the document (`application/pdf`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_StatementDocumentResponse_"}},"text/html":{"schema":{"type":"string"}},"text/csv":{"schema":{"type":"string"}},"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"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_statement_api_v1_credit_lines__credit_line_id__statements__cycle_id__get"}}},"components":{"schemas":{"CardSettlementResponse":{"properties":{"id":{"type":"string","title":"Id"},"external_settlement_id":{"type":"string","title":"External Settlement Id"},"cycle_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cycle Id"},"settled_on":{"type":"string","format":"date","title":"Settled On"},"amount_cents":{"type":"integer","title":"Amount Cents"},"merchant_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Name"},"card_last_four":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Card Last Four"},"merchant_category_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Category Code"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"source":{"type":"string","title":"Source"},"loan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Loan Id"},"refund_disposition":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Refund Disposition"},"status":{"type":"string","enum":["cleared","disputed","voided","reversed"],"title":"Status","description":"What the issuer side says about the transaction now.","default":"cleared"}},"type":"object","required":["id","external_settlement_id","settled_on","amount_cents","source"],"title":"CardSettlementResponse","description":"A settlement line item in the activity list (§7.2)."},"CycleStatusEnum":{"type":"string","enum":["open","closed","issued","paid","late","written_off"],"title":"CycleStatusEnum","description":"Cycle state per FRD §10.5.\n\n* ``open`` — collecting settlements; no draw exists yet. Merchant sees\n  activity but nothing is owed (this interval is the float).\n* ``closed`` — draw created; interest and fees computed. Statement pending.\n* ``issued`` — statement generated and available; amount due and due date shown.\n* ``paid`` — outstanding reduced to zero, *including* accrued interest.\n* ``late`` — past due date with an amount outstanding.\n* ``written_off`` — charged off per collections policy."},"LendingModel":{"type":"string","enum":["per_transaction","cycle_draw"],"title":"LendingModel","description":"What the unit of borrowing is.\n\n* ``per_transaction`` — every posted card transaction originates its\n  own loan with its own term, due date, fee, and daily accrual after\n  the due date. The monthly statement is a presentation wrapper and\n  the moment accrued interest is applied. This is the Tie model\n  (FRD v2 §10.5, D-01).\n* ``cycle_draw`` — settlements accumulate into a monthly cycle that\n  resolves into one draw at close, carrying one term, one due date,\n  and one interest figure. The credit-card model FRD v1 specified.\n\nA program picks one. Lines inherit it, and every engine branch keys\non it, so a second partner on the other model is a row, not a build."},"LoanStatusEnum":{"type":"string","enum":["active","past_due","paid","written_off","voided","reversed"],"title":"LoanStatusEnum","description":"Per-transaction loan state (FRD v2 §10.5 status vocabulary).\n\nThe API status is authoritative; a client must not compute it from\ndates or balances.\n\n* ``paid`` — the merchant paid it off (payments, refund credits or\n  operator adjustments brought it to zero).\n* ``voided`` — the issuer voided the transaction: the loan was taken off\n  as if it never cleared. Nothing was owed or collected for it; anything\n  paid towards it went to the credit balance.\n* ``reversed`` — a dispute the merchant won took the loan to zero before\n  anything was paid on it."},"RollForwardResponse":{"properties":{"previous_balance_cents":{"type":"integer","title":"Previous Balance Cents"},"new_purchases_cents":{"type":"integer","title":"New Purchases Cents"},"fees_cents":{"type":"integer","title":"Fees Cents"},"interest_cents":{"type":"integer","title":"Interest Cents"},"payments_cents":{"type":"integer","title":"Payments Cents"},"statement_balance_cents":{"type":"integer","title":"Statement Balance Cents"}},"type":"object","required":["previous_balance_cents","new_purchases_cents","fees_cents","interest_cents","payments_cents","statement_balance_cents"],"title":"RollForwardResponse","description":"The statement summary band as one equation (§7.1)."},"SinceStatement":{"properties":{"as_of":{"type":"string","format":"date","title":"As Of","description":"Today (UTC): the date of Outstanding now."},"issued_balance_cents":{"type":"integer","title":"Issued Balance Cents","description":"Where the section starts: the loan rows' outstanding as issued (per-transaction) or the amount due as issued (cycle-draw)."},"items":{"items":{"$ref":"#/components/schemas/SinceStatementItem"},"type":"array","title":"Items","description":"Oldest first; interest last."},"outstanding_now_cents":{"type":"integer","title":"Outstanding Now Cents","description":"What the statement's loans (cycle-draw: the period's draw) owe today: issued_balance_cents plus every item."},"statement_paid_cents":{"type":"integer","title":"Statement Paid Cents","description":"Of the issued balance, how much has been retired since. Money after the period goes to each loan's issued balance first and only the rest to interest charged later."},"statement_remaining_cents":{"type":"integer","title":"Statement Remaining Cents","description":"Of the issued balance, what is still unpaid."}},"type":"object","required":["as_of","issued_balance_cents","outstanding_now_cents","statement_paid_cents","statement_remaining_cents"],"title":"SinceStatement","description":"Everything after the statement, ending in what its loans owe now."},"SinceStatementItem":{"properties":{"date":{"type":"string","format":"date","title":"Date","description":"When it took effect. A backdated payment carries its own date, which can be inside the statement period."},"kind":{"type":"string","enum":["payment","payment_reversal","refund","credit","adjustment","write_off","dispute_hold","dispute_resolution","late_charge","interest","recalculation"],"title":"Kind","description":"payment, payment_reversal, refund, credit (carried-forward credit applied, or withdrawn when its payment was returned), adjustment (fee or interest waived, goodwill credit), write_off, dispute_hold (a hold placed; no amount), dispute_resolution, late_charge (cycle-draw), interest (charged since the period end, net of any recalculation) or recalculation (a change no single record explains)."},"description":{"type":"string","title":"Description","description":"One line, as the document prints it."},"amount_cents":{"type":"integer","title":"Amount Cents","description":"Negative reduces what is owed, positive adds to it."},"loan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Loan Id","description":"The statement's loan it touched, when one."},"external_settlement_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Settlement Id","description":"The issuer's id for that loan's transaction."},"reference":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reference","description":"The record behind it: the partner's payment id, the refund's settlement id, the adjustment, dispute or ledger entry id."}},"type":"object","required":["date","kind","description","amount_cents"],"title":"SinceStatementItem","description":"One thing that changed a statement's loans after it was issued."},"StatementDocumentResponse":{"properties":{"cycle_id":{"type":"string","title":"Cycle Id"},"credit_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Credit Line Id"},"lending_model":{"$ref":"#/components/schemas/LendingModel","default":"per_transaction"},"period_start":{"type":"string","format":"date","title":"Period Start"},"period_end":{"type":"string","format":"date","title":"Period End"},"closed_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Closed On"},"issued_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Issued On"},"due_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Due Date"},"status":{"anyOf":[{"$ref":"#/components/schemas/CycleStatusEnum"},{"type":"null"}]},"period_status":{"anyOf":[{"type":"string","enum":["open","paid"]},{"type":"null"}],"title":"Period Status"},"amount_due_cents":{"type":"integer","title":"Amount Due Cents"},"statement_balance_cents":{"type":"integer","title":"Statement Balance Cents","default":0},"paid_cents":{"type":"integer","title":"Paid Cents","default":0},"outstanding_cents":{"type":"integer","title":"Outstanding Cents","default":0},"on_hold_cents":{"type":"integer","title":"On Hold Cents","description":"The part of outstanding_cents on loans on hold now.","default":0},"roll_forward":{"$ref":"#/components/schemas/RollForwardResponse"},"loans":{"items":{"$ref":"#/components/schemas/StatementLoanRow"},"type":"array","title":"Loans"},"settlements":{"items":{"$ref":"#/components/schemas/CardSettlementResponse"},"type":"array","title":"Settlements"},"legal_lending_entity":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Legal Lending Entity"},"branding":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Branding"},"merchant_reference":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Reference"},"format":{"type":"string","enum":["json","html","pdf","csv"],"title":"Format","default":"json"},"html":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Html"},"download_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Download Url"},"spreadsheet_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Spreadsheet Url"},"view":{"type":"string","enum":["issued","current"],"title":"View","description":"issued: the loan rows exactly as the statement was issued. current: the rows recomputed from today's records (the CSV default).","default":"issued"},"issued":{"anyOf":[{"$ref":"#/components/schemas/StatementIssuedInfo"},{"type":"null"}],"description":"The snapshot behind the issued part."},"terms":{"anyOf":[{"$ref":"#/components/schemas/StatementTerms"},{"type":"null"}],"description":"The terms the statement was issued under."},"since_statement":{"anyOf":[{"$ref":"#/components/schemas/SinceStatement"},{"type":"null"}],"description":"What has touched the statement's loans since it was issued."}},"type":"object","required":["cycle_id","period_start","period_end","amount_due_cents","roll_forward"],"title":"StatementDocumentResponse","description":"A rendered statement.\n\nThe partner provides the download affordance and nothing else: no\npagination, no layout, no statement arithmetic (§8). Request\n``format=pdf`` for the document or ``format=csv`` for the spreadsheet.\n\nThe issued part (period, balances, roll-forward, loan rows, lender\nidentity and branding) comes from the snapshot written at close and\nnever changes. ``status``, ``period_status``, ``paid_cents``,\n``outstanding_cents`` and ``on_hold_cents`` are today's figures, and\n``since_statement`` lists what has happened to the statement's loans\nsince it was issued."},"StatementIssuedInfo":{"properties":{"snapshot_version":{"type":"integer","title":"Snapshot Version","description":"Version of the stored snapshot's layout. Currently 1."},"reconstructed":{"type":"boolean","title":"Reconstructed","description":"True when the period closed before snapshots existed and the snapshot was rebuilt from the records afterwards. The figures are the period-end position as the records show it, not a copy of the document sent at the time."},"ties":{"type":"boolean","title":"Ties","description":"True when the loan rows sum to the totals frozen on the period at close. False is logged and investigated; the snapshot is kept."},"captured_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Captured At","description":"When the snapshot was written (UTC)."}},"type":"object","required":["snapshot_version","reconstructed","ties"],"title":"StatementIssuedInfo","description":"Where the issued part of a statement document comes from."},"StatementLoanRow":{"properties":{"loan_id":{"type":"string","title":"Loan Id"},"external_settlement_id":{"type":"string","title":"External Settlement Id"},"transaction_date":{"type":"string","format":"date","title":"Transaction Date"},"merchant_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Name"},"card_last_four":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Card Last Four"},"principal_cents":{"type":"integer","title":"Principal Cents"},"disbursement_fee_cents":{"type":"integer","title":"Disbursement Fee Cents"},"term_days":{"type":"integer","title":"Term Days"},"due_date":{"type":"string","format":"date","title":"Due Date"},"status":{"$ref":"#/components/schemas/LoanStatusEnum"},"interest_applied_cents":{"type":"integer","title":"Interest Applied Cents","description":"Interest applied to this loan at this close.","default":0},"interest_accrued_cents":{"type":"integer","title":"Interest Accrued Cents","description":"Accrued through the period end.","default":0},"principal_paid_cents":{"type":"integer","title":"Principal Paid Cents","description":"Principal paid from origination to the period end.","default":0},"fee_paid_cents":{"type":"integer","title":"Fee Paid Cents","description":"Fee paid from origination to the period end.","default":0},"interest_paid_cents":{"type":"integer","title":"Interest Paid Cents","description":"Interest paid from origination to the period end.","default":0},"principal_paid_this_period_cents":{"type":"integer","title":"Principal Paid This Period Cents","description":"Principal paid by payments dated inside this statement period. The previous statement's `principal_paid_cents` plus this figure equals this statement's.","default":0},"fee_paid_this_period_cents":{"type":"integer","title":"Fee Paid This Period Cents","description":"Fee paid by payments dated inside this statement period.","default":0},"interest_paid_this_period_cents":{"type":"integer","title":"Interest Paid This Period Cents","description":"Interest paid by payments dated inside this statement period.","default":0},"adjustments_this_period_cents":{"type":"integer","title":"Adjustments This Period Cents","description":"Fee waived, interest waived and goodwill credited by operator adjustments effective inside this statement period. Never counted in the paid columns.","default":0},"outstanding_cents":{"type":"integer","title":"Outstanding Cents","description":"As at the period end.","default":0},"originated_this_period":{"type":"boolean","title":"Originated This Period","default":false},"on_hold":{"type":"boolean","title":"On Hold","description":"Issued view: the loan was on hold when the statement was issued. Current view: it is on hold now.","default":false},"hold_status":{"type":"string","enum":["none","disputed","voided"],"title":"Hold Status","default":"none"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"The card transaction's description. Issued view only."},"credits_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Credits Cents","description":"Refund credit applied to the loan as issued. Issued view only."},"written_off_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Written Off Cents","description":"Principal written off as issued. Issued view only."},"reversed_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Reversed Cents","description":"Principal, fee and interest a dispute resolution took off the loan, as issued. Issued view only."},"principal_outstanding_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Principal Outstanding Cents","description":"Unpaid principal as issued. Issued view only."},"fee_outstanding_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Fee Outstanding Cents","description":"Unpaid fee as issued. Issued view only."},"interest_outstanding_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Interest Outstanding Cents","description":"Unpaid interest as issued. Issued view only."}},"type":"object","required":["loan_id","external_settlement_id","transaction_date","principal_cents","disbursement_fee_cents","term_days","due_date","status"],"title":"StatementLoanRow","description":"One transaction on a statement, with its loan and period activity (§8.2)."},"StatementTerms":{"properties":{"lending_model":{"type":"string","title":"Lending Model","description":"per_transaction or cycle_draw."},"rate_bps":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rate Bps","description":"Annual interest rate on the line at close, in bps."},"term_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Term Days","description":"Repayment term on the line at close, in days."},"disbursement_fee_bps":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Disbursement Fee Bps","description":"Disbursement fee on the line at close, in bps."},"interest_accrual_start":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Interest Accrual Start","description":"due_date (interest from the day after the due date) or origination."},"grace_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Grace Days","description":"Days after the due date before interest accrues."},"statement_balance_mode":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Statement Balance Mode","description":"cumulative or cycle_scoped (cycle-draw roll-forward)."}},"type":"object","required":["lending_model"],"title":"StatementTerms","description":"The terms the statement was issued under."},"SuccessEnvelope_StatementDocumentResponse_":{"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/StatementDocumentResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[StatementDocumentResponse]"},"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":[]}]}