Environment Variables
SENTRY_URL
SetSENTRY_URL to point to your self-hosted Sentry instance:
- API requests (all commands)
- OAuth device flow (authentication)
- Web UI URLs (opened in browser)
- macOS/Linux
- Windows (PowerShell)
- Windows (CMD)
- Docker/CI
.bashrc or .zshrc
SENTRY_CLIENT_ID
For OAuth authentication on self-hosted instances, you must create an OAuth application and setSENTRY_CLIENT_ID:
1
Create an OAuth Application
- Log in to your self-hosted Sentry instance
- Go to Settings > Developer Settings
- Click Create New Application
- Set application name (e.g., “Sentry CLI”)
- Set Application Type to Public
- Set Redirect URIs to
http://localhost(required but unused for device flow) - Click Save
- Copy the Client ID
2
Set the environment variable
SENTRY_URL.3
Authenticate
Example: Complete self-hosted setup
Example: Complete self-hosted setup
Authentication Methods
OAuth Device Flow (Recommended)
Requirements:- Sentry 26.1.0 or later
- Both
SENTRY_URLandSENTRY_CLIENT_IDset - Public OAuth application created in Developer Settings
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
- Log in to your Sentry instance
- Go to Settings > Account > API > Auth Tokens
- Click Create New Token
- Select scopes:
project:read,project:write,org:read,event:read,event:write - Click Create Token
- Copy the token (shown only once)
2
Set SENTRY_AUTH_TOKEN
3
Verify access
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 useSENTRY_TOKEN instead of SENTRY_AUTH_TOKEN:
Precedence:
SENTRY_AUTH_TOKEN > SENTRY_TOKEN > stored OAuth token.Verifying Configuration
Check auth status
- OAuth (Success)
- Environment Token (Success)
- Not Authenticated
Test API access
SENTRY_URLis correct and accessible- Your self-hosted instance is running
- Firewall rules allow access
Check effective URL
The CLI usesSENTRY_URL for all operations. You can verify the active configuration:
DSN Auto-Detection
WhenSENTRY_URL is set, the CLI only detects DSNs matching your self-hosted instance:
Configuration Directory
By default, the CLI stores authentication and cache data in~/.sentry/.
For self-hosted instances, you might want separate configuration directories:
Config Directory Contents
- 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
- 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
- Create an OAuth application in Developer Settings
- Set
SENTRY_CLIENT_IDenvironment variable - Or use token authentication instead
Sentry Version Too Old
-
Use manual token authentication:
- Or upgrade your Sentry instance
SSL Certificate Errors
If your self-hosted instance uses self-signed certificates:- 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:SENTRY_URLis set correctly- No conflicting values in
.envfiles - Shell profile files don’t override your values
Best Practices
Use shell aliases for multiple instances
Use shell aliases for multiple instances
~/.bashrc
Use .env files per project
Use .env files per project
.env.production
Document OAuth setup for team
Document OAuth setup for team
SENTRY_SETUP.md
- Login:
sentry auth login - Test:
sentry org list