{"openapi":"3.1.0","info":{"title":"GET /api/v1/credit/finance/borrowing-base","version":"1.0.0","description":"Borrowing base"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/finance/borrowing-base":{"get":{"tags":["credit"],"summary":"Borrowing base","description":"Eligible receivables under the program's `borrowing_base_policy` (unpaid principal, plus fees when the policy says so, less loans past the days-past-due cap, loans on hold, and each merchant's excess over the concentration limit), times the advance rate. Per-line detail; `format=csv` for the spreadsheet. Ties to the portfolio's outstanding.","operationId":"get_borrowing_base","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":"format","in":"query","required":false,"schema":{"enum":["json","csv"],"type":"string","default":"json","title":"Format"}},{"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_BorrowingBaseResponse_"}}}},"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_borrowing_base_api_v1_credit_finance_borrowing_base_get"}}},"components":{"schemas":{"BorrowingBaseConcentration":{"properties":{"merchant_key":{"type":"string","title":"Merchant Key"},"eligible_before_cents":{"type":"integer","title":"Eligible Before Cents"},"limit_cents":{"type":"integer","title":"Limit Cents"},"excess_cents":{"type":"integer","title":"Excess Cents"}},"type":"object","required":["merchant_key","eligible_before_cents","limit_cents","excess_cents"],"title":"BorrowingBaseConcentration","description":"One merchant's share of the eligible pool."},"BorrowingBaseLineRow":{"properties":{"credit_line_id":{"type":"string","title":"Credit Line Id"},"external_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Line Id"},"external_merchant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Merchant Id"},"merchant_key":{"type":"string","title":"Merchant Key","description":"What concentration is measured over: the merchant reference, else the line."},"loans_open":{"type":"integer","title":"Loans Open"},"principal_outstanding_cents":{"type":"integer","title":"Principal Outstanding Cents"},"fee_outstanding_cents":{"type":"integer","title":"Fee Outstanding Cents"},"interest_outstanding_cents":{"type":"integer","title":"Interest Outstanding Cents"},"outstanding_cents":{"type":"integer","title":"Outstanding Cents"},"gross_receivable_cents":{"type":"integer","title":"Gross Receivable Cents","description":"Principal, plus fees when the policy includes them."},"ineligible_past_due_cents":{"type":"integer","title":"Ineligible Past Due Cents"},"ineligible_on_hold_cents":{"type":"integer","title":"Ineligible On Hold Cents"},"ineligible_concentration_cents":{"type":"integer","title":"Ineligible Concentration Cents"},"eligible_cents":{"type":"integer","title":"Eligible Cents"}},"type":"object","required":["credit_line_id","merchant_key","loans_open","principal_outstanding_cents","fee_outstanding_cents","interest_outstanding_cents","outstanding_cents","gross_receivable_cents","ineligible_past_due_cents","ineligible_on_hold_cents","ineligible_concentration_cents","eligible_cents"],"title":"BorrowingBaseLineRow","description":"One credit line's contribution to the borrowing base."},"BorrowingBasePolicy":{"properties":{"include_fees":{"type":"boolean","title":"Include Fees","description":"Count unpaid disbursement fees as eligible receivables beside principal. Accrued interest is never eligible.","default":false},"max_days_past_due":{"type":"integer","maximum":3650.0,"minimum":0.0,"title":"Max Days Past Due","description":"A loan more than this many days past its due date is ineligible.","default":30},"exclude_on_hold":{"type":"boolean","title":"Exclude On Hold","description":"Loans on hold are ineligible.","default":true},"concentration_limit_bps":{"type":"integer","maximum":10000.0,"minimum":1.0,"title":"Concentration Limit Bps","description":"Most of the eligible pool one merchant may make up, in basis points. The excess over it is ineligible; 10000 turns the limit off.","default":1500},"advance_rate_bps":{"type":"integer","maximum":10000.0,"minimum":0.0,"title":"Advance Rate Bps","description":"Share of eligible receivables available to borrow, in basis points.","default":8500}},"additionalProperties":false,"type":"object","title":"BorrowingBasePolicy","description":"Which receivables count toward the borrowing base, and at what rate.\n\nUnset fields take the defaults shown, so ``{}`` is a complete policy."},"BorrowingBaseResponse":{"properties":{"as_of":{"type":"string","format":"date","title":"As Of"},"program_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Program Id"},"policy":{"$ref":"#/components/schemas/BorrowingBasePolicy"},"total_outstanding_cents":{"type":"integer","title":"Total Outstanding Cents","description":"Principal, fees and interest on open loans. Equals the portfolio's figure."},"principal_outstanding_cents":{"type":"integer","title":"Principal Outstanding Cents"},"fee_outstanding_cents":{"type":"integer","title":"Fee Outstanding Cents"},"interest_outstanding_cents":{"type":"integer","title":"Interest Outstanding Cents"},"excluded_fees_cents":{"type":"integer","title":"Excluded Fees Cents","description":"Unpaid fees left out because the policy excludes them."},"excluded_interest_cents":{"type":"integer","title":"Excluded Interest Cents","description":"Accrued interest is never eligible."},"gross_receivable_cents":{"type":"integer","title":"Gross Receivable Cents"},"ineligible_past_due_cents":{"type":"integer","title":"Ineligible Past Due Cents"},"ineligible_on_hold_cents":{"type":"integer","title":"Ineligible On Hold Cents"},"ineligible_concentration_cents":{"type":"integer","title":"Ineligible Concentration Cents"},"ineligible_cents":{"type":"integer","title":"Ineligible Cents"},"written_off_cents":{"type":"integer","title":"Written Off Cents","description":"Written off over the book's life. A written-off loan carries no receivable, so it is never in the gross; shown for completeness."},"eligible_cents":{"type":"integer","title":"Eligible Cents"},"advance_rate_bps":{"type":"integer","title":"Advance Rate Bps"},"availability_cents":{"type":"integer","title":"Availability Cents","description":"Eligible × advance rate, rounded down."},"concentration":{"items":{"$ref":"#/components/schemas/BorrowingBaseConcentration"},"type":"array","title":"Concentration"},"lines":{"items":{"$ref":"#/components/schemas/BorrowingBaseLineRow"},"type":"array","title":"Lines"}},"type":"object","required":["as_of","policy","total_outstanding_cents","principal_outstanding_cents","fee_outstanding_cents","interest_outstanding_cents","excluded_fees_cents","excluded_interest_cents","gross_receivable_cents","ineligible_past_due_cents","ineligible_on_hold_cents","ineligible_concentration_cents","ineligible_cents","written_off_cents","eligible_cents","advance_rate_bps","availability_cents"],"title":"BorrowingBaseResponse","description":"Availability under the program's borrowing-base policy."},"SuccessEnvelope_BorrowingBaseResponse_":{"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/BorrowingBaseResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[BorrowingBaseResponse]"},"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":[]}]}