Scoped Tokens
Issue short-lived JWTs with explicit permissions in one namespace.
A scoped token gives its holder selected permissions in one namespace. Issue it on your backend with the control plane’s admin credential, then return only the scoped token to the application.
Quickstart
Issue a token
This example grants read access to Actor traffic in the production namespace. Every holder can reach every Actor in that namespace; use a specific Actor ID for private per-user access.
curl -X POST "$RIVET_API/auth/tokens" \
-H "Authorization: Bearer $RIVET_ADMIN_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"namespace": "production",
"duration": 900,
"grants": [
{"resource":"actor_gateway","target":"any","operations":["read"]}
]
}'
The response contains token, issued_ts, and expires_ts. Timestamps are Unix milliseconds; duration is seconds.
Use the token
Set $RIVET_TOKEN to the returned token and call an Actor’s gateway endpoint:
curl "$RIVET_API/gateway/$ACTOR_ID/health" \
-H "Authorization: Bearer $RIVET_TOKEN"
This grant does not allow Actor creation, listing, node registration, or pool management.
Grants
Each grant names a resource, a target, and operations drawn from create, read, update, delete, list, and fork. A target is "any" or an object such as {"id":"<actor-id>"}. Replace the placeholder with the resolved Actor ID.
| Resource | Purpose |
|---|---|
actor | Create, resolve, list, or manage Actors. |
actor_gateway | Reach an Actor’s actions, events, or HTTP handlers. |
node | Register or inspect nodes. |
pool | Read or manage node pool configuration. |
Actor management and gateway access require separate grants. Permission to reach one Actor does not allow the holder to create other Actors. Namespace administration and token issuance require the admin credential.
Forking an Actor
A fork copies everything an Actor holds into a new Actor the caller controls, so only the fork operation allows it. Grant fork on the source Actor, by its ID or "any", together with create on "any" Actor, because the new Actor’s ID is not known before the fork:
[
{"resource":"actor","target":{"id":"<actor-id>"},"operations":["fork"]},
{"resource":"actor","target":"any","operations":["create"]}
]
No other operation includes fork: tokens that can read, create, or connect to an Actor cannot fork it. The fork input comes from whoever forks the Actor, so validate it in onFork like any client input. While an engine upgrade is rolling out, issuing a token that grants fork answers auth.operation_unavailable (503 with Retry-After) until every engine worker supports it.
Inspect and renew
curl "$RIVET_API/auth/tokens/inspect" \
-H "Authorization: Bearer $RIVET_TOKEN"
The response contains the namespace slug, grants, subject, and issue and expiry timestamps. Renew expiring credentials through your authenticated backend. Do not give clients the admin credential to renew tokens themselves.