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

Source: https://botpassword.com/keys/okta
Last checked: 2026-10-25

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.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| API token (SSWS) | — | Yes | Inherits the privileges of the creating admin and changes if theirs change | 30 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 the 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.

## Gotchas

- 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.

## Using this key with AI agents (BotPassword)

- `run_with`: Runs 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_request`: Makes 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.
- `rotate`: Partly 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.

## FAQ

### 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.

## Sources

- https://developer.okta.com/docs/guides/create-an-api-token/main/
- https://help.okta.com/en-us/content/topics/security/api.htm
- https://developer.okta.com/docs/reference/error-codes/
