Sample - Adyen Checkout API
POST/cancels

Cancel an authorised payment

Cancels the authorisation on a payment that has not yet been captured, and returns a unique reference for this request. You get the outcome of the request asynchronously, in a TECHNICAL_CANCEL webhook.

If you want to cancel a payment using the pspReference, use the /payments/{paymentPspReference}/cancels endpoint instead.

If you want to cancel a payment but are not sure whether it has been captured, use the /payments/{paymentPspReference}/reversals endpoint instead.

For more information, refer to Cancel.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.
  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

1 parameter · 5 body fields
Idempotency-Keystringoptional
A unique identifier for the message with a maximum of 64 characters (we recommend a UUID).
applicationInfoobjectoptional
Information about your application. For more details, see [Building Adyen solutions](https://docs.adyen.com/development-resources/building-adyen-solutions).
enhancedSchemeDataobjectoptional
Enhanced scheme data that may be required for processing the payment. For example, airline information.
merchantAccountstringrequired
The merchant account that is used to process the payment.
paymentReferencestringrequired
The [`reference`](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__reqParam_reference) of the payment that you want to cancel.
referencestringoptional
Your reference for the cancel request. Maximum length: 80 characters.

6 status codes
201Created - the request has been fulfilled and has resulted in one or more new resources being created.
merchantAccountstringrequired
The merchant account that is used to process the payment.
paymentReferencestringrequired
The [`reference`](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/payments__reqParam_reference) of the payment to cancel.
pspReferencestringrequired
Adyen's 16-character reference associated with the cancel request.
referencestringoptional
Your reference for the cancel request.
statusstringrequired
The status of your request. This will always have the value **received**.
Allowed:received
400Bad Request - a problem reading or understanding the request.
additionalDataobjectoptional
Contains additional information about the payment. Some data fields are included only if you select them first. Go to **Customer Area** > **Developers** > **Additional data**.
errorCodestringoptional
The error code mapped to the error message.
errorTypestringoptional
The category of the error.
messagestringoptional
A short explanation of the issue.
pspReferencestringoptional
The PSP reference of the payment.
statusintegeroptional
The HTTP response status.
401Unauthorized - authentication required.
additionalDataobjectoptional
Contains additional information about the payment. Some data fields are included only if you select them first. Go to **Customer Area** > **Developers** > **Additional data**.
errorCodestringoptional
The error code mapped to the error message.
errorTypestringoptional
The category of the error.
messagestringoptional
A short explanation of the issue.
pspReferencestringoptional
The PSP reference of the payment.
statusintegeroptional
The HTTP response status.
403Forbidden - insufficient permissions to process the request.
additionalDataobjectoptional
Contains additional information about the payment. Some data fields are included only if you select them first. Go to **Customer Area** > **Developers** > **Additional data**.
errorCodestringoptional
The error code mapped to the error message.
errorTypestringoptional
The category of the error.
messagestringoptional
A short explanation of the issue.
pspReferencestringoptional
The PSP reference of the payment.
statusintegeroptional
The HTTP response status.
422Unprocessable Entity - a request validation error.
additionalDataobjectoptional
Contains additional information about the payment. Some data fields are included only if you select them first. Go to **Customer Area** > **Developers** > **Additional data**.
errorCodestringoptional
The error code mapped to the error message.
errorTypestringoptional
The category of the error.
messagestringoptional
A short explanation of the issue.
pspReferencestringoptional
The PSP reference of the payment.
statusintegeroptional
The HTTP response status.
500Internal Server Error - the server could not process the request.
additionalDataobjectoptional
Contains additional information about the payment. Some data fields are included only if you select them first. Go to **Customer Area** > **Developers** > **Additional data**.
errorCodestringoptional
The error code mapped to the error message.
errorTypestringoptional
The category of the error.
messagestringoptional
A short explanation of the issue.
pspReferencestringoptional
The PSP reference of the payment.
statusintegeroptional
The HTTP response status.

Error handling

A 400 is returned: Bad Request - a problem reading or understanding the request. A 401 is returned: Unauthorized - authentication required. A 403 is returned: Forbidden - insufficient permissions to process the request. A 422 is returned: Unprocessable Entity - a request validation error. A 500 is returned: Internal Server Error - the server could not process the request.