Reverse match

POST https://api.invunion.com/api/v1/matches/:id/reverse matches:write Idempotency-Key Markdown

Reverse a wrong payment with a reason, and optionally match the right transaction.

Use this when a payment recorded on an invoice was wrong: the invoice was never paid by that transaction, the amount was wrong, or the payment was counted twice. The match must be active or confirmed. The path is the match UUID from List matches, Get invoice, or a match webhook, not from the product.

The match is not deleted. It is kept as cancelled with who reversed it, when, the reason, and the note. Invoice and transaction amounts are recalculated, and the invoice reopens. reason wrong_transaction also records the pair as rejected, so matching does not suggest it again; the response returns that row as rejectedPairId.

Send replacement to match the transaction that really paid the invoice in the same step. replacement.transactionId is a transaction code. matchedAmount defaults to the reversed amount. The replacement is checked like Create match.

One invoice.settlement_changed webhook carries the removal, with its reason, and the replacement. match.cancelled is also emitted, and match.rejected for a wrong_transaction pair.

einvoicing is null unless an e-invoicing payment report exists for this payment. needsCorrection true means the report was already sent and needs a correction.

See also

  • Matches . Which call to use for each change.
  • List matches (GET/api/v1/matches). Get the UUID by invoice number and transaction code.
  • Create match (POST/api/v1/matches). The checks applied to replacement.
  • Webhooks . The invoice.settlement_changed payload.

Path parameters

NameTypeRequired
id

Match UUID.

Example: 1c9e6679-7425-40de-944b-e07fc1f90ae7

string

No maximum

Required

Body parameters

NameTypeRequired
reason

Why the payment was wrong. wrong_transaction also records the pair as rejected.

string

No maximum

Required
Allowed valueswrong_transactionwrong_amountduplicateother
note

Free text kept with the reversal.

Example: Paid by the parent company, not Leones Cars

string

Max 500

Optional
replacement

The transaction that really paid the invoice: { transactionId, matchedAmount? }. transactionId is the transaction code. matchedAmount is a positive number and defaults to the reversed amount.

Example: {"transactionId":"TX-8892"}

object
Optional

Errors

This operation can return the following errors in addition to generic HTTP failures.

Error HTTP code Description
Missing Bearer token 401 The Authorization header is missing or is not a Bearer token.
Invalid or revoked API key 401 The API key is unknown, malformed, expired, or has been revoked.
API key is missing scope matches:write 403 The key does not include matches:write. A write scope does not imply the matching read scope.
Too many requests, please try again later 429 More than 100 requests in one minute from this API key or IP address. Wait for the Retry-After header (seconds) and retry.
Validation failed 400 The body failed schema validation, for example an unknown reason. details lists field and message.
Transaction not found 400 replacement.transactionId does not exist in this tenant. The other Create match checks apply to replacement too.
Match not found 404 No match with this UUID exists in the authenticated tenant.
Only a payment that settles an invoice can be reversed. 409 The match is pending_review, rejected, or already cancelled.
Internal server error 500 Unexpected server error. The JSON body includes correlationId. Retry with backoff.
Idempotency-Key must be 8-255 characters: letters, digits, ".", "_", ":" or "-". 400 The Idempotency-Key header is present but malformed.
A request with this Idempotency-Key is still being processed. 409 The first request with this key has not finished. Retry after it completes. code is idempotency_in_progress.
This Idempotency-Key was already used with a different request body. 422 Send a new key for a different request. code is idempotency_key_reuse.