{"openapi":"3.1.0","info":{"title":"GET /api/v1/credit/lines/{credit_line_id}/borrower-ledger","version":"1.0.0","description":"Borrower ledger"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/lines/{credit_line_id}/borrower-ledger":{"get":{"tags":["credit"],"summary":"Borrower ledger","description":"Complete purchases, dated activity and mutually exclusive owed buckets.","operationId":"get_borrower_ledger","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":"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_BorrowerLedger_"}}}},"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_ledger_api_v1_credit_lines__credit_line_id__borrower_ledger_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"},"BorrowerDueGroup":{"properties":{"due_date":{"type":"string","format":"date","title":"Due Date","description":"Shared purchase due date for this payable group."},"amount_cents":{"type":"integer","title":"Amount Cents","description":"Payable outstanding balance in the group, in cents."},"count":{"type":"integer","title":"Count","description":"Number of payable purchases in the group."},"loan_ids":{"items":{"type":"string"},"type":"array","title":"Loan Ids","description":"Purchase machine references for actions, not display labels."}},"type":"object","required":["due_date","amount_cents","count","loan_ids"],"title":"BorrowerDueGroup"},"BorrowerLedger":{"properties":{"as_of":{"type":"string","format":"date","title":"As Of","description":"Authoritative credit clock date, including sandbox overrides."},"limit_cents":{"type":"integer","title":"Limit Cents","description":"Configured per-line credit limit, in cents."},"term_days":{"type":"integer","title":"Term Days","description":"Configured per-line payback term, in days."},"fee_bps":{"type":"integer","title":"Fee Bps","description":"Configured per-line disbursement fee in basis points."},"apr_bps":{"type":"integer","title":"Apr Bps","description":"Configured per-line annual interest rate in basis points."},"source_account_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Account Name","description":"Existing linked account display name when supported; not an account selector."},"source_account_mask":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Account Mask","description":"Existing linked account last four when supported."},"balance_cents":{"type":"integer","title":"Balance Cents","description":"Outstanding principal, fees and booked interest including disputes, excluding cancellations."},"used_credit_cents":{"type":"integer","title":"Used Credit Cents","description":"Unpaid principal after refunds on open and disputed purchases; excludes fees and interest."},"available_credit_cents":{"type":"integer","title":"Available Credit Cents","description":"Maximum of zero and limit minus used credit."},"over_by_cents":{"type":"integer","title":"Over By Cents","description":"Maximum of zero and used credit minus limit."},"payable_cents":{"type":"integer","title":"Payable Cents","description":"Total eligible for repayment now; disputed and cancelled purchases excluded."},"pending_payment_cents":{"type":"integer","title":"Pending Payment Cents","description":"Total amount of pending (in-transit) payments on this credit line as of as_of, in cents.","default":0},"pending_payment_count":{"type":"integer","title":"Pending Payment Count","description":"Count of pending (in-transit) payments on this credit line as of as_of.","default":0},"daily_interest_cents":{"type":"integer","title":"Daily Interest Cents","description":"Combined indicative daily interest, rounded once across eligible purchases."},"buckets":{"additionalProperties":{"$ref":"#/components/schemas/BorrowerBucket"},"type":"object","title":"Buckets","description":"Mutually exclusive late, next_7_days, later and disputed balances and counts."},"due_groups":{"items":{"$ref":"#/components/schemas/BorrowerDueGroup"},"type":"array","title":"Due Groups","description":"Payable purchases grouped by due date, earliest first."},"available_months":{"items":{"type":"string","format":"date"},"type":"array","title":"Available Months","description":"Month selector values from the earliest purchase through as_of; first day of each month."},"purchases":{"items":{"$ref":"#/components/schemas/BorrowerPurchase"},"type":"array","title":"Purchases","description":"Complete purchase rows, not a page used to derive totals."},"activity":{"items":{"$ref":"#/components/schemas/BorrowerActivity"},"type":"array","title":"Activity","description":"Dated ledger movements and per-purchase payment allocations through as_of."}},"type":"object","required":["as_of","limit_cents","term_days","fee_bps","apr_bps","balance_cents","used_credit_cents","available_credit_cents","over_by_cents","payable_cents","daily_interest_cents","buckets"],"title":"BorrowerLedger"},"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_BorrowerLedger_":{"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/BorrowerLedger"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[BorrowerLedger]"},"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":[]}]}