scope_denied means the credential was accepted but is not allowed to call this route. Read this page when a key that works on one route is refused on another.
What happened
Routes: every protected route under/v1/.
Each route needs a scope, and the credential does not hold it. The message names the missing scope in its wire form, for example runs_write. The message says “session” for API keys too; the meaning is the same.
Where the scopes come from:
- An API key holds exactly the scopes chosen when it was created. They never change.
- A console session holds the scopes of your role in the organization.
On
POST /v1/runs the scope is checked after the body is parsed. A malformed body gets invalid_body first.
How to fix
- Read the scope name in the message.
- For an API key: create a new key that includes that scope, deploy it, then revoke the old key. A key’s scopes cannot be edited. You can only grant scopes you hold yourself.
- For a console session: the scopes come from your role. Use an account whose role holds the scope. Buying credit, for example, needs
billing_write, which owners, admins and thebillingrole hold. - Keep keys narrow. A service that only sends runs needs
runs_writeandruns_read, nothing more.
Example
keys_write, and you must hold every scope you request.
Related
- Scopes - every scope and the routes it unlocks.
- Scopes and roles - which role holds which scope, and why.
- Key rotation - replace a key without downtime.
- Problem codes - every code, its status, and whether a retry can help.