Set up API authentication and authorization
In shortEnable JWT or custom auth, map roles to permissions, set how far each role can see, and keep every user's data private in 10xGraph.
- 19 min read
- 16 sections
- Updated
- v1.0.0
- Markdown
Authentication answers “who is calling the API?” Authorization answers “what may they do, and whose data may they see?” In 10xGraph both live under one auth key in 10xgraph.json. This guide covers JWT and custom auth, roles and permissions, reach, ownership, and the checks the server runs at boot.
10xGraph is a resource server. It verifies tokens and reads claims. It does not issue tokens, store users or talk to an identity provider. Anything that needs a database or an identity provider lookup goes in your own BaseAuth class.
For the full picture of what the server enforces and what it leaves to you, see the security model. To read the caller inside tools and nodes, see Authorization scopes.
The big picture
Each request goes through the same steps on every transport (HTTP, WebSocket, AG-UI, live):
- Authenticate.
BaseAuth.authenticateverifies the credential and returns claims. A failure is 401 (close code 1008 on a WebSocket). - Resolve. The server turns the claims into an
Identity:user_id, tenant values, roles, permissions and reach. A token with a missing tenant claim or a malformed roles or permissions claim is 401. It never falls back to a default role or reach. - Authorize.
BaseAuth.authorize(identity, permission, resource)decides. A refusal is 403 withMissing required permission: <permission>. - Run. The identity goes into the run config as
config["user"]. Storage filters every query by the identity’s reach, so a foreign thread, message, memory, file or run answers 404.
Auth is opt-in. With "auth": null no check runs and no thread has an owner.
Quick start with JWT
JWT is the easiest path: a stateless, standard bearer token that carries the user’s identity.
-
Install the JWT extra
Terminal pip install "10xgraph-api[jwt]" -
Set environment variables
Generate a secret and put these in your
.envfile:.env JWT_SECRET_KEY=<generate-with: python -c 'import secrets; print(secrets.token_urlsafe(48))'> JWT_ALGORITHM=HS256JWT_ALGORITHMmust be one ofHS256,HS384,HS512,RS256,RS384,RS512,ES256,ES384,ES512,PS256,PS384,PS512orEdDSA.none, an empty value or an unknown value stops startup. Startup also stops if PyJWT is not installed, and theauthvalue must be exactly"jwt". The server refuses a short HS* secret at startup whenMODE=production, and warns otherwise. RFC 7518 requires HMAC secrets to be at least 32 bytes for HS256. -
Enable JWT in 10xgraph.json
10xgraph.json { "agent": "graph.agent:app", "env": ".env", "auth": "jwt" } -
Send bearer tokens from clients
Every request must carry the token in the
Authorizationheader:Terminal curl -X POST http://localhost:8000/v1/graph/invoke \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"messages": [{"role": "user", "content": [{"type": "text", "text": "hello"}]}]}'
How do credentials reach the server?
HTTP requests
The server reads a standard bearer credential from the Authorization header:
| Situation | HTTP status | Error code |
|---|---|---|
| No header | 401 | INVALID_TOKEN |
| Expired token | 401 | EXPIRED_TOKEN |
Bad signature, or mismatched iss/aud |
401 | INVALID_TOKEN |
Valid signature but no user_id claim |
401 | INVALID_TOKEN |
user_id that is not a non-empty string or whole number (empty, boolean, float, list, object) |
401 | INVALID_TOKEN |
scope or scopes claim of the wrong type |
401 | INVALID_TOKEN |
Tenant claim missing, or user_id with the reserved __system__ prefix |
401 | INVALID_TOKEN |
| Token revoked | 401 | REVOKED_TOKEN |
Token revocation on and no usable jti claim |
401 | INVALID_TOKEN |
| All auth/authorization checks pass | 200 | (success) |
To pin tokens to your service and prevent replay across services, set JWT_ISSUER and JWT_AUDIENCE in your environment. Set both in production when the same signing key or identity provider also issues tokens for other services, so a token minted for another service is rejected here.
JWT_ISSUER and JWT_AUDIENCE are both off when unset or empty. With JWT_ISSUER unset, the issuer is not checked: a token with any iss, or none, is accepted. With it set, the token must carry iss and it must match exactly. With JWT_AUDIENCE unset, a token without aud is accepted, but a token that carries an aud claim is refused. With it set, the token must carry aud and it must match. A failure of either check answers 401 INVALID_TOKEN.
The codes tell a client what to do:
INVALID_TOKEN: the token cannot be used as it is. Sign in again.EXPIRED_TOKEN: the token is past itsexp. Refresh it.REVOKED_TOKEN: the token was revoked. Sign in again.
A correctly signed token that lacks a configured tenant claim (auth.tenant_claims), and a token whose user_id starts with the reserved prefix __system__, both answer 401 INVALID_TOKEN.
WebSocket connections
WebSocket routes (/v1/graph/ws, /v1/graph/live) accept auth via the Sec-WebSocket-Protocol header (the standard subprotocol negotiation):
const ws = new WebSocket(
"ws://localhost:8000/v1/graph/ws",
["10xgraph-bearer", TOKEN]
);The subprotocol list works as: the server looks for 10xgraph-bearer (or the legacy agentflow-bearer), treats the next item as the token, and responds with the matching subprotocol. The server also accepts the Authorization header. A ?token= query parameter is not accepted, because it would land in URLs and logs. The subprotocol works on WebSocket routes only; HTTP routes take the Authorization header alone. If no credential is found, the connection is rejected with close code 1008 (policy violation).
How does the user reach your code?
The server builds an Identity from the verified claims and puts it in the run config as config["user"]. A tool or node that declares a config parameter receives it. Framework-injected parameters are hidden from the tool schema the model sees.
from tenxgraph.core.authz import get_identity
def list_my_orders(config: dict) -> list[dict]:
"""List the caller's recent orders."""
identity = get_identity(config) # None when auth is off
return db.orders_for(identity.user_id) # From the verified token, never a tool argumentIdentity is a frozen model with user_id, kind (user or system), tenant, roles, permissions, reach and the raw claims. identity.can("store:write") checks one permission. See Authorization scopes for the full guide.
User IDs starting with __system__ are reserved for shared data (agent memory, RAG knowledge bases) and system identities. The server refuses a token that carries one (HTTP 401 “This user id is reserved”, WebSocket close code 1008), so no caller can act as a shared owner.
Never take a user ID from a tool argument. The model chooses tool arguments; a prompt-injected model could ask to see another user’s data. Trust the server-verified identity.
The auth key
Everything about auth sits under one key. method picks who verifies the credential. The RBAC keys next to it apply to whichever method you choose.
{
"auth": {
"method": "jwt",
"roles_claim": "roles",
"tenant_claims": ["org_id"],
"roles": {
"member": {
"permissions": ["graph:*", "threads:*", "store:*", "files:*", "tasks:trigger", "tasks:read", "tasks:cancel"],
"reach": "own"
},
"org_admin": {"inherits": ["member"], "permissions": ["admin:read"], "reach": "tenant"},
"super_admin": {"permissions": ["*"], "reach": "all"}
},
"default_role": "member",
"system_identities": {
"nightly": {"roles": ["member"], "tenant": {"org_id": "acme"}}
}
}
}| Key | Meaning |
|---|---|
method |
none, jwt or custom. "auth": null is none. "auth": "jwt" is a shortcut for {"method": "jwt"}. |
path |
Only for custom: "module:Class" or "dir/file.py:Class" of a BaseAuth subclass. |
roles |
Role table. Each role has permissions, optional inherits and a required reach. |
roles_claim |
Token claim that lists the caller’s roles. Defaults to roles when roles is set. |
permissions_claim |
Token claim that lists permissions directly. Use it instead of roles, never with it. |
tenant_claims |
Token claims that name the caller’s tenant, such as org_id. Every token must carry each one. |
default_role |
Role given to a token that has no roles claim at all. |
system_identities |
Named non-user callers for background jobs. See Background tasks. |
With only "auth": "jwt", every authenticated user gets the default permission set (everything except admin:*) with reach own.
Where permissions come from
You pick one source. The framework defines no role meanings.
| Source | Config | Result |
|---|---|---|
| Default | no RBAC keys | Every authenticated user gets the default set, reach own. |
| Roles | roles (and optionally roles_claim) |
Permissions are the union of the caller’s roles, including inherited ones. Reach is the widest reach among them. Role names in the token that are not in roles are ignored. |
| Permissions | permissions_claim |
The token lists permissions. Unknown names are ignored. A missing claim means no permissions. Reach is own. |
The claim may be a list of strings or one space-separated string. Anything else is 401. A token with no roles claim takes default_role when you set one, otherwise it holds no role and no permission.
Token scope and scopes claims only narrow. Effective permissions are the granted set intersected with the permission-shaped entries (those that contain : or equal *). Plain OAuth scopes such as openid profile are ignored. A permission-shaped scope the registry does not know narrows to nothing.
The permission registry
Permissions are resource:action and come from one list. A role that names anything else refuses to boot.
| Resource | Actions | Guards |
|---|---|---|
graph |
read, invoke, stream, stop, fix |
read: graph structure routes. invoke and stream: runs (stream also covers WebSocket, live and AG-UI). |
threads |
read, write, delete |
Thread, state and message routes. |
store |
read, write, delete |
Long-term memory routes. |
files |
read, upload, delete |
Media routes. |
config |
read |
The server config route. |
tasks |
trigger, read, cancel |
/v1/tasks routes. |
admin |
read, write |
No built-in route uses these. They are for your own checks. |
Wildcards: resource:* grants every action of a resource, and * grants everything. The default set is every permission except admin:*.
Reach: how far a caller sees
Reach says whose data a caller can see. It is set per role and is never a fallback: a missing or unknown reach refuses to boot (config) or denies (token, custom authorize).
| Reach | Sees |
|---|---|
own |
Rows of this user_id within their tenant. |
tenant |
Rows of every user with the same tenant values. Needs tenant_claims and a checkpointer with tenant columns (PgCheckpointer). On SqliteCheckpointer and InMemoryCheckpointer, which have no tenant columns, a read, list or delete by a caller with reach tenant raises an error (the request fails); it does not fall back to own. Writes still use own. |
all |
Every row. |
Reach widens reads, lists, deletes and stop only. Runs and state or message writes always stay on the caller’s own threads, admins included. Nobody runs inside another user’s thread. Boot logs a warning for every role with reach all.
Ownership lives in storage
There is no ownership cache and no ownership backend to configure. Every storage query filters by the caller’s reach, so:
- A thread, message, memory, file or run outside the caller’s reach answers 404, the same as one that does not exist. Nothing reveals that the id exists.
- Each thread route makes one scoped read before the run lock and before any response header. That read gives the 404 and enforces
runs.thread_ids. - Deleting a thread outside the caller’s reach answers 404 and does no file or telemetry cleanup.
- With auth off there is no identity, so no thread has an owner.
Use a durable, shared checkpointer such as PgCheckpointer in production. Tenant isolation needs tenant columns on both the checkpointer and the store, see Multi-tenant data.
Who am I: GET /v1/me
GET /v1/me returns what the server resolved for the caller. A UI can use it to show or hide views.
{"data": {"user_id": "u-42", "tenant": {"org_id": "acme"}, "roles": ["member"], "permissions": ["graph:invoke", "graph:stream", "threads:read"], "reach": "own"}}permissions is sorted. An identity with no restriction reports ["*"]. With auth off the answer is {"auth": "off"}.
Custom authentication and authorization
Subclass BaseAuth and implement authenticate. Optionally override authorize.
Reference: BaseAuth · Source: base_auth.py
from fastapi import HTTPException
from tenxgraph_api import BaseAuth
class ApiKeyAuth(BaseAuth):
async def authenticate(self, request, response, credential):
api_key = request.headers.get("X-API-Key")
if not api_key or not verify_key(api_key):
raise HTTPException(status_code=401, detail="Invalid API key")
return {"user_id": "service-account", "roles": ["service"], "org_id": "acme"}{
"auth": {
"method": "custom",
"path": "auth.custom_auth:ApiKeyAuth",
"tenant_claims": ["org_id"],
"roles": {"service": {"permissions": ["graph:invoke", "graph:stream"], "reach": "own"}}
}
}To call other services as the user, the server also puts a UserCredential in config["credential"] (the verified bearer token by default). Override async BaseAuth.downstream_credential(self, connection, credential, claims) to supply a different one, such as a session cookie or API key. Clients cannot set credential themselves. See Calling services as the user.
The path accepts auth_app:Cls, auth_app.py:Cls, pkg.mod:Cls and pkg/mod.py:Cls.
authenticate(request, response, credential)
- Required, and async: declare it
async def. The server awaits it, so a slow lookup does not block the event loop. - Returns the verified claims as a dict. It must include
user_id. Every other key lands inidentity.claims. - Raise
HTTPException(your status) orUserAccountError(401) to refuse. On a WebSocket both become a clean 1008 close. - Derive
user_idand tenant values only from the verified credential, never from a client-set header or query parameter. - Set
reusable_within_request = Trueon the class only ifauthenticateis a pure function of the credential with no response side effects. Then the rate limiter’s verified result is reused instead of verifying twice.
authorize(identity, permission, resource=None)
- Optional and
async. The default isidentity.can(permission), which applies the built-in RBAC. permissionisresource:action, for examplethreads:read.resourceis the id the request targets (thread id, memory id, namespace, file id, or the task name for a background task), orNone.- It takes no request, so the jobs worker can call it too.
- Return
Trueto allow orFalseto answer 403. If it raises, the request fails. It never counts as allowed. - If you override it and also set
roles, the roles apply only when your code callsawait super().authorize(...). Boot warns about this.
class MyAuth(BaseAuth):
async def authenticate(self, request, response, credential): ...
async def authorize(self, identity, permission, resource=None):
if not await super().authorize(identity, permission, resource):
return False # keep the role table as the first gate
return await my_extra_rule(identity, permission, resource)A custom authorize decides permissions only. Reach still comes from the identity, which auth.roles resolves from your claims. Recipes with a database, Casbin and Cerbos are below.
Revoke tokens
With auth on, set cache_store.token_revocation to true and the server refuses revoked tokens (401, code REVOKED_TOKEN). Revocations live in the cache store, so use "type": "redis" for them to reach every worker. Revoke from the command line with 10xgraph revoke --user USER_ID or --jti JTI; the command writes to the cache store the server uses and refuses when that store is in-memory.
{
"auth": "jwt",
"cache_store": {"type": "redis", "token_revocation": true}
}With revocation on, every token must carry a jti claim (a non-empty string or an integer). A token without it is refused with 401 INVALID_TOKEN and the message “Invalid token, jti missing”. One token is revoked by its jti, so without it the token could never be revoked on its own. This also applies to a custom BaseAuth class: the claims it returns must include jti. With revocation off, jti stays optional. A revoked token answers 401 REVOKED_TOKEN; on a WebSocket the socket is closed with code 1008.
If the cache store is unreachable, the server refuses to boot and requests that need the check answer 503. See Token revocation for the object form.
Boot-time refusals
One validator runs at boot, in 10xgraph config, 10xgraph audit and 10xgraph build. A setup the server would refuse cannot be saved in the editor, fails audit, and shows as a warning in build.
| Setup | Result |
|---|---|
auth null or none with any RBAC key |
Refused: set auth.method or remove the RBAC keys. |
Top-level authorization key (any value) |
Refused. The key is removed. See Migrating from authorization. |
Top-level graph_introspection key |
Refused. Reading the graph is the graph:read permission. |
method: custom without path, or path not a BaseAuth subclass |
Refused, naming the path. |
path with method jwt or none |
Refused: path is only for custom. |
roles (or roles_claim) together with permissions_claim |
Refused: pick one permission source. |
roles_claim without roles |
Refused. |
default_role, an inherits entry or a system_identities role not in roles |
Refused, naming the role. |
| Inheritance cycle | Refused, naming the cycle. |
| Unknown permission in a role | Refused. |
Missing or unknown reach on a role |
Refused. |
Role with reach tenant and no tenant_claims |
Refused. |
tenant_claims and the tenant columns on the checkpointer or store do not match |
Refused with MODE=production, warning otherwise. Declare the same names on both sides. |
Custom class overrides authorize and roles is set |
Allowed, with a warning. |
Role with reach all |
Allowed, with a warning that lists the roles. |
MODE=production with auth off |
Allowed, with a warning from build, config and audit. |
At request time a token without a configured tenant claim, or with a malformed roles or permissions claim, is 401.
Migrating from authorization
The top-level authorization key and AuthorizationBackend are removed. A leftover authorization key stops the server at boot and names auth.method: custom and auth.roles as the replacement. Stored data does not change: ownership is read from the same thread rows as before.
| Before | Now |
|---|---|
"authorization": "ownership" |
Delete the key. With auth on, every thread, memory and file is private to its owner (reach own), and a foreign id answers 404 (it used to answer 403). |
"authorization": "allow_all" |
No equivalent. To let a group read each other’s data, give their role reach tenant. Reads, lists and deletes widen; runs stay on the caller’s own threads. |
{"backend": "rbac", "roles": {...}, "default_scopes": [...]} |
auth.roles, each role with permissions and reach. isolation: "owner" is reach own. |
"authorization": "module:MyBackend" |
"auth": {"method": "custom", "path": "module:MyAuth"} and override authorize on your BaseAuth class. |
authorize(user, resource, action, resource_id) |
authorize(identity, "resource:action", resource) |
isolation_scope(user) returning "owner", "none" or ["org_id"] |
Role reach: own, all or tenant, with tenant_claims. |
scopes_for(user) |
permissions_claim, or roles_claim with a role table. |
"graph_introspection": "scoped" |
Delete the key. Grant graph:read only to the roles that may read the graph. |
"graph_introspection": "open" |
Delete the key. The default set already includes graph:read. |
checkpointer:read, checkpointer:write, checkpointer:delete |
threads:read, threads:write, threads:delete |
checkpointer:import and POST /v1/threads/{id}/messages |
Removed. There is no history import route. |
graph:setup |
Removed. |
files:upload, files:read |
Same, plus files:delete. |
tasks:invoke |
tasks:trigger |
config["authz"], get_authz, has_scope, isolation_scope, build_authz |
config["user"] as an Identity: get_identity(config), identity.can("resource:action"), identity.reach. |
| Redis ownership cache | Removed. Nothing to configure. |
A typical role setup, before and after:
{
"auth": "jwt",
"authorization": {
"backend": "rbac",
"roles": {"admin": ["*"], "member": ["graph:invoke", "graph:stream", "checkpointer:read"]},
"default_scopes": ["graph:read"]
}
}{
"auth": {
"method": "jwt",
"roles": {
"admin": {"permissions": ["*"], "reach": "own"},
"member": {"permissions": ["graph:invoke", "graph:stream", "graph:read", "threads:read"], "reach": "own"}
},
"default_role": "member"
}
}The old default_scopes applied to everyone. default_role applies only to a token with no roles claim. For a floor that every user gets, list those permissions in each role, or inherits from a base role.
For direct SDK use, config["user"] takes an Identity or a dict that validates into one (user_id, tenant, roles, permissions, reach, kind, claims). An unknown key in that dict raises. permissions=None means unrestricted.
Recipes for a custom authorize
authorize is where checks that need a lookup belong. The recipes below show the pattern for a database, Casbin and Cerbos.
Database lookup
Use this when access rules live in your own table. The query uses asyncpg with a pool you create once at startup. It keeps the built-in role check as the first gate.
import asyncpg
from tenxgraph_api import BaseAuth
class DbAuth(BaseAuth):
pool: asyncpg.Pool # create once, for example at app startup
async def authenticate(self, request, response, credential):
... # verify the credential, return {"user_id": ..., "org_id": ...}
async def authorize(self, identity, permission, resource=None):
if not await super().authorize(identity, permission, resource):
return False
if permission.startswith("threads:") and resource is not None:
return bool(await self.pool.fetchval(
"SELECT EXISTS (SELECT 1 FROM project_members WHERE user_id = $1 AND thread_id = $2)",
identity.user_id, resource,
))
return TrueThe lookup runs on every guarded request, so index it and cache short-lived answers yourself if it is hot. Storage still filters by reach after authorize passes.
Casbin
Casbin keeps the policy in a model file and a policy file. This follows its Python quick start: casbin.Enforcer(model, policy) and e.enforce(sub, obj, act).
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.actp, alice, threads, read
p, alice, graph, invokeimport casbin
from tenxgraph_api import BaseAuth
class CasbinAuth(BaseAuth):
def __init__(self):
self.enforcer = casbin.Enforcer("auth/model.conf", "auth/policy.csv")
async def authenticate(self, request, response, credential):
... # verify the credential, return {"user_id": ...}
async def authorize(self, identity, permission, resource=None):
resource_name, _, action = permission.partition(":")
return bool(self.enforcer.enforce(identity.user_id, resource_name, action))This version replaces the built-in role check, so do not set roles with it. For role mapping inside Casbin, see its docs.
Cerbos
Cerbos runs as a separate policy service. This calls its HTTP API, POST /api/check/resources on the default HTTP port 3592, with httpx.
import httpx
from tenxgraph_api import BaseAuth
CERBOS_URL = "http://localhost:3592/api/check/resources"
class CerbosAuth(BaseAuth):
async def authenticate(self, request, response, credential):
... # verify the credential, return {"user_id": ..., "roles": [...]}
async def authorize(self, identity, permission, resource=None):
kind, _, action = permission.partition(":")
body = {
"principal": {
"id": identity.user_id,
"roles": sorted(identity.roles) or ["user"],
"attr": dict(identity.tenant),
},
"resources": [{
"resource": {"id": resource or "*", "kind": kind, "attr": {}},
"actions": [action],
}],
}
async with httpx.AsyncClient(timeout=2.0) as client:
reply = await client.post(CERBOS_URL, json=body)
reply.raise_for_status()
effect = reply.json()["results"][0]["actions"][action]
return effect == "EFFECT_ALLOW"A network error raises, so the request fails instead of passing. Write Cerbos policies for the resource kinds graph, threads, store, files, config and tasks. The recipe uses the HTTP API directly; it does not use the Cerbos Python SDK.
Production deployment checklist
Verify auth is enforced
Test without a token:
curl -X POST http://127.0.0.1:8000/v1/graph/invoke \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": [{"type": "text", "text": "hello"}]}]}'Expected: HTTP 401, code INVALID_TOKEN, before any graph execution.
Then check who the server thinks you are:
curl http://127.0.0.1:8000/v1/me -H "Authorization: Bearer <TOKEN>"Expected: HTTP 200 with your user_id, roles, permissions and reach. Then ask for a thread another user owns and expect 404.
Common failures to expect
| Error | Likely cause | Fix |
|---|---|---|
401 INVALID_TOKEN (no credential) |
No credential presented | Attach Authorization: Bearer <token> |
401 EXPIRED_TOKEN |
Token exp is in the past |
Refresh the token; check server and issuer clock skew |
401 INVALID_TOKEN |
Bad signature or no user_id claim |
Verify JWT_SECRET_KEY, JWT_ALGORITHM, and that the issuer emits user_id |
401 INVALID_TOKEN (“Invalid token, please login again”) |
A configured tenant claim is missing, or the roles or permissions claim is malformed | Add the claim, or fix its type (list of strings or one space-separated string) |
401 INVALID_TOKEN (“Invalid token, jti missing”) |
cache_store.token_revocation is on and the token has no jti |
Issue tokens with a jti claim, or turn revocation off |
401 REVOKED_TOKEN |
The token or all of the user’s tokens were revoked | Sign in again for a new token |
403 Missing required permission: <resource>:<action> |
The caller’s roles do not grant it | Add the permission to a role, or give the user the role |
| 404 on a thread you expect to exist | It belongs to another user or tenant, or does not exist | Check GET /v1/me for reach and the token’s tenant claim |
Startup ValueError: “JWT_SECRET_KEY and JWT_ALGORITHM must be set” |
One of the two env vars is missing with JWT | Set both |
Refuses to boot, naming authorization or graph_introspection |
Removed keys | See Migrating from authorization |
Boot guard
Every non-public route is checked at startup to carry a RequirePermission guard. If a route lacks one, the server refuses to start:
RuntimeError: Refusing to start: the following routes are not protected:
- POST /v1/my-new-endpointThis is intentional: a forgotten guard becomes a deploy-time error, not a silent open endpoint. /ping and /health/ready are the only public paths.
Production recommendations
- Always set
"auth"in production; never leave itnullunless a gateway does the check - Use HTTPS everywhere
- Keep
JWT_SECRET_KEYoutside version control; inject it at deploy time - Use short-lived tokens and rotate secrets intentionally
- Give reach
allto as few roles as you can; boot logs each one - Set
MODE=productionto disable/docsand/redocs(enable only if intentional) - Test both successful and rejected requests before release, asserting on the status and error code
See also
- Authorization scopes: Read the caller and check permissions inside tools and nodes
- Multi-tenant data: Tenant columns and reach in storage
- Calling services as the user: Token exchange, M2M and self-issued tokens for MCP and local tools
- Configure the API server: Set
authand other keys in10xgraph.json - Troubleshooting auth: Debug auth and CORS failures
- REST API: auth reference: Full interface and status codes
Frequently asked questions
- Which claims must my JWT contain?
- Every token needs `exp` (expiration) and `user_id` claims. If you set JWT_ISSUER or JWT_AUDIENCE, the token must also carry matching `iss` or `aud` claims. A token without `user_id` is rejected with status 401, code `INVALID_TOKEN`.
- Why do I get 401 with code INVALID_TOKEN and no token?
- The request had no Authorization header, or it was not a Bearer credential. Send `Authorization: Bearer <token>` on every HTTP request, or use the `10xgraph-bearer` subprotocol on WebSocket.
- Does a role with reach all let an admin run inside another user's thread?
- No. Reach `tenant` and `all` widen reads, lists, deletes and stop. Runs and state or message writes always stay on the caller's own threads, admins included.
- What happens when I ask for another user's thread?
- The server answers 404, the same as for a thread that does not exist. Storage filters every query by the caller's reach, so a foreign thread is invisible.