> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/codapay/hosted-payment-page-integration/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"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coda.co/codapay/hosted-payment-page-integration/authorize-and-capture-a-payment-separately/cancel-a-payment-request.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
