AI-native
What permissions should an AI agent have?
Only what its job needs, on its own credential. Start from the agent's role, not the tool it runs in: a coding agent that ships changes needs to create and roll out, an on-call agent needs to read and stop things, and a reporting agent needs to read. Give each agent its own key with those actions, limited to the environments it works in and set to expire, so a leaked or confused agent can't reach anything else.
Updated November 20, 2026
Why shouldn't agents share an admin key?
A shared admin key gives every agent every power, and the audit log can't tell them apart. If one agent misreads a task, it can do anything the admin can; if the key leaks, so can whoever holds it. One credential per agent, scoped to its job, fixes both: what the agent can do is limited by the key, and every change it makes is recorded under its own name. See how to tell which AI agent made a change.
How do you scope a key by role?
Flagger.gg's guide to scoped agent tokens gives recipes by role. Its agent tokens carry any of six actions, read, create, target, rollout, kill and request, for a chosen list of environments:
| Role | Environments | Actions |
|---|---|---|
| Coding agent that ships its own changes | development, production | all six |
| On-call or monitoring agent | production | read, kill |
| Review or reporting agent | development, production | read |
| Agent kept out of production | development | everything but request |
flagger tokens create --kind agent --project shop \
--name "On-call agent" \
--envs production --actions read,kill \
--expires-days 30Name both lists every time. In Flagger.gg's CLI, leaving out --actions grants all six, and leaving out --envs gives the one environment you're working in. A call outside the token's environments fails with 403 forbidden; over MCP, a read-only agent sees no write tools at all.
What about an agent's access to its machine?
The same idea applies to the computer the agent works on. A Sandboxer API key can be limited to actions such as exec, file.read or sandbox.create, to particular sandboxes or environments, and to a lifetime. A request is allowed only when its action is in the key's actions and its sandbox is in the key's scope. Presets cover the usual cases, from read-only for dashboards to ci for pipelines, and an agent holding a narrow key can't create itself a wider one. See Sandboxer API keys for agents.
sbx api-key create one-sandbox --sandbox <sandbox-id> --actions sandbox.read,exec,file.read --ttl 7dHow long should an agent's key last?
As long as the job, and never forever. Flagger.gg agent tokens last 90 days at most; an expired or revoked token's next call fails with 401 unauthorized, so renew before the expiry. For one task, a key that lasts minutes or hours is better. See how long an AI agent's API keys should last.
Is a permission the same as approval?
No. A permission says what an agent may try; an approval says a person agrees to a particular change. Flagger.gg runs in auto-live mode by default, where an agent's allowed changes apply at once. With approvals on, an agent in production can roll out only up to a cap per environment, and turning a flag on for everyone becomes a request a person approves; agents have no approve tool, and every agent write needs a note saying why. Keep the agent's scope in its token and the release in a flag. See adding human approval to AI agent actions.
Frequently asked questions
Should every AI agent have its own API key?
Yes. One key per agent lets you limit each to its job and shows in the audit log which agent made each change.
What permissions does an on-call AI agent need?
Usually read and kill in production: it can see what's on and turn a bad release off, but can't turn anything on.
How do I keep an AI agent out of production?
Give its token only development environments. In Flagger.gg, any call it makes for production then fails with 403 forbidden, whatever its actions.
Can an AI agent give itself more permissions?
Not on Sandboxer or Flagger.gg. Creating Sandboxer keys needs a browser session or an admin key, and Flagger.gg agents have no approve tool.