{"openapi":"3.1.0","info":{"title":"GET /api/v1/loans/subledger","version":"1.0.0","description":"Loan subledger summary grouped by counterparty"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/loans/subledger":{"get":{"tags":["loans"],"summary":"Loan subledger summary grouped by counterparty","description":"Business-wide loan subledger grouped by counterparty.\n\n**Query Parameters:**\n- `direction`: Optional filter — `lend` (notes receivable) or `borrow`.\n\n**Returns:** Counterparty groups with per-loan balances, accrued\ninterest, and rolled-up totals.","operationId":"get_loan_subledger_summary_api_v1_loans_subledger_get","parameters":[{"name":"direction","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Filter by direction: `lend` or `borrow`.","title":"Direction"},"description":"Filter by direction: `lend` or `borrow`."},{"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_LoanSubledgerSummaryResponse_"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"LoanCounterpartyGroup":{"properties":{"counterparty":{"type":"string","title":"Counterparty"},"counterparty_type":{"type":"string","title":"Counterparty Type"},"loan_count":{"type":"integer","title":"Loan Count"},"outstanding_principal_cents":{"type":"integer","title":"Outstanding Principal Cents"},"accrued_interest_cents":{"type":"integer","title":"Accrued Interest Cents"},"total_receivable_cents":{"type":"integer","title":"Total Receivable Cents","description":"Principal + accrued interest still owed on this group."},"loans":{"items":{"$ref":"#/components/schemas/LoanInstrumentBrief"},"type":"array","title":"Loans"}},"type":"object","required":["counterparty","counterparty_type","loan_count","outstanding_principal_cents","accrued_interest_cents","total_receivable_cents","loans"],"title":"LoanCounterpartyGroup","description":"All loans against one counterparty, with rolled-up balances."},"LoanInstrumentBrief":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"counterparty":{"type":"string","title":"Counterparty"},"counterparty_type":{"type":"string","title":"Counterparty Type"},"direction":{"type":"string","title":"Direction"},"debt_type":{"type":"string","title":"Debt Type"},"status":{"type":"string","title":"Status"},"interest_rate_bps":{"type":"integer","title":"Interest Rate Bps"},"original_principal_cents":{"type":"integer","title":"Original Principal Cents"},"current_balance_cents":{"type":"integer","title":"Current Balance Cents"},"accrued_interest_cents":{"type":"integer","title":"Accrued Interest Cents"},"written_off_cents":{"type":"integer","title":"Written Off Cents"},"start_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Start Date"},"maturity_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Maturity Date"},"last_accrual_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Last Accrual Date"}},"type":"object","required":["id","name","counterparty","counterparty_type","direction","debt_type","status","interest_rate_bps","original_principal_cents","current_balance_cents","accrued_interest_cents","written_off_cents"],"title":"LoanInstrumentBrief","description":"Loan header shown above a register and inside counterparty groups."},"LoanSubledgerSummaryResponse":{"properties":{"counterparty_count":{"type":"integer","title":"Counterparty Count"},"loan_count":{"type":"integer","title":"Loan Count"},"total_lent_outstanding_cents":{"type":"integer","title":"Total Lent Outstanding Cents"},"total_borrowed_outstanding_cents":{"type":"integer","title":"Total Borrowed Outstanding Cents"},"total_accrued_receivable_cents":{"type":"integer","title":"Total Accrued Receivable Cents"},"total_accrued_payable_cents":{"type":"integer","title":"Total Accrued Payable Cents"},"groups":{"items":{"$ref":"#/components/schemas/LoanCounterpartyGroup"},"type":"array","title":"Groups"}},"type":"object","required":["counterparty_count","loan_count","total_lent_outstanding_cents","total_borrowed_outstanding_cents","total_accrued_receivable_cents","total_accrued_payable_cents","groups"],"title":"LoanSubledgerSummaryResponse","description":"Business-wide loan subledger grouped by counterparty."},"SuccessEnvelope_LoanSubledgerSummaryResponse_":{"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/LoanSubledgerSummaryResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[LoanSubledgerSummaryResponse]"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}