AI resources
Cancel order by ID

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

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

REQUIRED

Access token to authenticate the request. For more information, see the [Authentication](https://www.mercadopago.com/developers/en/docs/your-integrations/credentials) documentation.
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 orders. To ensure that each
Path
order_id
string

REQUIRED

ID of the order that is being canceled. This value is returned in the response to the 'Create order' ("/v1/orders") request.
Response parameters
id
string
Identifier of the order created in the request, automatically generated by Mercado Pago.
processing_mode
string

REQUIRED

Order processing mode. For payments with Checkout Pro, the only possible value is "manual".
manual: Order's processing will be made manually. This mode is used by Checkout Pro, allowing the order to be processed later through its payment flow.
external_reference
string
It is an external reference of the order. It can be, for example, a hashcode from the Central Bank, functioning as an identifier of the transaction origin. This field must have a maximum of 64 characters and can only be
total_amount
string
Total amount to be paid.
Errors

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.

404Error. Order not found.

order_not_found

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

409Conflict.

order_already_canceled

Cannot cancel order. Only orders with status "created" or "action_required" can be canceled. Check the message returned in the error details to find out what the problem was and try again.

500Generic error.

internal_error

Generic 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 ' \
       -H 'X-Idempotency-Key: 4f4511df-f544-408c-b27a-0558d34106b0' \
    
Response
{
  "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": "UY",
  "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",
        "payment_method": {
          "id": "master",
          "type": "credit_card",
          "token": "12345",
          "installments": 1,
          "statement_descriptor": "My Store"
        }
      }
    ]
  },
  "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"
    }
  ]
}