> For the complete documentation index, see [llms.txt](https://apidocs.onekeypayments.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.onekeypayments.com/guides/cashouts/create-cashouts/api-integration.md).

# API Integration

Our Cashouts API enable merchants to generate local withdrawals in every country that D24 operates. In order to do so, **merchants need provide the in each transaction the local banking details required**.

Therefore, it is important to properly understand the  <a href="/pages/-MA9W0JDYr7ewGa7xDTk" class="button primary" data-icon="earth-americas">Countries validations</a> within each market that the merchant is willing to operate.

***

### Integration flow

{% stepper %}
{% step %}

### Cashout creation

{% tabs %}
{% tab title="Example request" %}
Merchants need to send **all the required local information** for creating the transaction.

In this example, in :flag\_mx: Mexico we need the document, the bank account, the beneficiary name and last name.

<pre class="language-sh"><code class="lang-sh">curl -L \
  --request POST \
<strong>  --url 'https://api-stg.onekeypayments.com/v3/cashout' \
</strong>  --header 'Content-Type: application/json' \
  --header 'Payload-Signature: text' \
  --data '{
    "login": "your_cashout_login",
    "pass": "your_cashout_pass",
    "external_id": "30000000001",
    "country": "MX",
    "currency": "MXN",
    "amount": 100,
    "document_id": "848392783",
    "bank_account": "021790064060296642",
    "beneficiary_name": "Luis",
    "beneficiary_lastname": "Miguel",
    "notification_url": "https://merchant.site/webhooks/onekeypayments",
    "type": "json"
}'
</code></pre>

{% endtab %}

{% tab title="Example response" %}
In response, merchants receive the transaction identifier (`cashout_id`).

```json
{
  "cashout_id": "8405147"
}
```

{% endtab %}
{% endtabs %}

> For technical details, please visit the API Reference <a href="/spaces/0lbPmhFPUb55BAkK3G6F/pages/BJVC40qCkbDFJpgxozD4" class="button primary" data-icon="pencil">Create a cashout</a>
> {% endstep %}

{% step %}

### Webhook notification

Each time that a cashout changes its status we will send a webhook notification.

<pre class="language-http" data-title="Example notification"><code class="lang-http">    date=2020-03-12%2020%3A26%3A11
    &#x26;bank_reference_id=
    &#x26;comments=
    &#x26;external_id=cashoutV35381
    &#x26;control=A4CFF64E78C4BD01F8BFCA4AFF04632EC4A33CC61BD6BBD156BA1289897892EB
<strong>    &#x26;cashout_id=8405147
</strong>    &#x26;status_reason=
</code></pre>

> Please visit <a href="/pages/IDRgrfdaoiwf4YdhGjLU" class="button primary" data-icon="message-medical">Notifications</a>
> {% endstep %}

{% step %}

### Retrieve the cashout status

By creating a request to the cashout status endpoint you will capable od retrieving the final status of the transaction.

{% tabs %}
{% tab title="Example request" %}

<pre class="language-sh"><code class="lang-sh">curl -L \
  --request POST \
  --url 'https://api-stg.onekeypayments.com/v3/cashout/status' \
  --header 'Content-Type: application/json' \
  --header 'Payload-Signature: text' \
  --data '{
    "login": "your_cashout_login",
    "pass": "your_cashout_pass",
<strong>    "cashout_id": 8405147
</strong>  }'
</code></pre>

{% endtab %}

{% tab title="Example response" %}

```json
{
  "cashout_status": 1,
  "cashout_status_description": "Completed"
}
```

For more information regarding the **`cashout_status`**, please visit <a href="/pages/M0hPMNs7uaCI6Dbi76RG#cashout-status-codes" class="button primary">Cashout status codes</a>
{% endtab %}
{% endtabs %}

> For technical details, please visit the API Reference <a href="/spaces/0lbPmhFPUb55BAkK3G6F/pages/kJcyiJ99exMkjrYoRSSS" class="button primary" data-icon="pencil">Get a cashout status</a>
> {% endstep %}
> {% endstepper %}

{% hint style="info" %}

### Additional flows

Note that the flow described above corresponds to a regular cashout completion flow.

Within the cashout lifecycle, cashouts can also be **CANCELLED** or put **ON\_HOLD** status.\
For more information visit the API References:&#x20;

* <a href="/spaces/0lbPmhFPUb55BAkK3G6F/pages/Qm5CcCRfLaVFFaSROT0p" class="button secondary" data-icon="delete-left">Cashout cancellation</a>
* <a href="/spaces/0lbPmhFPUb55BAkK3G6F/pages/9ef5Y8mqB6qpEQMpa2gB" class="button secondary" data-icon="arrows-rotate-reverse">Update to On Hold</a>
  {% endhint %}
