> For the complete documentation index, see [llms.txt](https://coda-payments.gitbook.io/coda-public-technical-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-component-integration/cards/authorize-and-capture-a-payment-separately/cancel-a-payment-request.md).

# Cancel a Payment Request

This reference describes the server-side API used to cancel a payment request. Use this endpoint to terminate a transaction that has not yet been finalized.

### Endpoint

Method: `POST`

<table data-full-width="true"><thead><tr><th width="131.78515625">Environment</th><th>Base URL</th></tr></thead><tbody><tr><td>Sandbox</td><td><code>https://sandbox.codapayments.com/airtime/api/restful/v2.0/Payment/Cancel</code></td></tr><tr><td>Production</td><td><code>https://airtime.codapayments.com/airtime/api/restful/v2.0/Payment/Cancel</code></td></tr></tbody></table>

### Request Body

The request body must be sent in JSON format and include the following parameters:

<table><thead><tr><th width="289.85546875">Parameter</th><th width="93.06640625">Type</th><th width="108.59765625">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>cancelPaymentRequest.apiKey</code></td><td>string</td><td>Yes</td><td>Your Coda API key for authentication.</td></tr><tr><td><code>cancelPaymentRequest.projectId</code></td><td>string</td><td>Yes</td><td>The unique identifier for your project.</td></tr><tr><td><code>cancelPaymentRequest.txnId</code></td><td>string</td><td>Yes</td><td>The transaction ID associated with the payment to be captured.</td></tr></tbody></table>

**Example Request**

```json
{
  "cancelPaymentRequest": {
    "apiKey": "your_api_key_here",
    "projectId": "your_project_id",
    "txnId": "123456789"
  }
}
```

### Response

A successful request returns a confirmation that the capture request has been acknowledged.

**Example Response**

```json
{
  "cancelPaymentRequest": {
    "status": "received",
    "txnId": "123456789"
  }
}
```
