# Search Bills

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

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

***

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

Authorization: Bearer [\<access\_token>](/authentication-api.md)

Content-Type: application/json<br>

**Request Body**

* **List All** finds all your wallets

```json
{

    "page": 1,        // optional - if not present, default 1
    "pageSize": 20,    // optional - if not present, default 10

    // sorting is optional
    // when not set wallets are sorted by Creation Date Descending
    "sort" : { // sort by date, USDT Balance, Tron Balance
        "createdAt": 1     // ascending 1, descending -1, default -1        
     }
}
```

* **Search by bill UUID:** *(previous paging and sorting applies)*

{% code lineNumbers="true" %}

```json
{
    "wallet": "uuid" // wildcard uuid search
}
```

{% endcode %}

* **Search By bill Tag:** *(previous paging and sorting applies)*

{% code lineNumbers="true" %}

```json
{
    "tag": "tag" // wildcard tag search
}
```

{% endcode %}
{% endhint %}

{% hint style="success" %}
**Success Response**\
By default all search results are paged, with 10 items per page.

You can specify in your request the page number and number of items per page. Find in response, which page you are, if more pages are availabe (nextPage: true), total count for all items without paging and the total found for items count in this page.

**`Example Below:`**

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

```json
{
    "success": {
        "message": "Done",
        "data": [
            {
                "uuid": "827c5bce-a0f4-47b3-a4fe-aa16897882ae",
                "address": "",
                "billAmount": 10000000,
                "billRef": "1bdce316",
                "callbackURL": "https://mycallback.com/bill-alert",
                "canceled": true,
                "closed": true,
                "cooldown": 0,
                "createdAt": 1724149286283,
                "email": "someuser@mail.com",
                "lnInvoice": {
                    "createdAt": 1724149286,
                    "paymentRequest": "lnbc164540n1pnvgm3xpp5dz7zmhut9nwmcrh7umvzldplsxk9wfvsy06a8q3pq0ttdvnsr0wsdp68qerwce4vf3k2ttpxpnrgtf5xa3rxttpx3nx2ttpvycnvwpexuursvnpv5cqzpuxqrpkvsp54e6ds39frtcjrhg3msydq07vjtdgv7wzv8zjjqv8nmngmah5tvyq9qxpqysgqp62fy08w5jxv3cgd720euaa4xp5jjwa369c8rmaryxl302ralz6rknhk9ffgmaxwrhhgdcu0n7z34y04gevsdguwd6jd9r9pvyc20wsqhw3mt5",
                    "paymentHash": "68bc2ddf8b2cddbc0efee6d82fb43f81ac57259023f5d3822103d6b6b2701bdd",
                    "paymentStatus": "PENDING",
                    "satoshis": 16454,
                    "dollars": 10
                },
                "paidAmount": 0,
                "starting": 1724149226283,
                "tag": "XPAY-83cd",
                "testnet": false,
                "txs": [], // payment transactions
                "until": 1724151086283,
                "username": "account@mail.com",
                "wallet": "68e457c5-d8fb-4d62-ac5b-62fd6fd46484",
                "closedAt": 1724149958630
            },
            ...
        ]
    },
    "page": 1,
    "pageSize": 5,
    "foundCount": 5,
    "totalCount": 56,
    "nextPage": true,
    "uuid": "c586c030-2208-419a-806b-f49c088a8481"
}
```

{% endcode %}
{% endhint %}

***

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

```bash
curl 'https://apis.xpay.stream/client/wallets/find' \
  -H 'Authorization: Bearer <access_token>'         \
  -H 'Content-Type: application/json'               \
  --data-raw '{ "page": 1, "pageSize": 5}'             
```

{% 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/find";

const method = "POST";

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

const body = JSON.stringify({
    page: 1,
    pageSize: 5
});

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

{% endcode %}

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xpay.stream/billing/search-bills.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
