Skip to main content
Sentry CLI supports self-hosted Sentry instances. You’ll need to configure the base URL and, for OAuth authentication, a client ID.

Environment Variables

SENTRY_URL

Set SENTRY_URL to point to your self-hosted Sentry instance:
This variable affects:
  • API requests (all commands)
  • OAuth device flow (authentication)
  • Web UI URLs (opened in browser)
.bashrc or .zshrc
Then reload your shell:

SENTRY_CLIENT_ID

OAuth device flow requires Sentry 26.1.0 or later. For older versions, use token-based authentication.
For OAuth authentication on self-hosted instances, you must create an OAuth application and set SENTRY_CLIENT_ID:
1

Create an OAuth Application

  1. Log in to your self-hosted Sentry instance
  2. Go to Settings > Developer Settings
  3. Click Create New Application
  4. Set application name (e.g., “Sentry CLI”)
  5. Set Application Type to Public
  6. Set Redirect URIs to http://localhost (required but unused for device flow)
  7. Click Save
  8. Copy the Client ID
2

Set the environment variable

Add this to your shell profile alongside SENTRY_URL.
3

Authenticate

The CLI will use your self-hosted instance for the OAuth flow.

Authentication Methods

Requirements:
  • Sentry 26.1.0 or later
  • Both SENTRY_URL and SENTRY_CLIENT_ID set
  • Public OAuth application created in Developer Settings
Follow the prompts to complete authentication in your browser.
The OAuth flow uses SENTRY_URL for all authorization endpoints. Make sure your instance is accessible from your browser.

Token Authentication (Manual)

For older versions or if you prefer manual token management:
1

Create an auth token

  1. Log in to your Sentry instance
  2. Go to Settings > Account > API > Auth Tokens
  3. Click Create New Token
  4. Select scopes: project:read, project:write, org:read, event:read, event:write
  5. Click Create Token
  6. Copy the token (shown only once)
2

Set SENTRY_AUTH_TOKEN

3

Verify access

You should see:
With SENTRY_AUTH_TOKEN set, the CLI uses this token directly and skips OAuth. This is useful for CI/CD and older Sentry versions.

Token Authentication (Alternative)

You can also use SENTRY_TOKEN instead of SENTRY_AUTH_TOKEN:
Precedence: SENTRY_AUTH_TOKEN > SENTRY_TOKEN > stored OAuth token.

Verifying Configuration

Check auth status

Test API access

If commands fail with connection errors, verify:
  • SENTRY_URL is correct and accessible
  • Your self-hosted instance is running
  • Firewall rules allow access

Check effective URL

The CLI uses SENTRY_URL for all operations. You can verify the active configuration:

DSN Auto-Detection

When SENTRY_URL is set, the CLI only detects DSNs matching your self-hosted instance:
This prevents mixing SaaS and self-hosted DSNs, which would cause API errors.
If you work with multiple Sentry instances, use separate shells or shell aliases with different SENTRY_URL values.

Configuration Directory

By default, the CLI stores authentication and cache data in ~/.sentry/. For self-hosted instances, you might want separate configuration directories:
This keeps SaaS and self-hosted credentials separate.

Config Directory Contents

The database stores:
  • OAuth tokens and expiry times
  • User information
  • Organization/project cache
  • Default org/project settings
  • Pagination cursors

Moving Between Instances

To switch between SaaS and self-hosted:

Troubleshooting

Connection Refused

Solutions:
  • Verify the URL is correct: curl -I $SENTRY_URL
  • Check if Sentry is running
  • Verify firewall rules
  • Check DNS resolution: nslookup sentry.example.com

OAuth Client ID Required

Solutions:
  • Create an OAuth application in Developer Settings
  • Set SENTRY_CLIENT_ID environment variable
  • Or use token authentication instead

Sentry Version Too Old

OAuth device flow requires Sentry 26.1.0+. For older versions:
  1. Use manual token authentication:
  2. Or upgrade your Sentry instance

SSL Certificate Errors

If your self-hosted instance uses self-signed certificates:
Disabling SSL verification is insecure. Use proper certificates in production.
Better solutions:
  • Add your CA certificate to the system trust store
  • Use Let’s Encrypt for valid certificates
  • Use a proper SSL termination proxy

Wrong Instance Being Used

If commands hit the wrong Sentry instance:
Make sure:
  • SENTRY_URL is set correctly
  • No conflicting values in .env files
  • Shell profile files don’t override your values

Best Practices

~/.bashrc
.env.production
Then load it:
SENTRY_SETUP.md
  1. Login: sentry auth login
  2. Test: sentry org list
CI/CD:
This avoids OAuth flow complexity in CI while keeping local dev convenient.