# Cancel a transaction This endpoint allows you to cancel an eligible scheduled transaction using the `payout_id` and `transaction_id` returned when the payout was created. Only transactions that have not yet been processed and have `status=pending` or `status=in_process` can be canceled, and the cancellation is irreversible. The cancellation request must be sent at least 12 hours before the scheduled execution date and time. On success, the request returns status 204. **PUT** `/v1/payouts/{payout_id}/transactions/{transaction_id}/cancel` ## Request parameters ### Header - `X-Idempotency-Key` (string, required) This feature allows you to safely retry requests without the risk of accidentally performing the same action more than once. This is useful for avoiding errors, such as creating two identical transactions, for example. To ensure that each request is unique, it's important to use an exclusive value in the header of your request. We suggest using a UUID V4 or random strings. It is important to note that, starting from 2024/01/01, sending this parameter will become mandatory in all requests. - `X-signature` (string, optional) Request signature with the encrypted body in base 64 with the public and private keys of the integrator. It is required only in a productive environment. - `X-enforce-signature` (boolean, optional) Value of type `boolean` indicating whether the integrator will send the signature. It must be `false` for test environments, and `true` for production environments, when the signature is mandatory. - `X-test-token` (boolean, optional) Value of type `boolean` indicating whether the request is a test (`true`) or not (`false`). Always required as `true` when it's a test request. When using this header, it's possible to use `X-enforce-signature` as `true` and use `X-signature` to test the encrypted body validation. ### Path - `payout_id` (string, required) Identifier of the payout that contains the transaction you wish to cancel, returned in the `id` field of the response to [POST /v1/payouts](/developers/en/reference/online-payments/payouts/create-bank-transaction/post). - `transaction_id` (string, required) Identifier of the transaction you wish to cancel, returned in the `transactions[].id` field of the response to [POST /v1/payouts](/developers/en/reference/online-payments/payouts/create-bank-transaction/post). - `comments` (string, optional) Clear justification for the cancellation (avoid including sensitive personal information). This field supports history and audit. - `deleted_by` (string, optional) Unique identification of who performed the cancellation (user, system, etc.). This field supports history and audit. ## Response parameters This endpoint has no response body. ## Errors | Status | Error | Description | | ------- | ------- | ----------- | | 400 | invalid_payout_id | Invalid data was sent in the request body. The payout was not found. Try sending the request again, validating all fields. | | 400 | invalid_transaction_id | Invalid data was sent in the request body. The transaction was not found. Try sending the request again, validating all fields. | | 400 | invalid_signature | Invalid data was sent in the request body. Check if the secret was generated correctly and is registered with Mercado Pago. Also check if the body you are sending is the one that was encrypted. | | 400 | idempotency_key_required | Invalid data was sent in the request body. The idempotency key (`idempotency_key`) is missing. Try sending the request again, validating all fields. | | 400 | invalid_account | The `account` object was sent without the data required to identify the destination account. Provide `email` for a Mercado Pago account or the required bank details for an external account, including `number` and `bank_id`. For a Pix transfer, set `transactions.type` to `pix` and send the key details in `transactions.pix` instead of `account`. | | 400 | invalid_account_type | The `account_type` field was sent with an unsupported value. Accepted values are `checking_account` or `savings`. | | 401 | invalid_token | The value sent as Access Token is incorrect. Please check and try again with the correct value. | | 403 | forbidden | No permission to access the resource. | | 404 | not_found | Payout not found. Please check if you provided the correct payout ID. | | 412 | precondition_failed | The status of the transaction does not allow its cancelation. Only transactions with `status=pending` or `status=in_process` can be canceled. | | 500 | internal_server_error | An unexpected error occurred on the server. Try the request again. | | 502 | bad_gateway | An error occurred in the integration with an external service. Try the request again. | ## Request example ### cURL ```bash curl -X PUT \ 'https://api.mercadopago.com/v1/payouts/{payout_id}/transactions/{transaction_id}/cancel' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ -d '{ "comments": "delete because the payment was canceled", "deleted_by": "user_123" }' ```