Create cancellation - Cancellations - Mercado Pago Developers
What are you looking for?

Do not know how to start integrating? 

Check the first steps
Create cancellation

PUT

https://api.mercadopago.com/v1/payments/{payment_id}
This endpoint allows the cancellation of a purchase for a specific payment, provided the payment status is `in_process`, `pending`, or `authorized`. Upon success, the request will return a status code 200.
Request's parameters
PATH
payment_id
string

REQUIRED

Payment Identification Number (ID).
BODY
status
String

REQUIRED

Payment Status - This field exclusively accepts the status `cancelled`.
Response parameters
id
number
Payment identifier.
date_created
string
Cancelation creation date.
date_approved
string
Cancelation approved date.
date_last_updated
string
Last updated date.
Errors

400Error

2018

The action requested is not valid for the current payment state - This error occurs when an attempt is made to change a payment's status to canceled when the initial status is not 'in_process', 'pending', or 'authorized.

2016

Invalid Status for Update - This error occurs when, for example, an attempt is made to change the status of a payment from `in_process` to `approved`. This request only accepts the status `cancelled`. Please review the parameter submitted and make a new request with the correct value.

4017

Status attribute can't be null - If this error appears, please review the `status` parameter to ensure that it is set to `cancelled` and not left empty. Confirm the status is correctly populated before submitting a new request.

401Error

5

Must provide your access token - This error is displayed when an attempt is made to make a request without sending the Access Token. Please check the request parameters and ensure the necessary information is provided.

Unauthorized

Invalid access token - If this error appears, please review the Access Token provided in your request to ensure it is correct. After verifying the token, submit a new request.

403Error

4

Forbidden - The caller is not authorized to access this resource. This error occurs when attempting to change a payment status from `authorized` to `approved`. The same issue arises when trying to change a payment status from `in_process` to `rejected` or `approved`, or from `authorized` to `approved`. In this case, ensure the status being set is strictly `cancelled` and submit a new request.

404Error

2000

Payment not found - This error is returned when the payment ID entered is incorrect or does not exist. Please review the `payment_id` parameter and ensure that the number entered is correct.

Request
curl -X PUT \
    'https://api.mercadopago.com/v1/payments/{payment_id}'\
    -H 'Content-Type: application/json' \
       -H 'Authorization: Bearer TEST-7719*********832-03141*********ec9309854*********f1e54b5-1*********' \
    -d '{
  "status": "cancelled"
}'
Sample answer
{
  "id": 18746874919,
  "date_created": "2021-12-10T17:13:23.000-04:00",
  "date_approved": null,
  "date_last_updated": "2021-12-10T17:31:34.000-04:00",
  "date_of_expiration": "2021-12-13T22:59:59.000-04:00",
  "money_release_date": null,
  "operation_type": "regular_payment",
  "issuer_id": null,
  "payment_method_id": "bolbradesco",
  "payment_type_id": "ticket",
  "status": "cancelled",
  "status_detail": "by_collector",
  "currency_id": "BRL",
  "description": "Meu produto",
  "live_mode": null,
  "sponsor_id": null,
  "authorization_code": null,
  "money_release_schema": null,
  "taxes_amount": 0,
  "counter_currency": null,
  "brand_id": null,
  "shipping_amount": 0,
  "pos_id": null,
  "store_id": null,
  "integrator_id": null,
  "platform_id": null,
  "corporation_id": null,
  "collector_id": null,
  "payers": [
    {
      "first_name": null,
      "last_name": null,
      "email": "test_user_80507629@testuser.com",
      "type": "collector",
      "identification": [
        {
          "number": "32659430",
          "type": "DNI"
        }
      ],
      "phone": [
        {
          "area_code": null,
          "number": null,
          "extension": null
        }
      ],
      "entity_type": null,
      "id": "1003743392",
      "operator_id": null
    }
  ],
  "marketplace_owner": null,
  "metadata": [
    {}
  ],
  "additional_info": [
    {
      "items": [
        {
          "id": "234",
          "title": {
            "en": "My product",
            "pt": "Meu produto",
            "es": "Mi producto"
          },
          "description": {
            "en": "E-commerce store cellphone",
            "pt": "Celular da loja online",
            "es": "Celular de la tienda online"
          },
          "picture_url": "https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
          "category_id": "art",
          "quantity": "1",
          "unit_price": "75.76"
        }
      ]
    }
  ],
  "order": [
    {
      "type": "mercadopago",
      "id": "3754501423"
    }
  ],
  "external_reference": "firstname@gmail.com",
  "transaction_amount": 75.76,
  "transaction_amount_refunded": 0,
  "coupon_amount": 0,
  "differential_pricing_id": null,
  "deduction_schema": null,
  "barcode": [
    {
      "content": "23791883300000075763380250600221946300633330"
    }
  ],
  "installments": 1,
  "transaction_details": [
    {
      "payment_method_reference_id": "6002219463",
      "verification_code": "6002219463",
      "net_received_amount": 0,
      "total_paid_amount": 75.76,
      "overpaid_amount": 0,
      "external_resource_url": "https://www.mercadopago.com/mlb/payments/beta/ticket/helper?payment_id=18746874919&payment_method_reference_id=6002219463&caller_id=1003743392&hash=6a8c570f-9c39-4a5c-9b55-85ae1b724bf",
      "installment_amount": 0,
      "financial_institution": null,
      "payable_deferral_period": null,
      "acquirer_reference": null
    }
  ],
  "fee_details": [
    {}
  ],
  "charges_details": [
    {}
  ],
  "captured": true,
  "binary_mode": true,
  "call_for_authorize_id": null,
  "statement_descriptor": null,
  "card": [
    {}
  ],
  "notification_url": "https://webhook.site/17a3a5ce-28d4-4b4f-ba3f-a7595c17c6d8",
  "refunds": [
    {}
  ],
  "processing_mode": "aggregator",
  "merchant_account_id": null,
  "merchant_number": null,
  "acquirer_reconciliation": [
    {}
  ],
  "point_of_interaction": [
    {
      "type": "Unspecified",
      "business_info": [
        {
          "unit": "online_payments",
          "sub_unit": "checkout_pro"
        }
      ]
    }
  ]
}