AI resources
Cancel order by ID

This endpoint allows you to cancel an order created for Mercado Pago Point and its transactions using the reference ID obtained in the response to its creation. Orders with status=created and status=at_terminal can be canceled. If successful, a request for an order with status=created returns a response with status 200, while a request for an order with status=at_terminal returns a response with status 202, indicating that the request was accepted, but the cancellation will only take effect after a cancellation notification is received.

POST

https://api.mercadopago.com/v1/orders/{order_id}/cancel
Request parameters
Header
Authorization
string

REQUIRED

Access Token obtained through the developer panel. Must be sent in all requests.
x-allow-cancelable-status
string

CONDITIONALLY REQUIRED

This header is required to cancel an order with status=at_terminal, and its value must be exactly at_terminal. For orders with status=created, the header is ignored. Canceling an order with status=at_terminal als
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 payments. To ensure that eac
Path
order_id
string

REQUIRED

Identifier of the order to be canceled. This value is returned in the response to the request made to the endpoint POST /v1/orders.
Response parameters
id
string
Identifier of the order whose cancellation was requested.
user_id
string
ID of the Mercado Pago account that created the order.
type
string
Order type.
point: Order created for Mercado Pago Point payments.
external_reference
string
It is the external reference of the order, assigned when creating it. The maximum allowed limit is 64 characters, and the allowed characters are: uppercase and lowercase letters, numbers, and the symbols hyphen (-) and u
Errors

400Error.

empty_required_header

The X-Idempotency-Key header is required and was not sent. Make the request again including it.

bad_request

The order_id provided in the request path is not correct. Please confirm it and provide a valid ID to try again.

401Error.

unauthorized

The value sent as Access Token is incorrect. Please check and try again with the correct value.

404Error.

order_not_found

Order not found. Please check if you provided the correct order ID.

409Error.

idempotency_key_already_used

The value sent as the idempotency header has already been used. Please try the request again sending a new value.

cannot_cancel_order

The order status does not allow cancellation. Only orders with status=created or status=at_terminal can be canceled via API. To cancel an order with status=at_terminal, send the header x-allow-cancelable-status: at_terminal and use a terminal with a compatible software version. For more information about compatible terminal models, see Cancel an order. If the header is missing or invalid, or the terminal is not compatible, this error is returned.

order_already_canceled

The order has already been canceled.

500Error.

idempotency_validation_failed

Validation fail. Please try submitting the request again.

500

Internal server error. Please try submitting the request again.

Request
curl -X POST \
    'https://api.mercadopago.com/v1/orders/{order_id}/cancel'\
    -H 'Content-Type: application/json' \
       -H 'Authorization: Bearer APP_USR-4*********994754-12*********c73b4e1ac*********cef36b27c*********840' \
       -H 'x-allow-cancelable-status: at_terminal' \
       -H 'X-Idempotency-Key: b5651957-30d1-4b9d-bb16-cc8bfb0a6bf3' \
    
Response
{
  "id": "ORD0000ABCD222233334444555566",
  "user_id": "5238400195",
  "type": "point",
  "external_reference": "ext_ref_1234",
  "description": "Point Smart Mini",
  "expiration_time": "PT2M",
  "country_code": "MEX",
  "processing_mode": "automatic",
  "integration_data": {
    "application_id": "1234567890",
    "platform_id": "dev_1234567890",
    "integrator_id": "dev_123456",
    "sponsor": {
      "id": "446566691"
    }
  },
  "status": "canceled",
  "status_detail": "canceled",
  "created_date": "2024-09-10T14:26:42.109320977Z",
  "last_updated_date": "2024-09-10T14:26:42.109320977Z",
  "config": {
    "point": {
      "terminal_id": "NEWLAND_N950__SBX0000001",
      "screen_time": "PT15S",
      "print_on_terminal": "no_ticket"
    },
    "payment_method": {
      "default_type": "credit_card"
    }
  },
  "transactions": {
    "payments": [
      {
        "id": "PAY01J67CQQH5904WDBVZEM4JMEP3",
        "amount": "24.50",
        "status": "canceled",
        "status_detail": "canceled_by_api"
      }
    ]
  }
}