Cancel an order and its transactions using the reference ID obtained in the response to its creation. Only an order in "status=action_required" or "status=created" can be canceled. In case of success, the request will return a response with status 200.
POST
REQUIRED
REQUIRED
REQUIRED
400Request error.
invalid_path_param
The "order_id" provided in the request path is not correct. Please confirm it and provide a valid ID to try again.
empty_required_header
The "X-Idempotency-Key" header is required and was not sent. Make the requisition again including it.
invalid_idempotency_key_length
The value sent in the "X-Idempotency-Key" header exceeded the allowed size. The header accepts values between 1 and 64 characters.
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.
404Error. Order not found.
order_not_found
Order not found. Please check if you provided the correct order ID.
409Some specific system rule does not allow the action to be performed due to defined restrictions.
cannot_cancel_order
The status of the order does not allow its cancelation. Only orders with "status=action_required" or "status=created" can be canceled.
order_already_canceled
The order has already been canceled.
idempotency_key_already_used
The value sent as the idempotency header ("X-Idempotency-Key") has already been used. Please try the request again sending a new value.
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 APP_USR-4*********782856-12*********f202ca494*********f0baa4bb3*********648' \
-H 'X-Idempotency-Key: 68451ea4-8ad2-4731-b30a-a4f5eaa47107' \
{
"id": "ORD01J49MMW3SSBK5PSV3DFR32959",
"processing_mode": "automatic",
"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": "CO",
"type": "online",
"status": "canceled",
"status_detail": "canceled_transaction",
"capture_mode": "automatic",
"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"
}
}
]
},
"description": "Smartphone",
"items": [
{
"title": "Smartphone",
"unit_price": "24.50",
"quantity": 4,
"description": "Smartphone",
"external_code": "1234",
"picture_url": "https://http2.mlstatic.com/resources/frontend/statics/growth-sellers-landings/device-mlb-point-i_medium2x.png",
"category_id": "MLB1055",
"type": "MLB1055",
"warranty": "true",
"event_date": "2014-06-28T16:53:03.176-04:00"
}
]
}