> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opal.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# BILL

> Learn how to connect Opal to BILL to manage accounts payable and receivable users and roles.

With the BILL integration, you can manage accounts payable and receivable access from Opal:

* See the users in your BILL organization and the role each one holds
* Let people request a role, such as **Clerk**, **Approver**, or **Auditor**, from the web and Slack
* Create a user, and archive them when they should no longer have access
* Set the right resource owners to delegate approvals to those with the most context
* Automatically change a role when a time-bound grant expires

Opal connects to one BILL organization through an OAuth app. To manage several organizations, add a BILL app in Opal for each one.

This integration covers accounts payable and receivable. It does not sync Spend & Expense users, budgets, or cards.

## Supported resources

| Resource | Read | Grant and revoke access |
| - | - | - |
| BILL AP & AR | ✔️ | ✔️ |
| Users | ✔️ | Create and archive |

A person holds exactly one role. Granting a role replaces the role they have. Revoking that role sets **No access**.

### Roles

These roles can be requested:

| Role |
| - |
| Administrator |
| Accountant |
| Approver |
| Auditor |
| Clerk |
| Payer |

Opal also syncs roles it does not offer for new grants, including **No access**, **Member**, **Custom role**, and the procurement roles. **No access** is what Opal assigns when the last role is revoked. A custom role is shown as **Custom role**. Several custom roles share that one level, so Opal cannot grant a specific custom role.

### Limitations

* Opal does not sync Spend & Expense.
* BILL has no groups. Opal does not create any.
* Opal does not change a user's name or email after they are created.
* Archiving is the only removal. BILL does not permanently delete a user.
* A developer key, a sync token, or a Spend & Expense API token cannot be used. Opal accepts only OAuth client credentials.

## Requirements

Before you begin, you must:

* Be an [Opal Admin](https://docs.opal.dev/docs/roles-in-opal.md)
* Be a BILL **Administrator** in accounts payable and receivable
* Have OAuth client credentials enabled for the BILL organization. If **Connected apps** is missing from the profile menu, ask BILL to enable it. [home.bill.com](https://home.bill.com/) does not offer this until it is enabled.
* Be on version `1.1269.0` or later, if you self-host Opal

## Configuration steps

### 1. Create a BILL developer app

Opal signs in with the client credentials grant. BILL's steps are in [Get started with BILL OAuth](https://developer.bill.com/docs/oauth-client-credentials).

1. In the BILL web app, select your profile icon, then **Connected apps**.
2. Select **Create app**.
3. Select **Full access to my BILL org(s)**, accept the terms, and select **Create app**. Full access requires multi-factor authentication with the phone number on the BILL account. You cannot change the scope after the app is created. **Accounting data access** cannot manage users and roles.
4. Copy the client ID and client secret and store them where your team keeps secrets. The client secret is shown once. Select **Done**.

The app's token can do only what the BILL user who created it can do, so that user must be an **Administrator**. A client secret expires after two years. An organization can have up to five developer apps, and deactivating an app is permanent.

Use a production app for a production organization, and a sandbox app for a sandbox organization. A credential does not work in the other environment. See [Sandbox vs Production](https://developer.bill.com/docs/environmental-differences).

### 2. Create the BILL app in Opal

In Opal, go to **Inventory** > **+ App** and select **BILL AP & AR**. Fill in the following fields:

| Field | Value |
| - | - |
| App name | A name for the BILL app in Opal, for example `BILL`. |
| App admin | The owner who administers the app in Opal. |
| Description | A short description that helps requesters understand what this app is. |
| Visibility | Who in your organization can see the app. |
| Access | **Read and write** to create users, archive users, and change roles. **Read only** only syncs. |
| API host | **gateway.prod.bill.com** for production, or **gateway.stage.bill.com** for sandbox. |
| OAuth host | **auth.bill.com** for production, or **auth.stage.bill.com** for sandbox. Match the API host. |
| Client ID | The client ID from step 1. |
| Client secret | The client secret from step 1. |

Opal checks the client ID and client secret when you save. The app's **Setup** tab lists **Read users** and **Read roles**. A failed check means the app's creator is not an Administrator, or the hosts do not match the environment that issued the credentials.

### 3. Import the organization

After you save the app, on the app's **Assets** tab, select **Import assets** and choose **BILL AP & AR**. Turn on requests for the roles people should be able to ask for.

Opal pulls users and roles only for imported items. Users show on the **Accounts** tab. Who holds each role shows on **BILL AP & AR** after the next sync.

## User provisioning

* **Create.** Opal creates the user from their name and email, assigns **Clerk**, and BILL emails them an invite. The role you granted is applied after the user exists.
* **Restore.** Creating a user whose email matches an archived user restores that user instead of creating a second one.
* **Archive.** Removing the user in Opal archives them in BILL. They can no longer sign in. BILL keeps the user.

## Troubleshooting

| What you see | What to do |
| - | - |
| **Connected apps** is not in the profile menu | Ask BILL to enable OAuth client credentials for the organization. A developer key cannot be used instead. |
| Saving the app fails on the client secret | Create the app with **Full access**, then copy the client ID and client secret again. The secret is shown once. |
| **Read users** or **Read roles** fails | The user who created the app must be an Administrator, and the API host and OAuth host must be the same environment. |
| Creating a user fails | The person needs a first name, last name, and email in Opal. BILL rejects an email it already has on an active user. |
| Granting a role fails | That organization does not have a role of that type. |
| Revoking the last role fails | The organization has no **No access** role, so Opal cannot clear the role. |
| A custom role cannot be requested | Opal syncs every custom role as **Custom role** and does not grant them. Change a custom role in BILL. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.