Brume · Docs
API

Overview

Authenticate a client and apply the conventions shared across the Brume API.

In brief

Application routes use a session JWT presented as a Bearer token. Errors, pagination, versioning, and idempotency follow the conventions below; the generated schema remains the source for each endpoint.

Authenticate a request

Obtain a token

Send email and password to POST /api/auth/login. Add tenant_slug to request a token scoped to a specific organization.

curl -X POST https://your-instance/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"••••••••","tenant_slug":"my-organization"}'

The 201 response contains token, tenant_count, and tenants.

Keep the session

The JWT is signed with HS256 and expires after 720 hours by default. Its ver claim is compared with the account’s current version: a revoked session receives 401 Session revoked before expiry.

Present the token

Add Authorization: Bearer <token> to each protected route. The misty_v2 cookie is a fallback for web clients; the Bearer header takes precedence. The MCP server receives the same JWT through BRUME_TOKEN.

Token structure and revocation

ItemContract
AlgorithmHS256, with a secret kept on the server
Claimsuser_id, ver, auth_method, iat, exp; tenant_id for tenant-scoped sessions; sso_connection_id for an SSO session
Expiration720 hours (30 days) by default

Logout and password reset increment users.token_version, invalidating every JWT issued with an earlier version. The authentication guard keeps the current version in a per-worker cache for at most 5 seconds; the revoked token then receives 401 Session revoked.

Public endpoints accept requests without a token, including login, health, and invitation validation or acceptance. The generated reference identifies this status route by route. A protected route responds with 401 without a valid token.

Routes under /gateway/{provider}/v1/... use a Bearer token prefixed with brm_. The session JWT authenticates requests to /api; the brm_ token authenticates requests to the gateway.

BYOK LLM key ≠ access token

Routes /api/tenants/{tenant}/api-keys and /api/workspaces/{workspace}/api-key store model-provider keys reserved for LLM calls. Present the session JWT on /api and the brm_ token on the gateway; an LLM key presented as a Bearer token on /api is rejected.

Send the headers

HeaderValueUse
AuthorizationBearer <JWT>Protected application routes
Content-Typeapplication/jsonJSON bodies
Cookiemisty_v2=<JWT>Web client session

Multipart uploads and binary responses declare their own content type in the Endpoints pages of this section.

Interpret an error

HTTP exceptions from /api routes are serialized with a status and detail:

{
  "status_code": 422,
  "detail": "Validation message"
}

Branch your logic on the HTTP status and use detail for diagnostics. The gateway may return {"error":"..."} before calling a provider, then forwards the provider body. See error codes for recovery guidance.

Paginate a collection

Two endpoints paginate their collections:

EndpointFormParametersResponse
GET /api/workspaces/{workspace_id}/usage/logsPagespage (default 1), per_page (default 20, maximum 100)logs, total, page, per_page
GET /api/admin/audit-eventsCursorbefore_seq, snapshot_seq, limit (default 25, maximum 100)events, next_cursor, snapshot_seq

Keep snapshot_seq while traversing audit events and pass next_cursor as the next before_seq.

Preserve settings during a mutation

PATCH /api/workspaces/{workspace_id}/members/{member_user_id}/permissions replaces all existing overrides when you send permission_overrides. The request requires can_manage_team. An unknown permission key triggers a validation error. If the member has no workspace row yet, the request creates it.

PATCH /api/admin/role-settings merges the patch into the stored settings: an absent field remains unchanged. For user and power_user, label accepts at most 40 characters. color follows the #RRGGBB format.

Track the version

Application routes remain under /api, with no global version segment. The version published in OpenAPI matches the installed Brume package. The protected /api/instance/version endpoint also exposes the version, commit, edition, and build time to superadmins.

Replay a write

Idempotency is defined in each /api endpoint contract. Check that contract before replaying a mutation. On the gateway, Idempotency-Key supports charging for flat-rate services; the provider contract determines upstream execution.

In brief

Application routes signal failure through the HTTP status and a JSON body carrying detail. Use the status to choose recovery and the detail for diagnostics.

Read the error body

4xx exceptions from /api routes expose a JSON body with a readable detail field:

{
  "status_code": 422,
  "detail": "Type de fichier non autorisé : application/x-msdownload"
}

The detail field is a diagnostic string. The HTTP status remains authoritative for error logic: branch on the status, and read detail for the message.

Choose a recovery path

CodeSenseTypical triggerWhat to do
401Invalid or revoked authenticationToken absent, expired (beyond 30 days), or invalidated by change of token_version (message Session revoked)Reauthenticate via POST /api/auth/login to obtain a new JWT
404Resource not foundWorkspace, file, skill, or conversation identifier does not existCheck the identifier; avoid an identical retry
409State conflictWorkspace slug already taken, upload already finalized, or operation on a resource in an incompatible stateResolve the conflict (change the slug, reload the state), then retry
422Validation failureMalformed body, missing field, rejected file type, or file larger than 5 GBCorrect the request body according to detail
429Too many requests (uploads only)Upload rate exceeded or too many concurrent uploads in one workspaceWait, then retry the upload; the API has no global rate limit
5xxServer errorPlatform-side failureRetry after a delay; the request is not at fault

Renew after a 401

A single authentication mechanism covers the application API and MCP server: an HS256 JWT, sent in the Authorization: Bearer <token> header or misty_v2 cookie. 401 occurs in three cases:

  • Token missing or unreadable: no valid Authorization header or misty_v2 cookie.
  • Expired token: the default expiration is 720 hours (30 days), carried by the claim exp.
  • Token revoked: each user has a database token_version. When it is incremented (global sign-out, forced rotation), every previously issued JWT returns 401 with Session revoked.

Obtain a new token before replaying the request.

Access token ≠ LLM key

The 401 relates to the Brume API access JWT. Keys managed under /api/tenants/{tenant}/api-keys and /api/workspaces/{ws}/api-key belong to model providers (BYOK). An invalid LLM key appears during model execution as an inference error; it does not trigger a 401 on the API.

Correct after a 422

The 422 is the most frequent error during integration. The detail body field names the cause. Examples observed on uploads:

Casedetail
Missing required fieldworkspace_id requis / conversation_id requis
File type refusedType de fichier non autorisé : <mime>
File too largeFichier trop volumineux (max 5 Go)
Inconsistent size after sendingTaille du fichier incohérente
Actual type differs from declaredType de fichier incohérent

Replaying the same body without a correction reproduces the validation. Correct the request client-side using detail.

Back off after a 429

The 429 exists only for file uploads. It protects the workspace from two situations:

  • Rate too high: Trop de demandes d'upload, réessayez dans un instant.
  • Too many simultaneous uploads on the same workspace: Trop d'uploads en cours sur cet espace.

The rest of /api has no global rate limiter. Apply a short backoff before retrying the upload.

Decide whether to retry

CodeReplayable?Resumption
401After reauthenticationGet a new JWT, then retry
404No, except application logicCheck the identifier; MCP may turn it into a creation
409After conflict resolutionRemove the conflict (slug, state), then replay
422Not identicalCorrect body according to detail
429Yes, after backoffWait, send again
5xxYes, after delayBackoff then retry

For token details, see Authentication and conventions. For tools, see the MCP reference.

On this page