Quickstart
Create a client with a token, then call typed methods. The root Brex class
wires up all ten Brex APIs behind a single object.
import { Brex } from 'brex';
const brex = new Brex({ token: process.env.BREX_TOKEN! });
// Typed responsesconst me = await brex.users.getMe();
// Create with an auto-generated Idempotency-Keyconst vendor = await brex.vendors.create({ company_name: 'Acme Inc' });
// One page…const page = await brex.expenses.list({ limit: 100 });
// …or every item across all pagesfor await (const expense of brex.expenses.list({ 'expand[]': ['merchant'] })) { console.log(expense.id);}Generate a user token in your Brex dashboard, or obtain one via OAuth. See Authentication for token providers and OAuth refresh.
Where to go next
Section titled “Where to go next”- Tree-shakeable imports — import only the APIs you use.
- Pagination — pages vs. items vs. cursors.
- Client & request options — base URL, custom
fetch, per-request headers, idempotency, and abort signals. - Error handling — the
BrexErrorshape. - API reference — every namespace, method, and type.