{"openapi":"3.1.0","info":{"title":"POST /api/v1/contracts/invoices/{invoice_id}/payments","version":"1.0.0","description":"Apply a payment to a contract invoice"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/contracts/invoices/{invoice_id}/payments":{"post":{"tags":["contracts"],"summary":"Apply a payment to a contract invoice","description":"Record a payment (amount, method, received date) against a contract invoice, transitioning it to partially/fully paid.","operationId":"apply_contract_invoice_payment_api_v1_contracts_invoices__invoice_id__payments_post","parameters":[{"name":"invoice_id","in":"path","required":true,"schema":{"type":"string","title":"Invoice 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/ContractInvoicePaymentRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_ContractInvoicePaymentResponse_"}}}},"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"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"ContractInvoicePaymentRequest":{"properties":{"amount_cents":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount Cents","description":"Payment amount in cents."},"method":{"type":"string","title":"Method","description":"Payment method: ach, stripe, or manual.","default":"manual"},"received_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Received Date","description":"Date the payment was received (YYYY-MM-DD)."}},"type":"object","required":["amount_cents"],"title":"ContractInvoicePaymentRequest","description":"Record a payment against a contract invoice (amount / method / date)."},"ContractInvoicePaymentResponse":{"properties":{"invoice_id":{"type":"string","title":"Invoice Id"},"contract_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contract Id"},"method":{"type":"string","title":"Method"},"amount_applied_cents":{"type":"integer","title":"Amount Applied Cents"},"total_paid_cents":{"type":"integer","title":"Total Paid Cents"},"balance_due_cents":{"type":"integer","title":"Balance Due Cents"},"status":{"type":"string","title":"Status"},"paid_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paid On"}},"type":"object","required":["invoice_id","method","amount_applied_cents","total_paid_cents","balance_due_cents","status"],"title":"ContractInvoicePaymentResponse","description":"Result of applying a payment to a contract invoice."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"SuccessEnvelope_ContractInvoicePaymentResponse_":{"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/ContractInvoicePaymentResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[ContractInvoicePaymentResponse]"},"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":[]}]}