This endpoint allows to cancel an order that has not yet been paid using the ID obtained in the response to its creation. Only orders in created or action_required status can be canceled. Cancellation releases any reserved balance when applicable. In case of success, the request will return a response with status 200.
POST
REQUIRED
REQUIRED
REQUIRED
REQUIRED
manual.400Request error.
empty_required_header
The X-Idempotency-Key header is required and was not sent. Make the request again including it.
401Error. Access Token not authorized.
401
The value sent as Access Token is incorrect. Please check and try again with the correct value.
invalid_credentials
There is no support for test credentials. Use test users with production credentials for the sandbox environment and your production credentials for the production environment.
403Error. Forbidden.
forbidden
The application does not have permission to access this resource. Please check that the Access Token used has the necessary permissions and scopes for this operation.
PA_UNAUTHORIZED_RESULT_FROM_POLICIES
The account is blocked and its API keys have been revoked. At least one policy evaluated by the Policy Agent returned an UNAUTHORIZED result.
404Error. Order not found.
order_not_found
Order not found. Please check if you provided the correct order ID.
409Conflict.
order_already_canceled
The order has already been canceled.
cannot_cancel_order
The order status does not allow cancellation. Only orders with status action_required or created can be canceled.
429Request limit exceeded.
too_many_requests
Client ID blocked by the gateway because the request limit for the ID in question was reached. Read the Retry-After header from the response and wait the indicated number of seconds before retrying. For greater resilience, implement exponential backoff with jitter, that is, increase the wait time with each new attempt and add a random variation to avoid simultaneous retransmission of multiple requests.
usage_quota_exceeded
Quota enforced by the API backend because the per-client request limit was reached. Read the Retry-After header from the response and wait the indicated number of seconds before retrying. For greater resilience, implement exponential backoff with jitter, that is, increase the wait time with each new attempt and add a random variation to avoid simultaneous retransmission of multiple requests.
500Generic error.
internal_error
Generic error. Please try submitting the request again.
curl -X POST \
'https://api.mercadopago.com/v1/orders/{order_id}/cancel'\
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ' \
-H 'X-Idempotency-Key: 5221bfd1-4e30-4eb9-8931-384bbdd97bab' \
{
"id": "ORD01J49MMW3SSBK5PSV3DFR32959",
"processing_mode": "manual",
"external_reference": "ext_ref_1234",
"total_amount": "50.00",
"integration_data": {
"application_id": "1234",
"integrator_id": "dev_123",
"platform_id": "1234567890",
"sponsor": {
"id": "446566691"
}
},
"user_id": "12345",
"created_date": "2024-08-26T13:06:51.045317772Z",
"last_updated_date": "2024-08-26T13:06:51.045317772Z",
"country_code": "COL",
"type": "online",
"status": "canceled",
"status_detail": "canceled_transaction",
"capture_mode": "automatic_async",
"transactions": {
"payments": [
{
"id": "PAY01J67CQQH5904WDBVZEM4JMEP3",
"amount": "24.50",
"reference_id": "01JEVQM899NWSQC4FYWWW7KTF9",
"status": "canceled",
"status_detail": "canceled_transaction",
"expiration_time": "P3Y6M4DT12H30M5S",
"payment_method": {
"id": "master",
"type": "credit_card",
"token": "12345",
"installments": 1,
"statement_descriptor": "My Store",
"financial_institution": "1051"
}
}
]
},
"client_token": "eyJhbGciOiJSUzI1NiIs...",
"description": "Smartphone",
"items": [
{
"external_code": "ITEM-001",
"title": "Product 001",
"description": "Product description",
"category_id": "travels",
"picture_url": "https://example.com/img.jpg",
"quantity": 1,
"unit_price": "1000.00",
"type": "travel",
"warranty": true,
"event_date": "2014-06-28T16:53:03.176-04:00"
}
]
}