Skip to main content
POST
Sync invoices and payments
Creates or updates invoices, their payments, and refunds in one request. Layer applies the invoices first, then the payments and their dedicated refunds, then the standalone refunds. Layer validates invoice balances once at the end. The request is atomic. If any invoice, payment, or refund fails, nothing is saved.

Request rules

  • Send payments in the top-level payments list, not inside an invoice.
  • If a payment pays several invoices, include all of those invoices in the same request.
  • Payments and refunds that you don’t include are left unchanged.

Example

Request

Rate Limiting

This endpoint shares its rate limit with Bulk create invoices and Batch create invoices. For details on rate limit headers, see Rate Limiting.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Content-Type
string

Content-Type must be set to application/json.

Path Parameters

businessId
string<uuid>
required

The UUID of the business to sync invoices for.

Body

application/json

Invoices, payments, and standalone refunds to apply in one atomic request.

invoices
object[]

Invoices to create or update, matched by external_id. Each uses the same parameters as the create invoice endpoint, except that payments must be omitted. Send payments in the top-level payments list.

payments
object[]

Payments to create or update, matched by external_id. Each uses the same parameters as the bulk create invoice payments endpoint, including dedicated_refunds. A payment may allocate to several invoices.

refunds
(Simple Refund · object | Itemized Refund · object)[]

Standalone refunds to create or update, matched by external_id. Each uses the same parameters as the bulk create refunds endpoint. A refund with allocations is itemized, and any other refund is simple. Layer applies refunds after payments, so a refund can target a payment from the same request. To lower an invoice's net payments, target the payment with invoice_payment_id or invoice_payment_external_id.

Simple refund creation parameters. The system will automatically calculate the refund amount based on the specified target (invoice, line item, or payment). At least one target identifier must be provided.

Response

Every invoice, payment, and refund was applied. Returns each one in its final state.

data
object
required

Final state of the invoices, payments, and refunds in a sync request.