# Create Bill

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

**POST** [**/client/bills/save**](https://xpay.stream/client/bills/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
{
     amount: "1000000", // USD with 6 decimals uint, 1USD = 1000000
     tag: "bill-tag",   // Some useful tag for searching
     expireInMinutes: "30" // Bill Expires After 30 Minutes
     reference: "unique-ref" // Unique Non Reusable Bill Reference
     useLightning: true // when payment via bitcoin lightning network
}
```

{% 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": "bill created",
        "data": {
            "uuid": "827c5bce-a0f4-47b3-a4fe-aa16897882ae",
            "username": "user@xpay.stream",
            "wallet": "68e457c5-d8fb-4d62-ac5b-62fd6fd46484",
            "hex": "", // case of USDT TRON - Address to Pay
            "address": "", // case of USDT TRON - Address to Pay
            "createdAt": 1724149286283,
            "billRef": "1bdce316",
            "billAmount": 10000000,
            "paidAmount": 0,
            "testnet": false,
            "tag": "XPAY-83cd",
            "starting": 1724149226283,
            "until": 1724151086283,
            "closed": false,
            "canceled": false,
            "cooldown": 0,
            "txs": [],
            "lnInvoice": { // case of BTC Lightning Invoice to Pay
                "createdAt": 1724149286,
                "externalId": "68bc2ddf8b2cddbc0efee6d82fb43f81ac57259023f5d3822103d6b6b2701bdd",
                "paymentRequest": "lnbc164540n1pnvgm3xpp5dz7zmhut9nwmcrh7umvzldplsxk9wfvsy06a8q3pq0ttdvnsr0wsdp68qerwce4vf3k2ttpxpnrgtf5xa3rxttpx3nx2ttpvycnvwpexuursvnpv5cqzpuxqrpkvsp54e6ds39frtcjrhg3msydq07vjtdgv7wzv8zjjqv8nmngmah5tvyq9qxpqysgqp62fy08w5jxv3cgd720euaa4xp5jjwa369c8rmaryxl302ralz6rknhk9ffgmaxwrhhgdcu0n7z34y04gevsdguwd6jd9r9pvyc20wsqhw3mt5",
                "paymentHash": "68bc2ddf8b2cddbc0efee6d82fb43f81ac57259023f5d3822103d6b6b2701bdd",
                "paymentSecret": "ae74d844a91af121dd11dc08d03fcc92da8679c261c52901879ee68df6f45b08",
                "paymentStatus": "PENDING",
                "satoshis": 16454,
                "dollars": 10
            },
            "callbackURL": "https://mycallback.com/bill-alert", // Customer - xPAY Web Redirect
            "email": "user@gmail.com" // Send Invoice To Customer
        }
    },
    "uuid": "08d3b9c9-602d-403e-ba86-d1edbd50feec"
}
```

{% endcode %}
{% endhint %}

***

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

```bash
curl 'https://apis.xpay.stream/client/bills/save' \
  -H 'Content-Type: application/json'               \
  -H 'Authorization: Bearer <access_token>'         \
  --data-raw '{"amount":10000000,"tag":"XPAY-83cd","expireInMinutes":"30","reference":"1bdce316","email":"customer@gmail.com","callbackURL":"https://mycallback.com/bill-alert","useLightning":true}'              
```

{% 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({ 
   "amount":10000000,
   "tag":"XPAY-83cd",
   "expireInMinutes":"30",
   "reference":"1bdce316",
   "email":"customer@gmail.com",
   "callbackURL":"https://mycallback.com/bill-alert",
   "useLightning":true
});

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

{% endcode %}

{% endtab %}
{% endtabs %}
