Record that a payment settles an open invoice. Use this when the payment was created against the policy separately and needs to be attributed to a particular invoice.
The invoice's status in the response depends on the payment. If the payment has not succeeded yet the invoice stays open, and moves to paid on its own when the payment succeeds. If the payment has already succeeded, the invoice moves to paid as part of this call and the receipt document is queued, so the response comes back with "status": "paid".
A payment that succeeded but was later reversed does not settle the invoice: the link is recorded and the invoice stays open.
The payment must be on the same policy as the invoice, in the same currency, and for exactly the invoice total — partial payments are not supported. A payment can be linked to one invoice only; linking it again returns 400, whichever invoice is named.
Invoicing is opt-in per organization: unless the invoicing feature flag is enabled for your organization this endpoint returns 403.
400The payment cannot fund this invoice: it is on a different policy, in a different currency, or not for the exact invoice total; the invoice is not open; the invoice is a credit note; or the payment is already linked to an invoice.
403Invoicing is not enabled for the organization, or the caller is missing the invoices:create permission.
404No such invoice or payment, or the caller's user group does not grant access to the invoice's policy.
409The invoice was modified by a concurrent writer before it could be settled. Nothing is recorded, so the call can be retried.