Skip to content

Integrations

Brex SDK: get started

The complete Brex API through typed application or agent clients

Use an ordinary App, or an Agent when the workload needs agent identity. Alter builds provider requests from a reviewed contract and applies the same connection authorization, policy, approvals, and audit records as raw requests.

Terminal window
npm install @alter-ai/sdk @alter-ai/brex
# Python (installs core automatically)
pip install alter-sdk-brex

The provider package includes only Brex types and response schemas and pins its contract version.

Configure Brex OAuth or store a Brex user API token as a managed secret. For OAuth, request the scopes the application needs, and retain each customer’s grant ID after Connect consent. Alter supplies the credential; it never belongs in operation input.

import { App } from "@alter-ai/sdk";
import { BrexIntegration } from "@alter-ai/brex";
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const client = new BrexIntegration(app, { grantId: process.env.BREX_GRANT_ID! });
const result = await (await client.team.teamListUsers({})).wait();
console.log(result.bodyJson());
} finally {
await app.close();
}
from alter_sdk import App
from alter_sdk_brex import BrexIntegration
async def first_call(api_key: str, grant_id: str):
async with App(api_key=api_key) as app:
client = BrexIntegration(app, {"grant_id": grant_id})
call = await client.team.team_list_users({})
result = await call.wait()
return result.body_json()

Contract 2026-11-06 publishes 121 SDK methods from ten official Brex OpenAPI documents. The policy catalog covers all 147 reviewed operations: 134 business routes and 13 authentication routes from the two official issuer discovery documents. Twenty-six routes are explicitly excluded from the SDK: five onboarding routes requiring a separate partner client-credentials flow, thirteen issuer-protocol routes outside the connected business API origins, six budget routes that can appoint managers and the two user routes that can assign a role. These eight management-capable routes remain available through raw managed execution: ordinary requests are allowed, while management grants require a scoped security allowance. The API reference links every operation to its complete input fields, response models, TypeScript and Python examples, and policy identity. Browse by resource under this provider’s API reference in the Integrations sidebar, or download the pinned OpenAPI specification. The Developer Portal provider view and alter integrations operations brex --version 2026-11-06 also expose the schemas.

Generated calls pin the Alter contract version. Brex’s own product, role, scope and subscription requirements still apply. There is no silent version fallback and no automatic write retry or pagination.

Terminal window
alter integrations execute brex brex.team_listusers \
--version 2026-11-06 --grant "$BREX_GRANT_ID" --input '{}' --wait

Arguments use native path, query, headers, and body containers. Array query parameters are sent the way the provider’s document declares them: one delimited value where it declares explode: false (or a pipe- or space-delimited style), repeated keys otherwise. SDK methods preserve provider field names. Response decoders retain decimal lexemes and large integers as strings when necessary. TypeScript integer inputs must be within JavaScript’s safe range (-9007199254740991 through 9007199254740991); an unsafe value is refused before dispatch, including transfer amounts, rather than sending a rounded payment. Python integer inputs retain their exact value. Accounting range-filter objects are serialized as bracketed query keys, such as updated_at[gte] and erp_posting_date[from]. HTTP 204 returns null / None from the typed decoder. Binary responses use bodyBytes() / body_bytes(); the CLI can save them with --output-file.

A policy rule can require approval for any operation. The call returns a pending approval; wait() resolves once the approver decides, and resume(approvalId) picks a pending approval up after a restart. Approval cards show the operation, its contract version and the request input the sensitivity review marked safe to display.

This contract uses JSON requests and responses. Receipt-upload operations return a signed destination; clients upload the file directly to that destination. The signed URL is sensitive capability data and is withheld from payload capture. No binary file is embedded in this provider SDK contract. JSON inputs use the shared 5 MiB serialized-input limit.

Payments and transfers carry payment when they move or commit funds. Reading existing PAN/CVV data is read; emailing it is write and send. Both use the reviewed masking inventory. User invitations, card-detail email and active caller-selected webhook destinations carry send; deactivating a webhook stops delivery. Removing, cancelling, closing, archiving or disabling a whole resource or relationship carries delete. Pure removal omits write; a request that also changes other fields retains it.

Assigning budget owners, or giving a user any role other than Employee (an admin role, Bookkeeper, AP clerk or a custom role), grants management authority and is denied by default. The six budget create/update routes and user create/update are therefore raw-only: ordinary requests to them are allowed, and their reviewed authority-granting branches require a scoped allowance. Card creation, spending membership, ordinary employee invitations and manager assignments, and restoring ordinary employee status remain policy-governable. An organization admin can authorize a reviewed security operation for one named API key or agent using a credential_minting allowance in allow or require_approval mode, with a reason and an absolute expiry in the future, at most one year ahead. The same scoped fields apply to six credential-gated issuer identities. An allowance cannot lift the five partner-only Onboarding refusals. See scoped security allowances.

Working account-credential issuance, connection-credential revocation, account security and client registration are refused by default. Device authorization creates a pending credential flow and retains the credential gate even though user consent and a later token exchange are required. Its issuer route is catalog-only. Logout carries admin, delete and send because supported registered recipients can receive logout notifications before an optional browser return redirect. All thirteen issuer identities stay outside the business SDK; discovery does not establish enablement for every partner client. The separate Onboarding API requires partner client credentials, so company OAuth grants and user API tokens cannot execute its five routes.

All 5,304 parameter occurrences have explicit review decisions. Tax identifiers, banking numbers, card details and private personal/business values remain usable and are masked in approvals and captures. Referral identifiers that also act as signup capabilities appear as {id} in audit URL metadata. Signed links and other narrow capabilities are withheld from capture. Response masking follows reviewed schema paths through recursive occurrences; personal profile fields and private metadata are protected, while benign fields remain visible. Undiscriminated variants retain their sensitive upper bound. Unreadable effect discriminators fail closed. Opaque authorization Request Objects retain ambiguous hidden selectors; decoded JWT claims never authorize a request. OAuth and API-token connections share these decisions.

Brex documents request failures through HTTP status codes. The SDK preserves asynchronous job status and per-record result data; it does not turn a pending business process into a transport failure. See Brex error codes.

The ten pinned official API sources and both issuer discovery documents, their individual versions and hashes, the generated methods and the policy mapping are checked together. Scheduled checks save upstream candidates and report additions, removals and schema changes; they never replace a published contract automatically. Existing contract versions remain available for installed SDKs and pending approvals.

Persist call.approvalId (TypeScript) or call.approval_id (Python), then construct a fresh provider client and call resume(savedId), followed by wait(). The stored approval selects the operation; this installed package verifies its provider and contract version before attaching the response validator. Mismatches raise ManagedOperationError, never silently decode using another contract. See persist-and-resume examples.

Policy operation fields also accept the published SDK function IDs listed by alter integrations operations brex. Use when.operation for a json_match or conditional require_approval rule, or match.operations for content_match (including redaction and step-up). Conditional approval can also use when.match.operations with parameter conditions. alter policy simulate --operation <function-id> tests that exact function.

Managed calls carry a server-verified function identity. Alter still evaluates policy against the actual method, URL and body after building the request from the authorized connection. Endpoint, method, host, catalog-operation and family rules evaluate the reviewed labels of the built request. A raw call can share an endpoint with several SDK functions and matches all of them; a function name never grants permission or bypasses existing restrictions.

For example, this rule requires approval for one function:

{
"effect": "require_approval",
"when": { "operation": "brex.team_createdepartment" },
"approval": { "approvers": ["reviewer@example.com"] }
}

Save it with alter policy rules create --app <app-id> --grant <grant-id> --type require_approval --body @rule.json, or select the function in the portal.

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.