Error codes

Brex uses HTTP response status codes to indicate the success or failure of your API requests. If your request fails, Brex returns an error using the appropriate status code.

In general, there are 3 status code ranges you can expect:

  • 2xx: Success status codes confirm that your request worked as expected.
  • 4xx: Error status codes indicate an error because of the information provided (e.g., a required parameter was omitted).
  • 5xx: Error status codes are rare and indicate an error with Brex's servers.

All Brex API endpoints include an errors object in their response body when the request fails. It will contain a type, message, and optional code. For example:

HTTP/1.1 401 Not Authorized

Copy
Copied
{
    "type": "UNAUTHORIZED",
    "message": "PERMISSION_DENIED: Invalid or Revoked Token"
}

HTTP/1.1 404 Not Found

Copy
Copied
{
    "type": "NOT_FOUND",
    "message": "Not Found",
    "code": "USER_NOT_FOUND"
}

Common errors and fixes

Status code
Endpoint
Error Message
Fix
401 /v2/accounts/cash Must be cash admin, bookkeeper or user. Brex Cash may not be enabled in your account. The account owner should enable Brex Cash. For partners, there may be no fix beyond proper error handling as this means the customer does not have Brex Cash. If Brex Cash is enabled, the authenticated user must have access to Brex Cash.
401 /v2/vendors Only account admin, ap clerks and bookkeepers can access contacts Brex Cash may not be enabled in your account. The account owner should enable Brex Cash. For partners, there may be no fix beyond proper error handling as this means the customer does not have Brex Cash.
400 Any POST with free form text input [Field name] is invalid Free form text fields, display names, etc. can only accept ASCII characters.
403 Any endpoint Expired token For customers, generate a new token using the Brex dashboard. For partners, generate a new token using a refresh token.
Copyright © Brex 2019–2022. All rights reserved.