Authentication
Create, use, rotate, and revoke API keys that belong to a person, and distinguish machine credentials from CLI logins.
Create an API key for a script or MCP client, then copy it when shown. Oxagen stores a hash, so the raw key cannot be recovered.
Open Organization → API keys (/{org}/api-keys), or a workspace's Settings → API keys tab, and press Create key. Every key belongs to a person and acts as them:
- Assigned to. The person the key belongs to, you by default. Every call the key makes is checked against what that person may do at the time of the call. When they leave the organization, or the key's workspace, the key stops working there. A key you make for someone else leaves out what is theirs alone: their profile, preferences and notifications, their conversations with the in-app agent, their own model credentials, their own machine, and control of the runs they operate. You hold its secret, so it stops working when you leave the organization, and it stays this way when it is rotated.
- Workspaces. One workspace, or every workspace the person can open. Opened from a workspace page, that workspace starts picked. A key for one workspace is refused any call that names another workspace.
- Permissions. Every workspace permission, the default, or a list picked from the same catalog custom roles use, such as
run.readorwork.control. A key holds the permissions on its list and nothing else, files it downloads included. Enrolling a machine or a recorder host mints a credential that acts as the person with all of their access, so only a key the person made for themselves, holding every permission, can do it. - Admin access. Adds the organization permissions: billing and spend authority, members and invites, workspace creation, SSO and SCIM, API keys, data export, and audit. Only an organization Owner can grant it, and only on a key assigned to an Owner. A key without Admin access cannot create, rotate, or revoke keys.
- Expires. 7, 30, or 90 days, or 1 year.
An organization Owner can create a key for any member, in any workspace or every workspace. A workspace Admin can create a key for any member who is not an Owner, in a workspace they administer that the member can open. Rotating a key follows the same rule, because the new secret goes to whoever rotates it.
Only a person creates a key, in the app. Oxagen refuses an API key that calls create_api_key, the CLI's own login key included, so no key can make another.
A key made before 2026-11-17 keeps acting as it did: a workspace key as a Member of its workspace, an organization key as an Org member, or on Enterprise as a custom role.
Keys use the ox_ prefix followed by a base64url-encoded random value. Keep them in a secret store or environment variable.
Use a key
POST /v1/{orgSlug}/{workspaceSlug}/agent/tools
Host: api.oxagen.sh
Authorization: Bearer ox_…
Content-Type: application/json
{}For MCP, send the same Bearer header to https://mcp.oxagen.sh/mcp. The key resolves the organization and workspace. Use the matching slugs or ids for API routes. A request whose URL names another organization or workspace gets 403 with error.reason key_scope_mismatch, and the message names both. A key for every workspace can name any workspace its person can open. A call outside the key's permissions, or in an organization area without Admin access, gets 403 and the message names the permission it needs.
Check a key
GET /v1/auth/whoami tells you whether Oxagen accepts a credential. It calls no capability and needs no org or workspace in the path.
curl "https://api.oxagen.sh/v1/auth/whoami" \
-H "Authorization: Bearer $OXAGEN_API_KEY"A valid key gets 200 with authenticated: true, apiKeyId, and the orgId and workspaceId the key belongs to. workspaceId is null for a key that works in every workspace. userId is the key's person for a key that belongs to one, and for a CLI login. A missing, malformed, invalid, or expired key gets 401.
Browser sessions
The app's own calls to the API use your sign-in session cookie instead of a key. The API applies your organization's sign-in policy to that session on every organization and workspace route, the same way the app does:
- With Require SSO on, a session that did not come from one of the organization's verified SSO providers gets 403 with
error.reasonsso_required. Owners are exempt. - When the organization requires two-factor authentication, an Owner who has not set it up by the end of the grace period gets 403 with
error.reasonmfa_required.
API keys do not carry a session, so these checks do not apply to them. Require SSO checks a key against its creator instead, as Single sign-on describes.
Key purposes
Not every ox_ credential has the same authority:
| Kind | Authority |
|---|---|
| Ordinary API key | Acts as Member of its workspace, or as Org member for an organization key, or as a custom role on Enterprise. An Org member holds no role in any workspace. Calls are attributed to its creator. There is no arbitrary capability allowlist for this key. |
CLI login, cli_session_v1 | Resolves to the person who authorized oxagen login. Authentication rechecks organization and workspace membership. |
Host key, tacho_host_v1 | The enrolled machine's own calls only: event ingestion, its policy bundle, command polling, a Git credential for its workspace's repositories, memory upload and recall, work order claims, local code graph builds, and certificate renewal |
Gateway key, tacho_gateway_v1 | MCP-exposed, nonmutating capabilities that are not high-sensitivity |
| Stella telemetry key | Operational telemetry ingestion only |
Agent credential, agent_credential_v1 | Only the run token exchange below. Every other call is refused with purpose_locked |
Run token, agent_run_v1 | Acts as its agent, for the agent's operator, in one run: the agent's roles cut down to the operator's, its mandates, and kill switches decide every call |
Machine-purpose checks apply before the plan-dependent IAM resolver. An unknown purpose is denied. purpose is a reserved scope key: create_api_key refuses a scope that sets it to any value, so callers cannot mint a host, gateway, or CLI-login key through the generic create call.
The agent registration credential has its own purpose and exchange flow. It is not a general API or MCP bearer credential. The credential for a mediated downstream connection is separate again: Oxagen holds that credential and uses it on the agent's behalf.
Agent run tokens
An agent that calls Oxagen itself trades its credential, the key register_agent or rotate_agent_credential returned, for a run token. The run token lasts 15 minutes and belongs to one run, which shows on the Runs page like any other.
curl -X POST "https://api.oxagen.sh/v1/auth/agent/run-token" \
-H "Authorization: Bearer $OXAGEN_AGENT_CREDENTIAL"The answer carries token, expires_at, run_id (tse_…) and agent_id. Send the token as the Bearer on the capability routes under /v1/{org}/{workspace} or on https://mcp.oxagen.sh/mcp. Any other route answers 403 with error.reason run_token_route. Every call it makes is checked as the agent's: what the agent's roles allow, cut down to what its operator may do, inside the agent's mandates, and under every kill switch. A run token never reaches the operator's own account, conversations, model credentials or machine, the organization's settings, or another workspace. To keep working past 15 minutes, send { "run_id": "tse_…" } to the same route for a fresh token in the same run.
A run stays open while its agent calls with it. After 12 hours with no call it ends, and its tokens answer run_ended. Send the exchange again with no run_id to open the next run. An agent holds at most four open runs. A fifth exchange answers 429 too_many_open_runs with open_run_ids, so the agent refreshes one of them. One credential may exchange ten times a minute.
The run acts for the agent's operator, the member who registered it. The exchange refuses the agent, and its live tokens stop, once that person can no longer open the workspace (agent_has_no_operator). Rotating the credential or retiring the agent stops every token traded for it at its next call, and so does the end of the run (run_ended). Suspending the agent stops its tokens too (agent_suspended).
RBAC and roles explains the plan-dependent resolver. Do not assume a generic scope object creates a capability allowlist.
Rotate or revoke
Rotate or revoke a key on the page that lists it: the workspace's Settings → API keys tab, or Organization → API keys. Rotation issues a replacement and keeps the old key working for 24 hours, so a lost response does not cut the integration off. Put the new value in place, then confirm the new key to revoke the old one at once. If you do not confirm it, the old key stops working when its 24 hours end. Revocation causes subsequent authenticated requests with the old key to fail.
The API exposes the same three steps. An ordinary API key cannot call them, because no key acts as Owner or Admin. Call them from a signed-in session or an oxagen login CLI session:
POST /v1/{orgSlug}/{workspaceSlug}/api-keys/rotate
Authorization: Bearer ox_…
Content-Type: application/json
{ "keyPublicId": "aky_…" }The response carries the new key's publicId and rawKey, and a superseded block with the old key's publicId and the expiresAt when it stops working. Confirm the new key with its own public ID:
POST /v1/{orgSlug}/{workspaceSlug}/api-keys/rotate/acknowledge
Authorization: Bearer ox_…
Content-Type: application/json
{ "keyPublicId": "aky_…" }Revoke any key by its public ID. This route uses DELETE and takes a JSON body:
DELETE /v1/{orgSlug}/{workspaceSlug}/api-keys/revoke
Authorization: Bearer ox_…
Content-Type: application/json
{ "keyPublicId": "aky_…" }From a terminal, oxagen api-key rotate <key-id> prints the new secret. oxagen api-key acknowledge <key-id>, given the new key's ID, confirms it.
Inspect the key's expiry when creating or rotating it. Different provisioning flows set different lifetimes. Revocation, and confirming a rotation, writes api_key.revoked to the security record.
Store credentials
Keep keys out of source control, browser bundles, prompts, and shared terminal output. Revoke a key if an unauthorized person may have copied it. Use oxagen login for a person's terminal access and the enrollment flow for a registered agent's host.