Batchrouter Docs

Authentication & API keys

Authenticate to the Batchrouter API with a br_live_ bearer key — create keys from a signed-in account, check your account, and rotate.

Not open yet

Sign-up is not open yet. The API routes for batches, chat completions and the OpenAI-compatible endpoints are not yet available.

Every Batchrouter API request is authenticated with a secret API key sent as a bearer token. This page shows the key format, how to create a key, what each key role can do, and how to rotate keys. Creating the account itself is on Account and sign-in.

The Authorization header

Send your key in the Authorization header on every request to /v1 endpoints:

Authorization: Bearer br_live_xxxxxxxxxxxxxxxxxxxxxxxx

New production keys are prefixed br_live_. Legacy ob_live_ keys remain valid while active, so you don't need to migrate existing integrations immediately.

A key carries a workspace role. The usual key can submit batches and spend credits. A read_only key cannot. Never ship any key to a browser, mobile app, or any client-side code, and never commit one to source control. Keep keys server-side and inject them from a secret manager or environment variable. If a key is exposed, revoke it immediately.

Base URLs

Point your requests at the right environment.

EnvironmentBase URLKey
Productionhttps://api.batchrouter.combr_live_…

All public endpoints live under /v1 — for example https://api.batchrouter.com/v1/auth/account.

Create an API key

A person signs up and creates a key from a signed-in account. The secret is shown only once — store it immediately in your secret manager. Signing in an agent through OAuth is documented once it ships.

From a signed-in account

Create and name keys at app.batchrouter.com/settings. The form offers Read only (read_only) and Read and write (member). Read and write is the default.

The same call is POST /v1/auth/account/api-keys. It requires the dashboard session of a workspace owner or admin (workspace.api_keys.manage). A bearer API key alone receives 403 user_session_required, so do not call it with Authorization: Bearer. The email on that session must already be verified.

label is required. role defaults to member. expires_at is optional. Omit it, or send null, for a key that does not expire.

{
  "label": "production-worker",
  "role": "member",
  "expires_at": "2027-01-01T00:00:00Z"
}

The secret is value. api_key is the record, including api_key.id, which is what you pass to revoke:

{
  "value": "br_live_xxxxxxxxxxxxxxxxxxxxxxxx",
  "api_key": {
    "id": "key_abc123",
    "label": "production-worker",
    "role": "member",
    "expires_at": "2027-01-01T00:00:00Z"
  }
}

Make an authenticated request

Once you have a key, verify it by fetching your account. GET /v1/auth/account returns your org, plan, credit balance, and members — a quick way to confirm the key works.

curl https://api.batchrouter.com/v1/auth/account \
  -H "Authorization: Bearer $BATCHROUTER_API_KEY"

A successful call returns your org details and current credit balance:

{
  "org_id": "org_abc123",
  "display_name": "Acme Batch Jobs",
  "plan": "free",
  "credit_balance": { "currency": "usd", "amount": "42.00" },
  "members": []
}

Check credit_balance before submitting work — if it's at zero, batch creation returns 402.

Key roles

Every API key has one workspace role. A new key defaults to member. OAuth consent on the dashboard can mint only read_only or member.

RoleSubmit work and spend creditsBilling changesAPI keys and members
ownerYesYesYes, including invitations and closing the account
adminYesYesCan manage keys. Cannot invite members
memberYesRead onlyNo
billingNoYesNo
read_onlyNoNoNo

A read_only key can request quotes: POST /v1/quotes/model and POST /v1/batches/quote return 200. A quote prices the work. It reserves no credit and creates no batch. POST /v1/batches returns 403 forbidden (This action requires the console.write workspace capability.). Use read_only when a tool must show prices and must never start paid work.

The role names and the account page describe the same five roles. A key cannot be given a platform staff role.

Rotate and revoke keys

Keys never need to be rotated on a fixed schedule, but rotate promptly if a key may have leaked. Create the replacement first so there's no downtime, then revoke the old one.

  1. Create a new key while signed in (see above) and deploy the secret to your secrets store.

  2. Switch traffic to the new key and confirm requests still succeed (GET /v1/auth/account returns 200).

  3. Revoke the old key from Settings, or with POST /v1/auth/account/api-keys/{id}/revoke on the same signed-in session. The id is api_key.id from a session create. A bearer key alone receives 403 user_session_required.

Revoked and expired keys immediately return 401 on every request. To set an expiry up front, pass expires_at when you create the key; omit it for a non-expiring key.

Troubleshooting

StatusMeaningFix
401Missing, malformed, invalid, revoked, or expired keyCheck the Authorization: Bearer … header and that the key matches the environment's base URL.
403Authenticated, but not allowed for this actionThe key's role cannot do that, the email is unverified (email_verification_required), or the call needs a signed-in session (user_session_required).
402Insufficient creditsAdd credits via the dashboard; verify with GET /v1/auth/account.

Next steps