> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/b/bill.md).

# Bill

BILL Spend & Expense is a spend management platform. OctoXLabs reads its users from the Spend API.

## Use cases

* List BILL Spend & Expense users and their creation time.

```
Adapters = bill AND Email = *
```

## Before you begin

### Network

| Source              | Destination                                             | Port | Protocol                         |
| ------------------- | ------------------------------------------------------- | ---- | -------------------------------- |
| OctoXLabs connector | gateway.stage.bill.com (default, change for production) | 443  | HTTPS (HTTP if Is Secure is off) |

### Required permissions

| Scope or role                | Permission             | Needed for     |
| ---------------------------- | ---------------------- | -------------- |
| ADMIN user role (production) | Generate the API token | Authentication |

## Create credentials in Bill

{% stepper %}
{% step %}

### Open the profile settings

In Spend & Expense, click the Profile icon in the top right corner and select **Profile**, or select **My Account** in the navigation menu.
{% endstep %}

{% step %}

### Open API tokens

Go to the **Settings** tab and find the **API tokens** section.
{% endstep %}

{% step %}

### Generate the token

Click **Generate new token**. Copy the value from the **New token** field. It is not shown again after you close the window.
{% endstep %}

{% step %}

### Check the role

In production, the Spend & Expense API user must have the ADMIN role to generate a token.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter | Required | Type    | Default                | Description                                                 |
| --------- | -------- | ------- | ---------------------- | ----------------------------------------------------------- |
| Domain    | Yes      | String  | gateway.stage.bill.com | Host of the BILL gateway. The default is the stage gateway. |
| API Token | Yes      | String  |                        | Sent in the `apiToken` header.                              |
| Proxy     | No       | String  |                        | Proxy as `host:port`.                                       |
| Is Secure | No       | Boolean | True                   | Use HTTPS.                                                  |
| Timeout   | No       | Integer | 30                     | Seconds to wait for API responses.                          |

## Troubleshooting

| Error message                                           | Cause                                                                                                                                  | Fix                                                                                                  |
| ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| Failed to fetch users:                                  | The users request did not return 200.                                                                                                  | Check the token and the domain.                                                                      |
| Invalid JSON response while fetching users (status=...) | The response body is not JSON.                                                                                                         | Check the domain and the proxy.                                                                      |
| Request failed after 5 retries for url                  | The API kept answering 429.                                                                                                            | Wait and run the discovery again. The adapter sleeps 60 seconds per retry.                           |
| Status Code: `, URL, Method`                            | The API answered with an unexpected HTTP status. The shared request code raises it and logs the status, URL, method and response body. | Check the URL, the credentials and the permissions listed above, then run the connection test again. |

## Change history

{% hint style="info" %}
Available starting from version 5.6.11.
{% endhint %}
