# Cancel Payment API
source: https://developer.mastercard.com/cross-border-services/documentation/api-ref/transaction-apis/cancel-payment-api/index.md

Alert: If you are a Customer contracted with MTS EU or MTS UK, refer to the corresponding EU and UK specification inside the swagger file to ensure compliance with the relevant jurisdiction based Regulatory Technical Standards (either EU or UK) derived from the Revised Payment Services Directive (PSD2).

## Environment Domains {#environment-domains}

* Sandbox/MTF
* Sandbox-EU
* Sandbox-UK
* MTF-EU
* MTF-UK
* Production
* Production-EU
* Production-UK

```Sandbox/MTF
https://sandbox.api.mastercard.com/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

```Sandbox-EU
https://sandbox.api.xbs.mastercard.eu/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

```Sandbox-UK
https://sandbox.api.xbs.mastercard.uk/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

```MTF-EU
https://mtf.api.xbs.mastercard.eu/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

```MTF-UK
https://mtf.api.xbs.mastercard.uk/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

```Production
https://api.mastercard.com/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

```Production-EU
https://api.xbs.mastercard.eu/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

```Production-UK
https://api.xbs.mastercard.uk/send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel
```

Note: **Sandbox** and **MTF** environments share the same url but are differentiated by partner id.

You can use this API to cancel a request for a transaction that is in PENDING status.
Any payment with a payment status as "Pending" and Pending Stage as "Insufficient Balance" can be cancelled.
Additionally, for cash-out and some mobile money providers, the payment with status "Pending" can be cancelled irrespective of the Pending stage of that payment.

## API {#api}

[Open Specification](https://static.developer.mastercard.com/content/cross-border-services/swagger/cross_border-swagger.yaml)

Alternatively, here is a tabular view of the request/ response parameter:
[Cancel_Payment_Specifications.pdf](https://static.developer.mastercard.com/content/cross-border-services/uploads/Cancel_Payment_Specifications.pdf) (349KB)   


API Reference: `GET /send/v1/partners/{partner-id}/crossborder/{payment-id}/cancel`

* **Formats supported** : XML/ JSON   
* **HTTP Version**: 1.0/ 1.1
* **Required HTTP header parameters** :   
  content-type : Format of the inbound content being submitted. example: application/json   
  content-length: Length of the inbound content body in octets.   
  Accept: Format of the expected response must be provided in this header field. Example - application/json

## API Convention {#api-convention}

Take a look at the [API Conventions](https://developer.mastercard.com/cross-border-services/documentation/api-basics/index.md#api-conventions) for general guidelines.

## Payload Encryption {#payload-encryption}

All the request payload sent by you to Mastercard must be encrypted. And you will need to decrypt the payload sent by Mastercard.   

For more detailed information on payload **Encryption/ Decryption** , please see [here](https://developer.mastercard.com/cross-border-services/documentation/api-basics/index.md#transport-encryption)

## Error Codes {#error-codes}

Please refer to complete list of error codes [here](https://developer.mastercard.com/cross-border-services/documentation/code-and-formats/index.md).

For information about the HTTP response codes that may be returned for your API requests, see [HTTP Response Codes](https://developer.mastercard.com/cross-border-services/documentation/code-and-formats/index.md).

## Next step {#next-step}

Proceed to [Cancel Payment API: Sandbox Testing](https://developer.mastercard.com/cross-border-services/documentation/testing/cancel-payment-api/index.md) to test the Cancel Payment API in the Sandbox environment.
