What a scope is
A scope is a short permission string, by conventionresource:action:
items:readitems:writeorders:cancel
The scopes file
Each platform has amudraid_scopes.yaml that maps every route to one of three outcomes. The middleware reads it and enforces it.
| Setting | Meaning |
|---|---|
scope: <name> | The token must carry this scope, or the request is denied. |
public: true | No token required. For health checks, status pages, anything open. |
skip: true | The route returns 404 — it’s invisible to agents. |
Path parameters
Use the framework’s brace syntax for variable path segments:/api/v1/items/42 and /api/v1/items/abc both match this rule.
Scopes are flat — no implicit hierarchy
This is the rule that surprises people, so it’s worth stating plainly: holding one scope never implies another.items:write does not include items:read. If a route needs both, the agent must be granted both, and the route must require both.
It looks stricter than necessary, but it removes a whole class of accidental over-permissioning. There’s no hidden ladder where a “higher” scope quietly unlocks “lower” ones. What you grant is exactly what the agent can do.
Naming scopes well
- Use
resource:action— readable and predictable. - Keep them specific:
orders:read,orders:write,orders:cancel. - These names are what an agent’s owner sees when granting access, so make them self-explanatory.
The portal is the source of truth
The MudraID portal decides which agent gets which scope on which platform, and it generates themudraid_scopes.yaml. The middleware trusts that file.
To change what your routes require: update scopes in the portal, re-export the file, and redeploy your service. The middleware reads the file once at startup — it doesn’t hot-reload — so changes take effect on the next deploy.
A worked example
A small orders API:orders:read can list and read orders, but its calls to create or cancel are denied — and /internal/metrics is invisible to it entirely.
Next
- Define scopes — designing your scope set.
- Manage the scopes lifecycle — how changes roll out.

