Developer tools

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

Sentry has two different credentials. Auth tokens (organization tokens, personal tokens, internal integrations) are secret and call the API or upload source maps. A DSN only lets a client submit events, so Sentry says it is safe to keep public, but it can still be abused to send junk events and can be rotated.

Sentry key types

TypePrefixSecret?ScopeExpiry
Organization token
Shown once at creation. Only organization owners and managers can revoke; all owners get a security email on creation. Created at Settings → Developer Settings → Organization Tokens.
—YesOne organization, all its projects; fixed limited permissions designed for CI and Sentry CLI—
Personal token
Created from the Personal Tokens page in the account dropdown. Permissions cannot be edited later.
—YesAny organization and project the user can reach; permissions chosen at creation, cannot exceed the user's—
Internal integration token
Created under Organization Settings → Custom Integrations → Create New Integration → Internal Integration (Manager or Admin role).
—YesOne organization; customizable and editable permissions—
DSN
Format {PROTOCOL}://{PUBLIC_KEY}:{SECRET_KEY}@{HOST}{PATH}/{PROJECT_ID}; the secret part is deprecated and optional. Found in the project's Client Keys (DSN) settings.
—NoSubmit events to one project only; cannot read data—

How to create a Sentry key

  1. For CI and Sentry CLI, open Settings → Developer Settings → Organization Tokens on sentry.io and create a token.
  2. For a personal token, open Personal Tokens from the account dropdown in the top left and choose the permissions.
  3. For API calls that need custom scopes, create an internal integration under Organization Settings → Custom Integrations and copy the token under Tokens.
  4. Copy the token and store it in a secret store; organization tokens are shown only once.

Limiting what the key can do

Organization tokens have fixed, limited permissions. Internal integrations and personal tokens let you pick scopes; each API endpoint's docs list the scope it needs (for example creating a project needs project:write). A personal token can never exceed its creator's permissions.

How to rotate a Sentry key

  1. Create a new token of the same type.
  2. Update CI and local configuration (SENTRY_AUTH_TOKEN).
  3. Revoke the old token.
  4. For a DSN, rotate or revoke the key under the project's Client Keys (DSN) settings.

For apps shipped to end-user devices, Sentry recommends configuring the DSN dynamically so it can change without an app update.

How to revoke a Sentry key

  1. Organization tokens can be revoked only by organization owners and managers; personal tokens can be revoked by their owner at any time.
  2. Revoke or rotate a DSN in the project's Client Keys (DSN) settings.

If your Sentry key leaked

  1. Revoke the auth token and create a replacement.
  2. Update SENTRY_AUTH_TOKEN wherever it is stored.
  3. For an exposed DSN, block the abusing IPs or rotate and revoke the DSN; it cannot read data.

Environment variables and CLI

Sentry's SDKs and docs read the key from SENTRY_AUTH_TOKEN, SENTRY_DSN or SENTRY_ORG.

Sentry CLI (sentry-cli): sentry-cli login prompts you to create or paste an auth token and saves it to ~/.sentryclirc; SENTRY_AUTH_TOKEN or --auth-token also work

Things that catch people out

  • A DSN is not a secret in the same way as an auth token; Sentry says it is safe to keep public, but it can be abused to submit junk events.
  • Do not put an auth token in client-side code or a public repository, even though the DSN can be shipped there.
  • Personal token permissions cannot be edited after creation.
  • Some features such as Crons Monitoring rely on DSN authentication rather than the auth token.

Using your Sentry 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 Sentry 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.
cli_loginLets git, Docker, the AWS CLI and kubectl log in through bpw's credential helper, so the token is fetched when the tool needs it and not written into its config. The helper hands the value to the tool, so the grant is always disclosing. Other tools use run_with; OAuth device logins are planned.
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.

Sentry 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 find my Sentry auth token?

Create one at Settings → Developer Settings → Organization Tokens, or from Personal Tokens in the account dropdown. Organization tokens are shown only at creation.

Is a Sentry DSN a secret?

Not really. Sentry says DSNs are safe to keep public because they only allow submitting events, though they can be abused to send junk events.

What is SENTRY_AUTH_TOKEN?

It is the environment variable Sentry CLI reads for the auth token, equivalent to the auth.token config key or --auth-token.

How do I rotate a Sentry DSN?

Rotate or revoke it in the project's Client Keys (DSN) settings.

Can an AI agent use my Sentry 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 Sentry keys into agents

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