{"openapi":"3.1.0","info":{"title":"GET /api/v1/credit/lines/{credit_line_id}/historical-payments","version":"1.0.0","description":"List a line's historical payments"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/lines/{credit_line_id}/historical-payments":{"get":{"tags":["credit"],"summary":"List a line's historical payments","description":"Payments made before the line joined DayZero, attached from the previous system's records, newest first, each with its split by loan and whether that split is the previous system's or derived. They moved no balance here: the loans were imported with them in their paid amounts. `loan_id` lists one loan's.","operationId":"credit_list_historical_payments","parameters":[{"name":"credit_line_id","in":"path","required":true,"schema":{"type":"string","description":"The line.","title":"Credit Line Id"},"description":"The line."},{"name":"loan_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Only payments split onto this loan.","title":"Loan Id"},"description":"Only payments split onto this loan."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"description":"Page size (1-500).","default":50,"title":"Limit"},"description":"Page size (1-500)."},{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"`next_cursor` from the previous page.","title":"Cursor"},"description":"`next_cursor` from the previous page."},{"name":"include_total_count","in":"query","required":false,"schema":{"type":"boolean","description":"Also count every payment that matches.","default":false,"title":"Include Total Count"},"description":"Also count every payment that matches."},{"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_HistoricalPaymentPage_"}}}},"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":"credit_list_historical_payments_api_v1_credit_lines__credit_line_id__historical_payments_get"}}},"components":{"schemas":{"HistoricalPaymentAllocationResponse":{"properties":{"loan_id":{"type":"string","title":"Loan Id","description":"The loan."},"external_settlement_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Settlement Id","description":"The loan's original issuer transaction id."},"principal_cents":{"type":"integer","title":"Principal Cents","description":"To principal."},"fee_cents":{"type":"integer","title":"Fee Cents","description":"To the disbursement fee."},"interest_cents":{"type":"integer","title":"Interest Cents","description":"To interest."}},"type":"object","required":["loan_id","principal_cents","fee_cents","interest_cents"],"title":"HistoricalPaymentAllocationResponse","description":"How much of a historical payment went to one loan."},"HistoricalPaymentPage":{"properties":{"next_cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Next Cursor","description":"Pass back as `cursor` for the next page. Null on the last."},"has_next":{"type":"boolean","title":"Has Next","description":"Another page follows. Looked up one row past the page, so a full last page is not reported as more.","default":false},"limit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Limit","description":"The page size the list was read with."},"total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total","description":"Row count; present only with `include_total_count=true`."},"items":{"items":{"$ref":"#/components/schemas/HistoricalPaymentResponse"},"type":"array","title":"Items","description":"The payments on this page."}},"type":"object","title":"HistoricalPaymentPage","description":"A line's historical payments, newest first."},"HistoricalPaymentResponse":{"properties":{"id":{"type":"string","title":"Id","description":"DayZero's id for the record."},"credit_line_id":{"type":"string","title":"Credit Line Id","description":"The line."},"source":{"type":"string","const":"partner_history","title":"Source","description":"Always `partner_history`: attached from the previous system.","default":"partner_history"},"external_payment_id":{"type":"string","title":"External Payment Id","description":"The partner's payment id."},"status":{"type":"string","enum":["settled","reversed"],"title":"Status","description":"`settled`, or `reversed` once an operator marked it returned."},"amount_cents":{"type":"integer","title":"Amount Cents","description":"The payment."},"paid_on":{"type":"string","format":"date","title":"Paid On","description":"When it landed, as the partner dated it."},"method":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Method","description":"How it was paid, if given."},"source_system":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source System","description":"The previous system, as the file named it."},"allocation_source":{"type":"string","enum":["partner","derived"],"title":"Allocation Source","description":"`partner`: the split is the one the partner's ledger gave it. `derived`: the ledger held no split, so DayZero derived one."},"derivation":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Derivation","description":"How a derived split was worked out, in words."},"allocations":{"items":{"$ref":"#/components/schemas/HistoricalPaymentAllocationResponse"},"type":"array","title":"Allocations","description":"The split, loan by loan."},"reversed_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Reversed On","description":"When an operator marked it returned."},"reversal_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reversal Reason","description":"The reason the operator gave."},"import_batch_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Import Batch Id","description":"The payments file that attached it."},"attached_at":{"type":"string","format":"date-time","title":"Attached At","description":"When it was attached (UTC)."}},"type":"object","required":["id","credit_line_id","external_payment_id","status","amount_cents","paid_on","allocation_source","attached_at"],"title":"HistoricalPaymentResponse","description":"A payment made before cut-over, as the partner's ledger recorded it.\n\nA record, not money DayZero moved: the loans' paid amounts already\ncarried it in from the import, so it changes no balance, is on no\nDayZero statement and on no event."},"SuccessEnvelope_HistoricalPaymentPage_":{"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/HistoricalPaymentPage"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[HistoricalPaymentPage]"},"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":[]}]}