{"openapi":"3.1.0","info":{"title":"POST /api/v1/bills/payments/batch","version":"1.0.0","description":"Split one transaction across multiple bills"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/bills/payments/batch":{"post":{"tags":["bills"],"summary":"Split one transaction across multiple bills","description":"Apply a single bank transaction to multiple bills in one atomic request. Validates the total allocation against the transaction's remaining unallocated balance before creating any payments.","operationId":"create_bill_payments_batch_api_v1_bills_payments_batch_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/BillBatchPaymentRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillBatchPaymentResponse"}}}},"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":{"BillBatchPaymentAllocation":{"properties":{"bill_id":{"type":"string","title":"Bill Id","description":"UUID of the bill receiving this slice of the transaction."},"amount":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount","description":"Amount in cents to allocate to this bill. Must be > 0."}},"type":"object","required":["bill_id","amount"],"title":"BillBatchPaymentAllocation","description":"A single bill allocation inside a batch payment request."},"BillBatchPaymentRequest":{"properties":{"transaction_id":{"type":"string","title":"Transaction Id","description":"UUID of the bank transaction representing the payment."},"allocations":{"items":{"$ref":"#/components/schemas/BillBatchPaymentAllocation"},"type":"array","minItems":1,"title":"Allocations","description":"One allocation per bill (1+). Each `bill_id` must be unique."},"paid_on":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paid On","description":"Override payment date applied to every allocation. Defaults to the transaction datetime if omitted."}},"type":"object","required":["transaction_id","allocations"],"title":"BillBatchPaymentRequest","description":"Schema for splitting a single bank transaction across multiple bills.\n\nAll allocations are applied atomically *after* up-front validation: if\nthe total allocation would exceed the transaction's remaining\nunallocated balance, or any bill is invalid, no payment records are\ncreated.","example":{"allocations":[{"amount":50000,"bill_id":"019ab37c-bill-7000-8000-000000000001"},{"amount":75000,"bill_id":"019ab37c-bill-7000-8000-000000000002"}],"transaction_id":"019ab37c-txn1-7000-8000-000000000001"}},"BillBatchPaymentResponse":{"properties":{"transaction_id":{"type":"string","title":"Transaction Id","description":"Bank transaction UUID."},"total_allocated":{"type":"integer","title":"Total Allocated","description":"Total cents allocated across all bills in this batch."},"payment_count":{"type":"integer","title":"Payment Count","description":"Number of BillPayment records created."},"payments":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Payments","description":"Per-bill payment payloads (mirrors BillPaymentResponse)."}},"type":"object","required":["transaction_id","total_allocated","payment_count"],"title":"BillBatchPaymentResponse","description":"Response for a batch payment split across multiple bills."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"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":[]}]}