# Create Wallet

<mark style="color:blue;">`POST`</mark> `/wallet/create`

Create a new wallet with your preferred currency and label.

**Headers**

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

**Body**

<table><thead><tr><th width="160">Name</th><th width="80">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>label</code><mark style="color:red;">*</mark></td><td>string</td><td>Label of wallet</td></tr><tr><td><code>postback_url</code></td><td>string</td><td>Destination URL for sending post</td></tr></tbody></table>

**Response**

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

```json
{
    "id": 0,
    "label": "string",
    "postback_url": "http://example.com",
    "currency": "string",
    "address": "string",
    "created_at": "2019-08-24T14:15:22Z",
    "expires_at": "2019-09-24T14:15:22Z",
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "detail": "Currency does not exist"
}
```

```json
{
    "detail": "Max length of label is 255 characters"
}
```

```json
{
    "detail": "Max length of postback_url is 255 characters"
}
```

{% 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/wallet/create" \
     -H "Content-Type: application/json" \
     -H "X-API-KEY: YOUR_API_KEY" \
     -d '{
       "currency": "USDTBEP20",
       "label": "Order #123",
       "postback_url": "https://example.com/postback"
     }'
```

{% endtab %}

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

```python
import requests

def create_wallet(currency, label, postback_url=None):
    url = "https://api.nord-pay.com/wallet/create"
    headers = {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
    }
    payload = {
        "currency": currency,
        "label": label
    }
    if postback_url:
        payload["postback_url"] = postback_url

    resp = requests.post(url, json=payload, headers=headers)
    resp.raise_for_status()
    return resp.json()

# usage:
wallet = create_wallet(
    currency="USDTBEP20",
    label="Order #123",
    postback_url="https://example.com/postback"
)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function createWallet(
    string $currency,
    string $label,
    string $postbackUrl = null
): array {
    $url = "https://api.nord-pay.com/wallet/create";
    $payload = [
        "currency" => $currency,
        "label"    => $label
    ];
    if ($postbackUrl) {
        $payload["postback_url"] = $postbackUrl;
    }

    $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:
$wallet = createWallet(
    "USDTBEP20",
    "Order #123",
    "https://example.com/postback"
);
```

{% endtab %}

{% tab title="JavaScript" %}

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

// usage:
createWallet({
  currency: "USDTBEP20",
  label: "Order #123",
  postback_url: "https://example.com/postback"
}).then(wallet => {
  // work with wallet
});
```

{% endtab %}

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

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

async function createWallet({ currency, label, postback_url }) {
  const { data } = await axios.post(
    "https://api.nord-pay.com/wallet/create",
    {
      currency,
      label,
      ...(postback_url && { postback_url })
    },
    {
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY"
      }
    }
  );
  return data;
}

// usage:
createWallet({
  currency: "USDTBEP20",
  label: "Order #123",
  postback_url: "https://example.com/postback"
}).then(wallet => {
  // work with wallet
});
```

{% endtab %}
{% endtabs %}
