Developer tools

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

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.

CircleCI key types

TypePrefixSecret?ScopeExpiry
Personal API token—YesFull read and write permissions for manually created tokens; works with API v1 and v2Chosen at creation, no more than one year ahead; emails at 30, 15, 7 and 1 day before expiry
Project API token
Set per project under Project Settings → API Permissions.
—YesStatus (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.

Open CircleCI's key settings

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.

Tokens cannot be edited; CircleCI recommends rotating them periodically.

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 your CircleCI 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 and CLI

CircleCI's SDKs and docs read the key from CIRCLE_TOKEN or CIRCLECI_TOKEN.

Things that catch people out

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

Common CircleCI authentication errors

Credentials provided are invalid.

The API returned 401 because the token is missing, expired, revoked or wrong.

Using your CircleCI 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 CircleCI key, these intents fit:

IntentWhat BotPassword does
list_credentialsLists the credentials this agent is granted and what it may do with each. Never values.
request_accessAsks 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_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.
capture_secretPlanned, not built yet: will read a newly created key straight from the page or command output into the vault.
store_secretSaves a value the agent already holds as a new vault item.

CircleCI also publishes its own MCP server. Whatever server the agent uses, keep the credential it authenticates with out of the agent's context.

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

Frequently asked questions

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.

Stop pasting CircleCI keys into agents

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