{"openapi":"3.1.0","info":{"title":"GET /api/v1/credit/lines/{credit_line_id}/borrower-monthly-balance","version":"1.0.0","description":"Borrower monthly balance"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/lines/{credit_line_id}/borrower-monthly-balance":{"get":{"tags":["credit"],"summary":"Borrower monthly balance","description":"Historical month-end status, roll-forward and original purchase activity.","operationId":"get_borrower_monthly_balance","parameters":[{"name":"credit_line_id","in":"path","required":true,"schema":{"type":"string","description":"Credit line UUID on the authenticated business.","title":"Credit Line Id"},"description":"Credit line UUID on the authenticated business."},{"name":"month","in":"query","required":true,"schema":{"type":"string","format":"date","description":"Calendar month to reconstruct; pass its first date, YYYY-MM-01.","title":"Month"},"description":"Calendar month to reconstruct; pass its first date, YYYY-MM-01."},{"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_BorrowerMonthlyBalance_"}}}},"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_borrower_monthly_balance_api_v1_credit_lines__credit_line_id__borrower_monthly_balance_get"}}},"components":{"schemas":{"BorrowerActivity":{"properties":{"date":{"type":"string","format":"date","title":"Date","description":"Effective date of the ledger movement or payment allocation."},"kind":{"type":"string","title":"Kind","description":"Movement kind, such as origination, fee, refund, payment or accrual. Interest taken back when a backdated payment or a hold re-prices days already accrued is a negative accrual, so a month's accrual rows net to its interest."},"memo":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Memo","description":"What the movement was, in the register's words, for a kind that needs one: a waiver, a goodwill credit, a dispute reversal, credit applied at origination, a write-off. Null on purchases, fees, refunds, payments and accruals."},"amount_cents":{"type":"integer","title":"Amount Cents","description":"Signed movement: purchases and charges positive, repayments and refunds negative."},"loan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Loan Id","description":"Related purchase machine reference, not a display label."},"merchant_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Name","description":"Merchant of the related original purchase."},"original_purchase_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Original Purchase Date","description":"Posting date of the related original purchase."},"original_purchase_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Original Purchase Cents","description":"Original purchase principal before refunds, in cents."},"method":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Method","description":"Method reported on the recorded payment; not proof of payment initiation."},"settled_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Settled On","description":"Payment rows: date the payment settled, when settled."},"payer_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payer Name","description":"Payment rows: the account holder the money came from, from the linked Payliance debit or the matched bank transaction, when known."},"account_last4":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Account Last4","description":"Payment rows: last four of the payer's bank account, when known."},"loans_touched":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Loans Touched","description":"Payment rows: distinct purchases the whole payment reached."},"loans_paid_off":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Loans Paid Off","description":"Payment rows: purchases the whole payment paid off (status `paid` and this payment is the last payment allocated to them); `0` for a pending or reversed payment."},"principal_delta_cents":{"type":"integer","title":"Principal Delta Cents","description":"Signed change to unpaid principal from this movement.","default":0},"fee_delta_cents":{"type":"integer","title":"Fee Delta Cents","description":"Signed change to unpaid fees from this movement.","default":0},"interest_delta_cents":{"type":"integer","title":"Interest Delta Cents","description":"Signed change to unpaid interest from this movement.","default":0}},"type":"object","required":["date","kind","amount_cents"],"title":"BorrowerActivity"},"BorrowerBucket":{"properties":{"amount_cents":{"type":"integer","title":"Amount Cents","description":"Outstanding balance in this bucket, in cents.","default":0},"count":{"type":"integer","title":"Count","description":"Purchases with a positive balance in this bucket.","default":0}},"type":"object","title":"BorrowerBucket"},"BorrowerMonthlyBalance":{"properties":{"period_start":{"type":"string","format":"date","title":"Period Start","description":"First calendar day of the requested month."},"period_end":{"type":"string","format":"date","title":"Period End","description":"Last calendar day of the requested month."},"as_of":{"type":"string","format":"date","title":"As Of","description":"Earlier of month end and the authoritative credit clock."},"final":{"type":"boolean","title":"Final","description":"The requested calendar month has ended; false for month-to-date views."},"customer":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer","description":"Borrower's legal name when available."},"logo_data_uri":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Logo Data Uri","description":"Configured embedded branding image; remote URLs are never fetched."},"limit_cents":{"type":"integer","title":"Limit Cents","description":"Credit limit currently configured on this line, in cents."},"available_credit_cents":{"type":"integer","title":"Available Credit Cents","description":"Current line limit less historical unpaid principal, floored at zero."},"term_days":{"type":"integer","title":"Term Days","description":"Current per-line payback term, in days."},"fee_bps":{"type":"integer","title":"Fee Bps","description":"Current per-line disbursement fee in basis points; 100 is 1%."},"apr_bps":{"type":"integer","title":"Apr Bps","description":"Current per-line annual interest rate in basis points; 2000 is 20%."},"start_balance_cents":{"type":"integer","title":"Start Balance Cents","description":"Outstanding balance immediately before this month began."},"purchases_cents":{"type":"integer","title":"Purchases Cents","description":"Original principal posted this month, including imports once and excluding cancellations."},"fees_cents":{"type":"integer","title":"Fees Cents","description":"Disbursement fees posted this month, excluding cancelled purchases."},"refunds_cents":{"type":"integer","title":"Refunds Cents","description":"Refunds dated within this month, shown as a positive deduction."},"interest_cents":{"type":"integer","title":"Interest Cents","description":"Interest charged during this month, excluding repayments of interest."},"payments_cents":{"type":"integer","title":"Payments Cents","description":"Net payments allocated this month, shown as a positive deduction."},"adjustments_cents":{"type":"integer","title":"Adjustments Cents","description":"Signed other recorded balance adjustments during this month."},"reconciliation_difference_cents":{"type":"integer","title":"Reconciliation Difference Cents","description":"Unexplained roll-forward remainder; nonzero blocks final PDF export.","default":0},"end_balance_cents":{"type":"integer","title":"End Balance Cents","description":"Historical outstanding balance at as_of, in cents."},"buckets":{"additionalProperties":{"$ref":"#/components/schemas/BorrowerBucket"},"type":"object","title":"Buckets","description":"Mutually exclusive late, next_30_days, later and disputed balances and counts."},"purchases":{"items":{"$ref":"#/components/schemas/BorrowerPurchase"},"type":"array","title":"Purchases","description":"Historical purchase rows with original amounts, dates and status at as_of."},"activity":{"items":{"$ref":"#/components/schemas/BorrowerActivity"},"type":"array","title":"Activity","description":"Dated movements during this month, including separate refunds and payment allocations."},"historical_reconstruction":{"type":"boolean","title":"Historical Reconstruction","description":"This view is reconstructed from dated records, not a replacement of an issued immutable statement.","default":true},"notice":{"type":"string","title":"Notice","description":"Borrower-facing notice printed on the monthly balance.","default":"This is a record of your balance, not a bill."}},"type":"object","required":["period_start","period_end","as_of","final","limit_cents","available_credit_cents","term_days","fee_bps","apr_bps","start_balance_cents","purchases_cents","fees_cents","refunds_cents","interest_cents","payments_cents","adjustments_cents","end_balance_cents","buckets","purchases","activity"],"title":"BorrowerMonthlyBalance"},"BorrowerPurchase":{"properties":{"loan_id":{"type":"string","title":"Loan Id","description":"Machine reference for actions; never use as a borrower-facing label."},"transaction_date":{"type":"string","format":"date","title":"Transaction Date","description":"Original purchase posting date, retained after refunds."},"merchant_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Merchant Name","description":"Merchant display name from the purchase."},"card_last_four":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Card Last Four","description":"Card last four when the issuer supplied them."},"due_date":{"type":"string","format":"date","title":"Due Date","description":"Original purchase due date under its captured terms."},"status":{"type":"string","title":"Status","description":"Authoritative display status: Not due, Due soon, Late, Disputed, Paid or Cancelled."},"late_days":{"type":"integer","title":"Late Days","description":"Days past due at the response date; zero for held or terminal purchases.","default":0},"principal_cents":{"type":"integer","title":"Principal Cents","description":"Original purchase principal, before any refund or repayment."},"fee_cents":{"type":"integer","title":"Fee Cents","description":"Original disbursement fee; not reduced by a principal refund."},"refunds_cents":{"type":"integer","title":"Refunds Cents","description":"Refund principal applied to this purchase by the response date."},"principal_paid_cents":{"type":"integer","title":"Principal Paid Cents","description":"Principal retired by recorded payments, in cents."},"fee_paid_cents":{"type":"integer","title":"Fee Paid Cents","description":"Fees retired by recorded payments, in cents."},"interest_paid_cents":{"type":"integer","title":"Interest Paid Cents","description":"Interest retired by recorded payments, in cents."},"principal_outstanding_cents":{"type":"integer","title":"Principal Outstanding Cents","description":"Unpaid principal after refunds and other booked reductions."},"fee_outstanding_cents":{"type":"integer","title":"Fee Outstanding Cents","description":"Unpaid fee after repayments and booked reductions."},"interest_outstanding_cents":{"type":"integer","title":"Interest Outstanding Cents","description":"Booked unpaid interest; not projected future accrual."},"owed_cents":{"type":"integer","title":"Owed Cents","description":"Outstanding principal plus fee plus interest; cancelled purchases owe zero."},"payable_cents":{"type":"integer","title":"Payable Cents","description":"Owed amount eligible for repayment; zero while disputed or cancelled."},"daily_interest_cents":{"type":"integer","title":"Daily Interest Cents","description":"Indicative daily interest under captured pricing rules; zero while held.","default":0}},"type":"object","required":["loan_id","transaction_date","due_date","status","principal_cents","fee_cents","refunds_cents","principal_paid_cents","fee_paid_cents","interest_paid_cents","principal_outstanding_cents","fee_outstanding_cents","interest_outstanding_cents","owed_cents","payable_cents"],"title":"BorrowerPurchase"},"SuccessEnvelope_BorrowerMonthlyBalance_":{"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/BorrowerMonthlyBalance"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[BorrowerMonthlyBalance]"},"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":[]}]}