SettlementRecorded event, then returns the settlement as CONFIRMED. The associated invoice is automatically marked PAID at the same time.
Request Body
The ID of the invoice this settlement closes.
A unique 32-byte identifier for this settlement, encoded as a hex string —
0x followed by exactly 64 hex characters (e.g. 0xabcdef12...). You generate this value and use it to deduplicate submissions. Submissions with a malformed hash are rejected with 400.The EVM wallet address of the payer. Must be a valid, non-zero checksummed address.
The EVM wallet address of the merchant. Must be a valid, non-zero checksummed address.
The Retempo user ID of the payer. If provided, it must match the
userId on the invoice. If omitted, defaults to the invoice’s userId.The Retempo user ID of the merchant. If provided, it must match the
ownerId of the associated service. If omitted, defaults to the service owner.The settlement amount as a decimal string or number. If omitted, Retempo uses the invoice amount. Must be a non-negative decimal.
The currency of the settlement. Defaults to the invoice currency if omitted.
An ISO 8601 datetime string for when the settlement occurred. Defaults to the time of the API call if omitted.
Response
A successful settlement returns HTTP201 Created with both a settlement object and a chain object containing the on-chain transaction details.
The confirmed settlement record with related objects.
On-chain transaction details returned alongside the settlement.
201 — Settlement confirmed
Example Request
Error Codes
| Status | Message | Condition |
|---|---|---|
400 Bad Request | invoiceId is required. | invoiceId was omitted. |
400 Bad Request | referenceHash is required. | referenceHash was omitted. |
400 Bad Request | referenceHash must be a 32-byte hex value. | The hash is not 0x + exactly 64 hex characters. |
400 Bad Request | payerAddress must be a valid address. | payerAddress is missing or is not a valid EVM address. |
400 Bad Request | merchantAddress must be a valid address. | merchantAddress is missing or is not a valid EVM address. |
400 Bad Request | Settlement payer must match the invoice user. | The provided payerId does not match the invoice’s userId. |
400 Bad Request | Settlement merchant must match the service owner. | The provided merchantId does not match the service’s ownerId. |
404 Not Found | Referenced database record was not found. | The invoiceId was not found. |
500 Internal Server Error | (error message) | The on-chain transaction failed or could not be verified. |
Idempotency
Settlements are idempotent on the combination ofinvoiceId and referenceHash. If you submit a settlement with the same pair and a matching settlement already exists in CONFIRMED status, Retempo returns 200 with the existing settlement record instead of creating a duplicate. Use this behavior to safely retry on network failures without risk of double-charging.
A settlement is marked
CONFIRMED only after a real on-chain transaction receipt and SettlementRecorded event are observed. The endpoint does not return until that verification is complete. If verification fails, the settlement is recorded as FAILED and a 500 is returned.