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

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

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.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Organization token | — | Yes | One organization, all its projects; fixed limited permissions designed for CI and Sentry CLI | — |
| Personal token | — | Yes | Any organization and project the user can reach; permissions chosen at creation, cannot exceed the user's | — |
| Internal integration token | — | Yes | One organization; customizable and editable permissions | — |
| DSN | — | No | Submit 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.

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

- `SENTRY_AUTH_TOKEN`
- `SENTRY_DSN`
- `SENTRY_ORG`

## Gotchas

- 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 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.
- `cli_login`: Lets 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.
- `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 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.

## Sources

- https://docs.sentry.io/account/auth-tokens/
- https://docs.sentry.io/api/guides/create-auth-token/
- https://docs.sentry.io/concepts/key-terms/dsn-explainer/
- https://docs.sentry.io/cli/configuration/
- https://mcp.sentry.dev/
