# Create Wallet

{% hint style="info" %}
**API Endpoint**

**POST** [**/client/wallets/save**](https://xpay.stream/client/wallets/save)
{% endhint %}

***

{% hint style="info" %}
**Request Headers:**

Authorization: Bearer [\<access\_token>](https://docs.xpay.stream/authentication-api)

Content-Type: application/json\
\
**Request Body:**

{% code lineNumbers="true" %}

```json
{
    "tag" : "<optional_your_tag>",
    "lightning": "on"// for BTC lightning, else for TRON
}
```

{% endcode %}
{% endhint %}

{% hint style="success" %}
**Success Response**\
You will get under the created wallet details under th&#x65;*`success.data`*

Wallet Address: *`success.data.address.base58`*

Wallet Identifier: *`success.data.uuid`*

**`Sample Below:`**

{% code lineNumbers="true" fullWidth="true" %}

```json
{
    "success": {
        "message": "Wallet Saved",
        "data": {
            "address": {
                "base58": "TYViWxHG5wgnnmCMfVfwTvp3KGkRt4qk7V",
                "hex": "41F717E263E541FDB3C69F7F5062D0573EFF8A9760"
            },
            "username": "<your_email>",
            "uuid": "dd249743-22a3-42fb-8d86-3e27287272e2",
            "createdAt": 1697182976392,
            "tag": "<optional_your_tag>",
            "balances": {
                "tokenBalanceRaw": 0,
                "tokenBalance": 0,
                "tronBalanceSun": 0,
                "tronBalance": 0
            }
        }
    },
    "uuid": "7ac71a3c-7aa2-440c-a379-bcf416fd74e9"
}
```

{% endcode %}
{% endhint %}

***

{% tabs %}
{% tab title="CURL Example" %}
{% code lineNumbers="true" fullWidth="true" %}

```bash
curl 'https://apis.xpay.stream/client/wallets/save' \
  -H 'Content-Type: application/json'               \
  -H 'Authorization: Bearer <access_token>'         \
  --data-raw '{"tag":"<your_tag>"}'              
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS Example" %}
{% code lineNumbers="true" %}

```javascript
// npm i cross-fetch
const fetch = require("cross-fetch");

const API_URL = "https://apis.xpay.stream/client/wallets/save";

const method = "POST";

const headers = { 
    "Content-Type": "application/json",
    "Authorization": "Bearer <access_token>"
};

const body = JSON.stringify({ 
    tag: "<your_tag>",
    lightning: "on" // for BTC Lightning or off for TRON 
});

fetch(API_URL, { headers, body, method })
.then(async res =>  await res.json())
.then(result => {
    if(result.error)
        console.log("Wallet Creation Error", result);
    if(result.success)
        console.log("Wallet Created", result);
})
.catch((err) => {
    console.error("Wallet Create API Exception", err);
});
```

{% endcode %}

{% endtab %}
{% endtabs %}
