# Withdraw Funds

### To initiate a withdrawal, the process is carried out in two steps:

1. You initiate a withdrawal by sending a request to [`/balance/withdraw/request`](#id-1.-create-a-withdraw-request). The API returns a unique `identifier` for that request.
2. You finalize the payout by calling [`/balance/withdraw/confirm`](#id-2.-confirm-the-withdrawal) passing only the previously received `identifier`.

***

## 1. Create a withdraw Request

<mark style="color:blue;">`POST`</mark> `/balance/withdraw/request`

Create a Withdraw Request and get some interesting data.

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| X-API-KEY    | `<token>`          |

**Body**

<table><thead><tr><th width="130">Name</th><th width="100">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>currency</code><mark style="color:red;">*</mark></td><td>string</td><td><a href="../supported-currencies-and-networks">Currency</a></td></tr><tr><td><code>address</code><mark style="color:red;">*</mark></td><td>string</td><td>Address to send</td></tr><tr><td><code>amount</code><mark style="color:red;">*</mark></td><td>number</td><td>Amount to send</td></tr></tbody></table>

**Response**

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

```json
{
  "identifier": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "currency": "USDTBEP20",
  "address": "0x...",
  "amount": 0,
  "amount_usd": 0,
  "service_fee": 0,
  "service_fee_usd": 0,
  "expires_at": "2025-06-12T10:04:32.962319Z"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "detail": "<CURRENCY> is not available for withdraw at this moment"
}
```

```json
{
    "detail": "Amount is less than minimum withdraw amount for <CURRENCY> (<CURRENCY.MIN_WITHDRAW>)"
}
```

```json
{
    "detail": "Withdraw request not found"
}
```

```json
{
    "detail": "Withdraw request expired"
}
```

```json
{
    "detail": "Not enough balance"
}
```

{% endtab %}

{% tab title="422" %}

```json
{
    "detail": [
        {
            "loc": [],
            "msg": "string",
            "type": "string"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Amount sent to the wallet = amount - service fee
{% endhint %}

**Example**

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST "https://api.nord-pay.com/balance/withdraw/request" \
     -H "Content-Type: application/json" \
     -H "X-API-KEY: YOUR_API_KEY" \
     -d '{
       "currency": "USDTBEP20",
       "address": "0x1234...abcd",
       "amount": 100.0
     }'
```

{% endtab %}

{% tab title="Python (requests)" %}

```python
import requests

def create_withdraw_request(currency, address, amount):
    url = "https://api.nord-pay.com/balance/withdraw/request"
    headers = {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
    }
    payload = {
        "currency": currency,
        "address": address,
        "amount": amount
    }
    resp = requests.post(url, json=payload, headers=headers)
    resp.raise_for_status()
    return resp.json()

# usage:
request_data = create_withdraw_request(
    currency="USDTBEP20",
    address="0x1234...abcd",
    amount=100.0
)
# request_data["identifier"] — UUID for confirming
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function createWithdrawRequest(
    string $currency,
    string $address,
    float $amount
): array {
    $url = "https://api.nord-pay.com/balance/withdraw/request";
    $payload = [
        "currency" => $currency,
        "address"  => $address,
        "amount"   => $amount
    ];

    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST           => true,
        CURLOPT_POSTFIELDS     => json_encode($payload),
        CURLOPT_HTTPHEADER     => [
            "Content-Type: application/json",
            "X-API-KEY: YOUR_API_KEY"
        ],
    ]);
    $response = curl_exec($ch);
    curl_close($ch);

    return json_decode($response, true);
}

// usage:
$req = createWithdrawRequest("USDTBEP20", "0x1234...abcd", 100.0);
// $req["identifier"] — UUID for confirming
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
async function createWithdrawRequest({ currency, address, amount }) {
  const response = await fetch(
    "https://api.nord-pay.com/balance/withdraw/request",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
      },
      body: JSON.stringify({ currency, address, amount })
    }
  );
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  return response.json();
}

// usage:
createWithdrawRequest({
  currency: "USDTBEP20",
  address: "0x1234...abcd",
  amount: 100.0
}).then(req => {
  // req.identifier — UUID for confirm
});
```

{% endtab %}

{% tab title="Node.js (axios)" %}

```javascript
const axios = require('axios');

async function createWithdrawRequest({ currency, address, amount }) {
  const { data } = await axios.post(
    "https://api.nord-pay.com/balance/withdraw/request",
    { currency, address, amount },
    {
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
      }
    }
  );
  return data;
}

// usage:
createWithdrawRequest({
  currency: "USDTBEP20",
  address: "0x1234...abcd",
  amount: 100.0
}).then(req => {
  // req.identifier — UUID for confirm
});
```

{% endtab %}
{% endtabs %}

***

## 2. Confirm the Withdrawal

<mark style="color:blue;">`POST`</mark> `/balance/withdraw/confirm`

Confirming Withdraw Request and sent money.

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| X-API-KEY    | `<token>`          |

**Body**

<table><thead><tr><th width="140">Name</th><th width="80">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>identifier</code><mark style="color:red;">*</mark></td><td>string</td><td>UUID Of your Withdraw Request</td></tr></tbody></table>

**Response**

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

```json
{
    "detail": "Withdrawal request created and waiting for admin approval", 
    "status": "pending,
    "id": 1
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "detail": "Withdraw request not found"
}
```

```json
{
    "detail": "Withdraw request expired"
}
```

```json
{
    "detail": "Not enough balance"
}
```

{% endtab %}

{% tab title="422" %}

```json
{
    "detail": [
        {
            "loc": [],
            "msg": "string",
            "type": "string"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

**Example**

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST "https://api.nord-pay.com/balance/withdraw/confirm" \
     -H "Content-Type: application/json" \
     -H "X-API-KEY: YOUR_API_KEY" \
     -d '{
       "identifier": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
     }'
```

{% endtab %}

{% tab title="Python (requests)" %}

```python
import requests

def confirm_withdraw(identifier):
    url = "https://api.nord-pay.com/balance/withdraw/confirm"
    headers = {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
    }
    payload = { "identifier": identifier }
    resp = requests.post(url, json=payload, headers=headers)
    resp.raise_for_status()
    return resp.json()

# usage:
result = confirm_withdraw("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
# result["tx_hash"], result["url"], etc.
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function confirmWithdraw(string $identifier): array {
    $url = "https://api.nord-pay.com/balance/withdraw/confirm";
    $payload = [ "identifier" => $identifier ];

    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST           => true,
        CURLOPT_POSTFIELDS     => json_encode($payload),
        CURLOPT_HTTPHEADER     => [
            "Content-Type: application/json",
            "X-API-KEY: YOUR_API_KEY"
        ],
    ]);
    $response = curl_exec($ch);
    curl_close($ch);

    return json_decode($response, true);
}

// usage:
$confirm = confirmWithdraw("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
// $confirm["tx_hash"], $confirm["url"], $confirm["detail"]
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
async function confirmWithdraw({ identifier }) {
  const response = await fetch(
    "https://api.nord-pay.com/balance/withdraw/confirm",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
      },
      body: JSON.stringify({ identifier })
    }
  );
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  return response.json();
}

// usage:
confirmWithdraw({ identifier: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" })
  .then(res => {
    // res.tx_hash, res.url, res.detail
  });
```

{% endtab %}

{% tab title="Node.js (axios)" %}

```javascript
const axios = require('axios');

async function confirmWithdraw({ identifier }) {
  const { data } = await axios.post(
    "https://api.nord-pay.com/balance/withdraw/confirm",
    { identifier },
    {
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
      }
    }
  );
  return data;
}

// usage:
confirmWithdraw({ identifier: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" })
  .then(res => {
    // res.tx_hash, res.url, res.detail
  });
```

{% endtab %}
{% endtabs %}
