← Blog

How do you give an AI agent an API key that can't touch everything?

Scope an Orgo API key to one workspace or one computer, give it only the permission groups your agent needs, set an expiry, and know how the key Orgo puts on a computer behaves.

Updated

Give the agent a key with a narrow scope, only the permissions it needs, and an expiry. Every Orgo API key has three settings: a scope (all workspaces, one workspace, or one computer), an access level (full access, read only, or custom levels across eleven permission groups), and an expiry (1 day to a year, or none). Orgo checks scope and permissions on every request before the endpoint runs. A call outside the key's permissions answers 403 with code: "key_permission", and the message names the group and level the key would need. A program running on an Orgo computer can instead use the computer's own key, which Orgo makes, rotates and revokes, and which reaches only that computer.

This matters because an agent acts on whatever its key allows. If the key can delete computers, invite people or buy credits, a confused or prompt-injected agent can too.

The three settings

SettingChoicesWith POST /api/keys
ScopeAll workspaces, one workspace, one computerNeither field, workspace_id, or computer_id
AccessFull access, read only, customLeave permissions out or send "full", send "read_only", or send an object of group to level
Expiry7, 30 or 90 days, 1 year, a date up to a year away, or noneexpires_in_days (1 to 365) or expires_at; neither for no expiry

A key made in Settings, API keys defaults to 90 days. Its value is shown once.

Scope

ScopeReachesSuited toCannot
All workspacesEverything your account can reachYour own scripts and admin toolingNothing is fenced off
One workspaceThat workspace and its computers and filesAn agent running a fleet inside one workspaceCall anything outside computers, workspaces, files, screenshots, chat completions, support and keys (so no secrets, templates, billing or account settings); create or name another workspace; manage members, share links, or delete its workspace (workspace_scope_mismatch); make one-computer keys (account_key_required)
One computerOne Linux computerA contractor, an embed in your app, an agent that drives one computerDelete, resize, clone, fork or move its computer; manage keys; reach workspaces, files, templates, secrets or billing

A one-computer key can start, stop, restart, suspend and resume its computer, and drive its screen, shell and Desktop API. Asked about another computer, it answers 403 with code: "computer_scope_mismatch".

Making a workspace key revokes the computer keys on that workspace's computers (below). If a program on one of those computers reads ORGO_API_KEY, switch it to the new key first.

Permissions

A restricted key has a level in each of eleven groups: none, read or write (write includes read). A group left out of a custom key is none.

GroupCovers
computersCreate, start, stop, resize and delete computers
controlScreenshots, commands, mouse and keyboard on a computer
filesFiles stored in Orgo
templatesTemplates and their builds
workspacesWorkspaces, their names and settings
membersPeople, invites and share links
secretsSecret names, and setting or using them
aiModels, chats and agents
bopsWhat the Bops app keeps in Orgo
billingPlan, credits and invoices
keysMake, change and revoke keys, never past the key's own access

Most computer use agents need two groups: computers to start and stop their machines, and control to click, type, run commands and take screenshots. An agent that calls POST /api/v1/chat/completions also needs ai at write. Leave members, billing and keys at none unless managing those is the agent's job.

  • Read is not always harmless. Control read takes screenshots of a computer's screen and reads files on it.
  • A workspace key cannot have members at write. Asking for it answers 400 with code: "invalid_permissions", as does an unknown group or level.
  • Custom with write in every group is still a restricted key. It cannot make a full access key, and it cannot call the endpoints reserved for a signed-in person.

A workspace key for an agent that runs and drives computers in one workspace, expiring in 30 days:

bash
curl -X POST https://www.orgo.ai/api/keys \
  -H "Authorization: Bearer $ORGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Fleet agent",
    "workspace_id": "'"$WORKSPACE_ID"'",
    "permissions": { "computers": "write", "control": "write" },
    "expires_in_days": 30
  }'

Send computer_id instead of workspace_id to bind the key to one Linux computer.

The computer's own key

Orgo can make a key for one Linux computer and write it onto that computer as ORGO_API_KEY, so an agent running there can call Orgo. It does so when a template's secrets declare orgo_api_key, when you own the workspace, nobody else can use it, and you create the computer signed in or with a full access key for the whole account that never expires.

