Identity

Okta API tokens: find, store, rotate, and use them safely with AI agents

Okta API tokens are created in the Admin Console under Security, API, Tokens, and the value can be seen only when the token is created. A token inherits the privileges of the admin who made it, is sent with the SSWS prefix, and expires 30 days after creation or last use.

Okta key types

TypePrefixSecret?ScopeExpiry
API token (SSWS)
Sent as Authorization: SSWS <token>. Okta recommends OAuth 2.0 access tokens instead.
—YesInherits the privileges of the creating admin and changes if theirs change30 days after creation or last use; the window resets on each API call and cannot be changed

How to create a Okta key

  1. In the Admin Console go to Security > API.
  2. Click the Tokens tab, then Create token.
  3. Name the token and choose where API calls may originate from.
  4. Click Create token, then Copy to clipboard. This is the only time you can view it.

Limiting what the key can do

Create tokens from a dedicated service account with only the admin role needed. You can limit a token to an IP or network range when creating or editing it. New tokens default to 50% of each API's maximum rate limit.

How to revoke a Okta key

  1. On Security > API > Tokens click the trash icon in the Actions column, or open the token and click Revoke token.
  2. Agent tokens can be revoked only when the agent is inactive.

If your Okta key leaked

  1. Revoke the token on Security > API > Tokens.
  2. Create a replacement from a service account with a network restriction.
  3. Review System Log for unexpected admin actions.

Things that catch people out

  • The token disappears from view after creation.
  • It is deprovisioned if the user who created it is deactivated.
  • It expires after 30 days of inactivity.

Common Okta authentication errors

Invalid token provided

The API token is invalid (HTTP 401).

You do not have permission to perform the requested action

The token's admin privileges do not allow the action (HTTP 403).

Using your Okta key with AI agents

A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.

BotPassword works this way. For a Okta key, these intents fit:

IntentWhat BotPassword does
run_withRuns a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
http_requestMakes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
rotatePartly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.

Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents

Frequently asked questions

Where do I create an Okta API token?

In the Admin Console at Security > API > Tokens.

How long does an Okta API token last?

30 days after creation or last use, and each API call resets the window.

What does E0000011 mean?

The message "Invalid token provided" means the API token is wrong, expired or revoked.

Can an AI agent use my Okta key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, so the agent gets the result and never the value.

Stop pasting Okta keys into agents

BotPassword is in early access. Request an invite and we'll email you when your spot opens.