Skip to content

brex

The unofficial TypeScript SDK for the Brex API. Fully typed, tree-shakeable, zero-dependency — and generated deterministically from Brex's published OpenAPI specs.
import { Brex } from 'brex';
const brex = new Brex({ token: process.env.BREX_TOKEN! });
// Typed responses, auto-pagination, idempotency — all built in.
for await (const expense of brex.expenses.list({ 'expand[]': ['merchant'] })) {
console.log(expense.id, expense.merchant?.raw_descriptor);
}

Fully typed

Request bodies, query params, and responses are typed straight from the specs. Every method also carries the operation’s full description inline.

Tree-shakeable

Import one API via a subpath (brex/payments) and the other nine never enter your bundle — about 3.5 kB min for a single API.

Runs everywhere

Native fetch, zero runtime dependencies, ESM-only. Node ≥ 20.19 (including require()), Bun, Deno, browsers, and edge runtimes.

Auto-pagination

Every list method is both a promise and an async iterator — await a page, or for await across all of them.

Idempotency built in

Idempotency-Key headers are sent automatically wherever Brex requires them, with an auto-generated UUID by default.