Computer key
Managed byOrgo. PATCH /api/keys/{id} answers 409 with code: "managed_key"
ExpiryNone
RotationIts secret rotates on use once it is 30 days old; the old secret works 10 more minutes
ReachIts own computer, and a fixed list of calls for computer work and the Bops runner. Anything else answers 403 with code: "computer_key"; another computer, computer_scope_mismatch
CopiesA clone, fork or restore as a new computer gets its own key; no key is live on two computers
RevocationDeleted with its computer or workspace, and revoked when the workspace stops being yours alone

The last row is the one that surprises people. Anyone who can use the computer is root there and could read the key, so Orgo revokes it when an invite is accepted (whatever its access), a share link is claimed, a workspace key is made, someone connects the workspace through an MCP sign-in, an Invoicing client key is made or rotated for it, an agent account that owns it is claimed, or the computer moves into a shared workspace. A sweep every 15 minutes catches keys that should no longer stay. Programs that relied on ORGO_API_KEY then stop reaching Orgo.

Because anything that controls a computer can read its key, a restricted or expiring key cannot control a computer that holds its own key. Its control and AI calls about that computer answer 403 with code: "computer_key_held". Start, stop and get still work. Use a full access key that never expires for that computer, or sign in.

Rotating your own keys

Orgo never rotates a key you made, because it cannot reach where you keep it. Replace one in three steps:

  1. Create a new key with the same permissions and scope.
  2. Update every agent and service that uses the old key.
  3. Revoke the old key with DELETE /api/keys/{id}.

Both keys work until you revoke the old one. Orgo emails the account 7 days and 1 day before a key expires. Past its expiry the key answers 401 with code: "key_expired", and a WebSocket closes with code 4001. A key that expires can only make keys that expire no later than it does.

For the computer key, a program on the computer should read ORGO_API_KEY from /root/.orgo-secrets.env first, then /root/.env, and read it again after a 401 before retrying once. In a shell, sourcing /root/.env is enough: it sources /root/.orgo-secrets.env last, so it gives the newest value. Both files are readable by root only.

bash
# Run as root on the computer. Set COMPUTER_ID to the computer's UUID.
call_orgo() {
  . /root/.env
  status=$(curl -s -o /tmp/orgo-out.json -w '%{http_code}' "$@" \
    -H "Authorization: Bearer $ORGO_API_KEY")
  if [ "$status" = "401" ]; then
    . /root/.env   # the key may have rotated: read it again
    status=$(curl -s -o /tmp/orgo-out.json -w '%{http_code}' "$@" \
      -H "Authorization: Bearer $ORGO_API_KEY")
  fi
  cat /tmp/orgo-out.json
}
 
call_orgo "https://www.orgo.ai/api/computers/$COMPUTER_ID"

A 401 that persists after a fresh read means the key was revoked, not rotated. A 503 with code: "key_rotation_failed" means Orgo could not write the new secret, usually because the computer is not running; nothing changed, so retry after Retry-After seconds.

Revoking a one-computer key

When you revoke a one-computer key that could control its computer, Orgo changes the computer's VNC password and Desktop API token, and open screen viewers close. Until the change finishes, Get VNC password answers 503 with code: "vnc_rotation_pending", so fetch the password again rather than reusing a stored one. Settings, API keys, the computer's General tab, and GET /api/keys?computer_id={id} show which keys reach a computer.

Errors

StatuscodeMeaning
403key_permissionThe key lacks the group or level this endpoint needs
403computer_key_heldA restricted or expiring key tried to control a computer that holds its own key
403computer_scopeA one-computer key called an endpoint outside its list
403computer_scope_mismatchA key bound to one computer asked about another
403computer_keyA computer key called an endpoint outside its fixed list
403workspace_scope_mismatchA workspace key went outside its workspace or its surfaces
403account_key_requiredA workspace key tried to manage a one-computer key
403key_escalationA key tried to make, change or revoke a key wider than itself
400invalid_permissionsAn unknown group or level, or members write on a workspace key
409computer_key_in_useA one-computer key was requested for a computer that holds its own key
400computer_scope_fixedSomeone tried to change a one-computer key's computer; make a new key
400computer_scope_unsupportedA one-computer key was requested for a computer that is not Linux
409managed_keySomeone tried to change a computer key
401key_expiredThe key is past its expiry
503key_rotation_failedA computer key's rotation could not be written; retry shortly

Sources