{"openapi":"3.1.0","info":{"title":"POST /api/v1/invoices/bulk-payments","version":"1.0.0","description":"Bulk mark invoices paid"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/invoices/bulk-payments":{"post":{"tags":["invoices"],"summary":"Bulk mark invoices paid","description":"Mark a selection of invoices paid in one call, recording the payment date you supply and optionally matching one or more bank transactions to each invoice.","operationId":"bulk_mark_invoices_paid_api_v1_invoices_bulk_payments_post","parameters":[{"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/BulkMarkInvoicesPaidRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_BulkMarkInvoicesPaidResponse_"}}}},"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"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"BulkInvoicePaymentAllocation":{"properties":{"transaction_id":{"type":"string","title":"Transaction Id","description":"UUID of the bank transaction the payment arrived in."},"amount":{"anyOf":[{"type":"integer","exclusiveMinimum":0.0},{"type":"null"}],"title":"Amount","description":"Cents of this transaction to allocate to the invoice. Omit to apply as much as fits: the smaller of the invoice's remaining balance and the transaction's unallocated amount. Never exceeds either — a transaction cannot be spread across invoices beyond its own amount."}},"type":"object","required":["transaction_id"],"title":"BulkInvoicePaymentAllocation","description":"One bank transaction applied to one invoice."},"BulkInvoicePaymentRow":{"properties":{"invoice_id":{"type":"string","title":"Invoice Id","description":"UUID of the invoice to settle."},"paid_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paid On","description":"Payment date for this invoice (YYYY-MM-DD or full ISO 8601). Overrides the batch-level `paid_on`. When transactions are linked and no date is given anywhere, the transaction's own date is recorded."},"transactions":{"items":{"$ref":"#/components/schemas/BulkInvoicePaymentAllocation"},"type":"array","maxItems":25,"title":"Transactions","description":"Bank transactions to match to this invoice. One or many — a customer who paid an invoice in two deposits gets two entries. Leave empty to mark the invoice paid without linking a transaction."}},"type":"object","required":["invoice_id"],"title":"BulkInvoicePaymentRow","description":"One invoice to mark paid, optionally matched to transactions."},"BulkInvoicePaymentRowResult":{"properties":{"index":{"type":"integer","title":"Index","description":"Position of the row in the request, 0-based."},"invoice_id":{"type":"string","title":"Invoice Id","description":"Invoice the row targeted."},"success":{"type":"boolean","title":"Success","description":"Whether the invoice was settled."},"invoice_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Invoice Number","description":"Invoice number, for naming the row to a human."},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status","description":"Invoice status after the write (manual_paid, partially_paid)."},"paid_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paid On","description":"Payment date actually recorded on the invoice."},"amount_applied":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Amount Applied","description":"Cents applied by this row (0 when nothing was allocated)."},"transaction_ids":{"items":{"type":"string"},"type":"array","title":"Transaction Ids","description":"Transactions linked by this row, in the order applied."},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error","description":"Why the row failed. Always set when success is false."}},"type":"object","required":["index","invoice_id","success"],"title":"BulkInvoicePaymentRowResult","description":"Outcome of one row — applied or failed, never silently dropped."},"BulkMarkInvoicesPaidRequest":{"properties":{"invoices":{"items":{"$ref":"#/components/schemas/BulkInvoicePaymentRow"},"type":"array","maxItems":500,"minItems":1,"title":"Invoices","description":"Invoices to settle (1-500 rows)."},"paid_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paid On","description":"Payment date applied to every row that does not carry its own (YYYY-MM-DD or full ISO 8601). This is the date recorded as the invoice's 'Paid on' — not the date the request was made."}},"type":"object","required":["invoices"],"title":"BulkMarkInvoicesPaidRequest","description":"Request body for marking a selection of invoices paid.","example":{"invoices":[{"invoice_id":"019ab37c-0002-7000-8000-000000000002"},{"invoice_id":"019ab37c-0003-7000-8000-000000000003","transactions":[{"transaction_id":"019ab37c-0004-7000-8000-000000000004"}]}],"paid_on":"2026-03-10"}},"BulkMarkInvoicesPaidResponse":{"properties":{"total_requested":{"type":"integer","title":"Total Requested","description":"Rows in the request."},"total_succeeded":{"type":"integer","title":"Total Succeeded","description":"Rows that settled their invoice."},"total_failed":{"type":"integer","title":"Total Failed","description":"Rows that did not."},"total_amount_applied":{"type":"integer","title":"Total Amount Applied","description":"Cents applied across all successful rows."},"committed_count":{"type":"integer","title":"Committed Count","description":"Successful rows already committed at a checkpoint, and therefore durable even if the rest of the batch is rolled back.","default":0},"partial":{"type":"boolean","title":"Partial","description":"True when some rows succeeded and some failed."},"success":{"type":"boolean","title":"Success","description":"True when every row succeeded."},"results":{"items":{"$ref":"#/components/schemas/BulkInvoicePaymentRowResult"},"type":"array","title":"Results","description":"Every requested row, in request order, applied or failed."}},"type":"object","required":["total_requested","total_succeeded","total_failed","total_amount_applied","partial","success"],"title":"BulkMarkInvoicesPaidResponse","description":"Per-row outcome of a bulk mark-paid call.\n\nPartial application is the normal case, not an error: rows are applied\nindependently and a failure in one does not roll back the rest. Every\nrequested row appears exactly once in ``results`` so the caller can always\nanswer \"which ones did not go through, and why\"."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"SuccessEnvelope_BulkMarkInvoicesPaidResponse_":{"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/BulkMarkInvoicesPaidResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[BulkMarkInvoicesPaidResponse]"},"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":[]}]}