Auth & Identity

Authentication

Every MUDBASE API request authenticates one of two ways — an API key for server-to-server calls, or a JWT for user-facing apps that need identity and RBAC. Most endpoints accept either; each one's reference page states which it requires.

API key (server-to-server, SDKs)

Create one from Console → API Keys (or POST /api/api-keys, which itself requires a JWT). Send it in the X-API-Key header:

httpRequest Headers
X-API-Key: ak_live_xxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
X-API-Key: ak_live_xxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

API keys are project-scoped — the project comes from the endpoint's URL (e.g. /api/projects/{projectId}/...), not a header. Each key can be limited to specific permissions (database, storage, functions, auth, realtime) and has its own rate limit, default 1000 requests/hour.

JWT (user-facing apps, RBAC)

Obtained from a login/register endpoint (e.g. POST /api/auth/login). Send it in the Authorization header instead:

httpRequest Headers
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json

A JWT carries the authenticated user's identity and organization context, so it's the right choice whenever you need role-based access control or an audit trail tied to a real user — not just a project. See User Authentication for the full login flow.

Note
If a request includes both an X-API-Key and an Authorization: Bearer header, the JWT is tried first.

Base URL

text
https://cloud.mudbase.dev
https://cloud.mudbase.dev

Authentication Flow

API key or JWT
Validate
Project Check
Authorized

Error Responses

StatusCodeMeaning
200okRequest succeeded
400bad_requestCheck your request parameters
401unauthorizedInvalid or missing API key
403forbiddenInsufficient permissions for this action
404not_foundResource does not exist
429rate_limitedRate limit exceeded — see Retry-After header