Most Brex APIs require a Brex admin to grant access. In these cases, only users with the account admin role can be authenticated.
Additionally:
- Bookkeepers may access the accounting API.
- Partners using the onboarding API authenticate with a Client Credentials Grant–there is no user associated with this API access.
Every token a user authorizes represents exactly one Brex account, and the scopes in it are evaluated against that account. This does not apply to the onboarding API, which uses a Client Credentials Grant with no user and no consent screen.
Some users can reach more than one account. An accounting firm, for example, may have its own Brex account and also service a number of client accounts (Pro Access). A user like this is prompted on the consent screen to choose which account they are connecting, and the token is issued for the account they pick.
That prompt only appears if your authorization request includes prompt=consent. Without it, an authorization that would otherwise complete silently skips the consent screen, and the user's primary account may be selected for them.
The account the user picked is the account you are working in, and it is not necessarily their primary one. For example, Get company returns that selected account rather than the one you might expect from the user's main company.
Scopes define which endpoints your app has access to. You will specify your scopes when generating your user token.
For more information on how scopes work in general, see the OAuth website.
Consent and authorization are separate steps. When a scope is granted, it means the user agreed to let your app ask for that kind of data. Each endpoint still checks, at call time, that the authorizing user holds the required role and that the account actually has the underlying product. A scope can therefore be present in your token and the call still not return what you expect.
Two causes account for most of this:
- The account does not have the underlying product. For example, the cash scopes (
accounts.cash.readonly,statements.cash.readonly,transactions.cash.readonly) consent normally for an account that has no Brex business account. - The user is not authorized for that data. The authorizing user's role may not permit access even when the account has the product and the scope was granted.
Neither is transient. Retrying will not help, and neither will re-authorizing as the same user on the same account, because neither changes what the account has or what the user's role allows. Handle it and degrade the affected feature instead.
See handling errors for the status codes and messages to expect.
As a general security practice, you should request the minimum set of scopes required for whatever action the user is performing. For instance, if you are building a simple app that lists all of a company's cards, you should request the cards.readonly scopes. Since you are not modifying any data, you only need the readonly version of the cards scope.
If you later want to add new functionality that requires fetching user information, or make updates to cards, you can request those scopes (users, cards) which will send the user through the authentication flow again and add those scopes to their previously consented scopes.
At the beginning of each API reference, there is a list of the scopes required for that given API. They are also listed here for convenience.
These 2 scopes are included automatically in user tokens.
| Scope | Description |
|---|---|
openid | Make an OpenID Connect request |
offline_access | Obtain an OAuth 2.0 refresh token |
| Scope | Description |
|---|---|
accounting.integration.read | View accounting integration |
accounting.integration.write | View and manage accounting integration |
accounting.record.read | View accounting records |
accounting.record.write | View and manage accounting records |
| Scope | Description |
|---|---|
budgets.readonly | View budget data |
budgets | View and manage budget data |
| Scope | Description |
|---|---|
expenses.card.readonly | View card expense data |
expenses.card | View and manage card expense data |
| Scope | Description |
|---|---|
fields.read | View custom field definitions |
fields.write | View and manage custom field definitions |
field_values.read | View custom field values |
field_values.write | View and manage custom field values |
| Scope | Description |
|---|---|
https://onboarding.brexapis.com/referrals | View and manage referrals |
| Scope | Description |
|---|---|
incoming_transfers | View and manage incoming transfers |
linked_accounts.readonly | View linked accounts |
transfers.readonly | View existing transfers |
transfers | View and manage transfers |
vendors.readonly | View vendor data |
vendors | View and manage vendor data |
| Scope | Description |
|---|---|
cards.readonly | View card data |
cards | View and manage card data |
cards.pan | View card number data |
companies.readonly | View company data |
departments.readonly | View department data |
departments | View and manage department data |
legal_entities.readonly | View legal entity data |
legal_entities | View and manage legal entity data |
locations.readonly | View location data |
locations | View and manage location data |
roles.readonly | View role data |
roles | View and manage role data |
titles.readonly | View title data |
titles | View and manage title data |
users.readonly | View user data |
users | View and manage user data |
| Scope | Description |
|---|---|
accounts.card.readonly | View card accounts |
accounts.cash.readonly | View cash accounts |
statements.card.readonly | View card statement data |
statements.cash.readonly | View cash statement data |
transactions.card.readonly | View card transaction data |
transactions.cash.readonly | View cash transaction data |
| Scope | Description |
|---|---|
travel.trips.readonly | View trip data |
travel.trips | View and manage trip data |