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

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

CircleCI has personal API tokens (User settings → Personal API Tokens, expiry up to one year, full read and write) and project API tokens (Project Settings → API Permissions, with Status, Read Only or Admin scope). Send them in the `Circle-Token` header. Tokens cannot be edited or viewed again, so rotation means delete and recreate.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Personal API token | — | Yes | Full read and write permissions for manually created tokens; works with API v1 and v2 | Chosen at creation, no more than one year ahead; emails at 30, 15, 7 and 1 day before expiry |
| Project API token | — | Yes | Status (read build statuses), Read Only (API v1 only) or Admin (read and write, API v1 only) | — |

## How to create a CircleCI key

1. In the CircleCI app open **User settings** → **Personal API Tokens**.
2. Select **Create New Token**, enter a name and set an expiry date (no more than one year ahead).
3. Select **Add API Token** and copy it; you cannot view it again.

## Limiting what the key can do

Personal tokens made manually have full read and write permissions. For narrower access use a project API token with Status, Read Only or Admin scope, noting that Read Only and Admin apply to API v1 only.

## How to rotate a CircleCI key

1. Create a new token.
2. Update `CIRCLE_TOKEN` or `CIRCLECI_TOKEN` and other places that use the old token.
3. Delete the old token.

## How to revoke a CircleCI key

1. For a personal token click the **X** in the **Remove** column and confirm.
2. For a project token click the **X** in the **Remove** column, type `DELETE` and click **Delete API Token**.

## If the key leaked

1. Delete the token immediately.
2. Create a replacement with the narrowest scope and shortest practical expiry.
3. Review recent pipeline runs and project settings for unexpected changes.

## Environment variables

- `CIRCLE_TOKEN`
- `CIRCLECI_TOKEN`

## Gotchas

- The API v2 docs show `Circle-Token` as the header, with bearer, basic auth and query-string options also accepted.
- Passing a token in a query string can leak it into logs; prefer the header.
- The CircleCI MCP server package reads `CIRCLECI_TOKEN`; its README says it is no longer receiving feature work and points to the hosted MCP server.
- Expiry emails cannot be turned off.

## Using this key with AI agents (BotPassword)

- `list_credentials`: Lists the credentials this agent is granted and what it may do with each. Never values.
- `request_access`: Asks you for a grant, which you approve with your master password or decline in BotPassword on your desktop, never in the chat. The agent gets a receipt, never a value. Approval on your phone is planned.
- `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.
- `capture_secret`: Planned, not built yet: will read a newly created key straight from the page or command output into the vault.
- `store_secret`: Saves a value the agent already holds as a new vault item.

## FAQ

### Where do I get a CircleCI API token?

In the CircleCI app go to **User settings** → **Personal API Tokens** and select **Create New Token**.

### How do I send a CircleCI API token?

Send it in the `Circle-Token` header, for example `--header "Circle-Token: $CIRCLE_TOKEN"`.

### Do CircleCI API tokens expire?

Personal tokens expire on the date you pick, up to one year ahead.

### What is the difference between personal and project API tokens?

Personal tokens act as you with full read and write. Project tokens are tied to one project with a Status, Read Only or Admin scope.

### Can an AI agent use my CircleCI 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 `list_credentials`, `run_with`, `http_request`, so the agent gets the result and never the value.

## Sources

- https://circleci.com/docs/guides/toolkit/managing-api-tokens/
- https://circleci.com/docs/api/v2/index.html
- https://github.com/CircleCI-Public/mcp-server-circleci
