Skip to main content
Sentry CLI resolves the target organization and project from multiple sources, following a well-defined priority order. This enables both explicit targeting (org/project) and automatic inference from your environment.

Resolution Priority

The CLI resolves org and project in this order (highest to lowest):
  1. Explicit CLI arguments - sentry issue list acme/frontend
  2. Environment variables - SENTRY_ORG / SENTRY_PROJECT
  3. Config defaults - sentry config set org acme
  4. DSN auto-detection - Scans source code and .env files
  5. Directory name inference - Matches project slugs using word boundaries

Explicit CLI Arguments

Org/Project Format

Most commands accept an org/project argument in the format <org>/<project>:

Positional vs Flag Arguments

Some commands use positional arguments, others use flags:
When using flags, both --org and --project must be provided together. Providing only one will result in an error.

Environment Variables

Set organization and project via environment variables:

Combo Notation

SENTRY_PROJECT supports the <org>/<project> combo notation:
When the combo form is used, SENTRY_ORG is ignored.

Resolution Logic

Config Defaults

Set default org and project that persist across commands:
Defaults are stored in SQLite:

DSN Auto-Detection

When no explicit target is provided, the CLI automatically detects the project from DSN:

Resolution via DSN

The CLI resolves DSN to org/project using cached project info:

Project Cache Schema

Project info is cached to avoid repeated API calls. Cache entries are keyed by either org_id:project_id or dsn_key depending on the DSN format.

Directory Name Inference

As a last resort, the CLI infers the project from the current directory name:

Word Boundary Matching

The inference uses bidirectional word boundary matching (\b):

Inference Rules

  • Minimum directory name length: 2 characters
  • Hidden directories (starting with .) are skipped
  • Matches are cached for 24 hours
Directory name inference queries all accessible projects via the API. It will be skipped if not authenticated.

Multiple Project Resolution

In monorepo scenarios, the CLI may detect multiple projects:
Commands that support multiple projects (like issue list) will process all detected targets.

Org Prefix Normalization

DSN hosts encode org IDs with an o prefix (e.g., o1081365). The API rejects this form, so the CLI strips it:
This normalization is applied automatically to all parsed org arguments.
The regex /^o(\d+)$/ is safe for slugs like “organic” because it requires the entire string to match the pattern.

Resolved Target Type

All resolution functions return a ResolvedTarget:

Display Names

The CLI displays friendly names when available:

Error Handling

Missing Context

When no target can be resolved:

Ambiguous Projects

When a project slug exists in multiple organizations:

Resolution Failures

Numeric Project IDs

The CLI supports numeric project IDs for API queries:
Numeric IDs avoid “project not actively selected” errors in some API endpoints.
When a numeric project ID is successfully resolved, the CLI hints about using the slug form for faster lookups.