{"openapi":"3.1.0","info":{"title":"POST /api/v1/loans/{instrument_id}/disbursements","version":"1.0.0","description":"Record an additional loan disbursement"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/loans/{instrument_id}/disbursements":{"post":{"tags":["loans"],"summary":"Record an additional loan disbursement","description":"Record an additional draw/advance on an existing loan.\n\n**Request Body:**\n- `amount_cents`: Amount advanced (required, > 0).\n- `cash_ledger_id`: Bank/cash account the money moves through (required).\n- `disbursement_date`: Optional, defaults to today.\n- `memo`: Optional journal-entry memo.\n\n**Effect:** Posts a balanced JE and increases the loan's outstanding\nbalance. A `paid_off` loan returns to `active`.","operationId":"record_loan_disbursement_api_v1_loans__instrument_id__disbursements_post","parameters":[{"name":"instrument_id","in":"path","required":true,"schema":{"type":"string","title":"Instrument Id"}},{"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"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoanDisbursementRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_LoanDisbursementResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"detail":"Invalid request parameters"}}}},"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"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"detail":"Resource not found"}}}},"409":{"description":"Conflict - Resource already exists","content":{"application/json":{"example":{"detail":"Resource already exists"}}}},"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"},"LoanDisbursementRequest":{"properties":{"amount_cents":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount Cents"},"cash_ledger_id":{"type":"string","title":"Cash Ledger Id"},"disbursement_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Disbursement Date"},"memo":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Memo"}},"additionalProperties":false,"type":"object","required":["amount_cents","cash_ledger_id"],"title":"LoanDisbursementRequest","description":"Record an additional draw/advance on an existing loan."},"LoanDisbursementResponse":{"properties":{"instrument_id":{"type":"string","title":"Instrument Id"},"instrument_name":{"type":"string","title":"Instrument Name"},"amount_cents":{"type":"integer","title":"Amount Cents"},"new_balance_cents":{"type":"integer","title":"New Balance Cents"},"journal_entry_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Journal Entry Id"}},"type":"object","required":["instrument_id","instrument_name","amount_cents","new_balance_cents"],"title":"LoanDisbursementResponse","description":"Outcome of an additional disbursement."},"SuccessEnvelope_LoanDisbursementResponse_":{"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/LoanDisbursementResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[LoanDisbursementResponse]"},"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":[]}]}