# Cashout Cancellation Endpoint

## Cashout Cancellation Endpoint

<mark style="color:red;">`DELETE`</mark> `https://api-stg.onekeypayments.com/v3/cashout/cancel`

This API allows you to cancel a cashout request. Only for cashouts in **PENDING** state.

#### Headers

| Name                                                | Type   | Description        |
| --------------------------------------------------- | ------ | ------------------ |
| Content-Type<mark style="color:red;">\*</mark>      | string | `application/json` |
| Payload-Signature<mark style="color:red;">\*</mark> | string | Control Signature  |

#### Request Body

| Name                                           | Type   | Description                                                                                   |
| ---------------------------------------------- | ------ | --------------------------------------------------------------------------------------------- |
| login<mark style="color:red;">\*</mark>        | string | Your D24 CASHOUTS API login key                                                               |
| pass<mark style="color:red;">\*</mark>         | string | Your D24 CASHOUTS API pass key                                                                |
| cashout\_id<mark style="color:red;">\*</mark>  | number | The ID of the cashout to cancel. It  is the one generated by D24 when the cashout was created |
| external\_id<mark style="color:red;">\*</mark> | string | The external ID of the cashout to cancel. It  is the one you sent when generating the cashout |

{% tabs %}
{% tab title="200 Cashout cancelled" %}

```java
{
    "cashout_status": 2,
    "cashout_status_description": "Canceled"
}
```

{% endtab %}

{% tab title="412 Error while cancelling the cashout. It can be cancelled only if its status is Pending" %}

```java
{
    "code": 510,
    "message": "Invalid status transition"
}
```

{% endtab %}
{% endtabs %}

## Cancel Cashout Request

The Cancel Cashout Request endpoint is only to cancel a cashout while it is still in PENDING state (it hasn't been sent for processing).

To do that, you will need to provide both the cashout ID on our end and the external ID you sent while creating the cashout.

{% hint style="info" %}
The method to use this endpoint has to be **DELETE**.
{% endhint %}

###

### Request Example

```java
// HEADERS
Content-Type: application/json 
Payload-Signature: 2e5023770760ea0a02230bff1a6dab934fe3b47a5e3d43854b58676600ee3868 

// BODY
{ 
    "login": "cashout_login", 
    "pass": "cashout_pass", 
    "cashout_id": 11954,
    "external_id": "cashoutID2134"
}
```

### Request Fields

| Field         | Format                | Description                                                                                                                                                            |
| ------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `login`       | String. Length 32 max | Your OKP **CASHOUTS** API Key, it can be found on the Merchant Panel: Settings -> API Access. Notice there are specific Cashout credentials                            |
| `pass`        | String. Length 32 max | Your OKP **CASHOUTS** API Passphrase, it can be found on the Merchant Panel: Settings -> API Access. Notice there are specific Cashout credentials                     |
| `cashout_id`  | Number                | Identifier of the cashout in the OKP end. Returned by the [Create Cashout Endpoint](/api-documentation/cashouts-api/endpoints/cashout-creation-endpoint.md)            |
| `external_id` | String                | The external ID of the cashout to cancel. It is the one you sent when [generating the cashout](/api-documentation/cashouts-api/endpoints/cashout-creation-endpoint.md) |

### Request Payload Signature

The Payload-Signature of the Cashout Status Endpoint is calculated by hashing the JSON payload of the request using HMAC256 and your secret key (API Signature) to encrypt it.

[Click here](/api-documentation/cashouts-api/technical-and-security-aspects/calculating-the-payload-signature.md) for further instructions.

## Cancel Cashout Response

### Response Example

```java
// Cashout cancelled successfully
{
    "cashout_status": 2,
    "cashout_status_description": "Canceled"
}

// Cashout not found
{
    "code": 509,
    "message": "Cashout not found with this ID"
}

// The cashout can't be cancelled because its status is not Pending
{
    "code": 510,
    "message": "Invalid status transition"
}
```

**Response fields**

| Field                        | Format | Type    | Description                                                                                                              |
| ---------------------------- | ------ | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `cashout_status`             | Number | Success | If shown, it is the new[ status code](/api-documentation/cashouts-api/api-codes.md#cashout-status-codes) of the cashout. |
| `cashout_status_description` | String | Success | If shown, it described the new status  of the cashout.                                                                   |
| `code`                       | Number | Error   | Error code                                                                                                               |
| `message`                    | String | Error   | Error description                                                                                                        |


---

# Agent Instructions: 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:

```
GET https://apidocs.onekeypayments.com/api-documentation/cashouts-api/endpoints/cashout-cancel-endpoint.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
