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
| Item | Contract |
|---|---|
| Algorithm | HS256, with a secret kept on the server |
| Claims | user_id, ver, auth_method, iat, exp; tenant_id for tenant-scoped sessions; sso_connection_id for an SSO session |
| Expiration | 720 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
| Header | Value | Use |
|---|---|---|
Authorization | Bearer <JWT> | Protected application routes |
Content-Type | application/json | JSON bodies |
Cookie | misty_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:
| Endpoint | Form | Parameters | Response |
|---|---|---|---|
GET /api/workspaces/{workspace_id}/usage/logs | Pages | page (default 1), per_page (default 20, maximum 100) | logs, total, page, per_page |
GET /api/admin/audit-events | Cursor | before_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
| Code | Sense | Typical trigger | What to do |
|---|---|---|---|
401 | Invalid or revoked authentication | Token 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 |
404 | Resource not found | Workspace, file, skill, or conversation identifier does not exist | Check the identifier; avoid an identical retry |
409 | State conflict | Workspace slug already taken, upload already finalized, or operation on a resource in an incompatible state | Resolve the conflict (change the slug, reload the state), then retry |
422 | Validation failure | Malformed body, missing field, rejected file type, or file larger than 5 GB | Correct the request body according to detail |
429 | Too many requests (uploads only) | Upload rate exceeded or too many concurrent uploads in one workspace | Wait, then retry the upload; the API has no global rate limit |
5xx | Server error | Platform-side failure | Retry 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
Authorizationheader ormisty_v2cookie. - 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 returns401withSession 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:
| Case | detail |
|---|---|
| Missing required field | workspace_id requis / conversation_id requis |
| File type refused | Type de fichier non autorisé : <mime> |
| File too large | Fichier trop volumineux (max 5 Go) |
| Inconsistent size after sending | Taille du fichier incohérente |
| Actual type differs from declared | Type 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
| Code | Replayable? | Resumption |
|---|---|---|
401 | After reauthentication | Get a new JWT, then retry |
404 | No, except application logic | Check the identifier; MCP may turn it into a creation |
409 | After conflict resolution | Remove the conflict (slug, state), then replay |
422 | Not identical | Correct body according to detail |
429 | Yes, after backoff | Wait, send again |
5xx | Yes, after delay | Backoff then retry |
For token details, see Authentication and conventions. For tools, see the MCP reference.
MCP tools reference
The 18 tools of the Brume MCP server, their parameters and returns, the permissions enforced by API routes, and the client error mapping.
Example
A complete end-to-end journey: connect, create a workspace, invite a member, upload a file, start a conversation and read the result, in REST API and in MCP.