Commands

Reference for all DevGrid CLI commands.

Help

devgrid-cli help

Prints usage information and available commands.


Authentication

Most commands that call the DevGrid API require authentication. The CLI resolves credentials in this order:

  1. Access tokenDEVGRID_ACCESS_TOKEN or --token
  2. One-shot OAuth — username/password or client ID/secret via env vars or flags
  3. Cached login — token from a previous devgrid login
  4. Deprecated API keyDEVGRID_API_KEY (fallback only; a deprecation warning is shown)

devgrid login

Cache OAuth credentials for local use.

devgrid-cli login [options]
FlagDescription
--usernameUsername for password grant
--passwordPassword (prompted if omitted with --username)
--client-idClient ID for client credentials grant
--client-secretClient secret (prompted if omitted with --client-id)
--envEnvironment for credential storage (prod, dev, local; default from ENV)

Password grant (interactive):

devgrid-cli login --username [email protected]

Client credentials grant (automation-friendly):

devgrid-cli login --client-id YOUR_CLIENT_ID --client-secret YOUR_SECRET

Credentials are stored at ~/.config/devgrid/<env>/credentials.json (or $XDG_CONFIG_HOME/devgrid/<env>/credentials.json).

Note: SSO users cannot use the password grant with their SSO password. Use a dedicated service account or client credentials grant. Confirm client credentials availability with your DevGrid administrator.

devgrid logout

Remove cached credentials for an environment.

devgrid-cli logout [--env prod]

devgrid auth status

Show whether you are logged in, the grant type, and token expiry.

devgrid-cli auth status [--env prod]

Example output when logged in:

Logged in to prod (password grant)
Token expires: 2026-07-01T15:30:00Z

Auth environment variables

VariablePurpose
DEVGRID_ACCESS_TOKENPre-fetched OAuth access token (highest priority)
DEVGRID_USERNAMEUsername for one-shot password grant
DEVGRID_PASSWORDPassword for one-shot password grant
DEVGRID_CLIENT_IDClient ID for one-shot client credentials grant
DEVGRID_CLIENT_SECRETClient secret for one-shot client credentials grant
DEVGRID_API_KEYDeprecated — legacy API key fallback
DEVGRID_AUTH_URLOverride OAuth token endpoint
DEVGRID_AUDIENCEOAuth audience (default: https://api.devgrid.io)
DEVGRID_ENVAPI environment selector (dev or prod)
ENVConfig section / credential store environment (local, dev, prod)

CI examples

Client credentials (recommended for pipelines):

# GitHub Actions example
env:
  DEVGRID_CLIENT_ID: ${{ secrets.DEVGRID_CLIENT_ID }}
  DEVGRID_CLIENT_SECRET: ${{ secrets.DEVGRID_CLIENT_SECRET }}
steps:
  - run: devgrid-cli sync

Confirm that client credentials are enabled for your DevGrid tenant before relying on this in production CI.

Pre-fetched access token:

export DEVGRID_ACCESS_TOKEN="${{ secrets.DEVGRID_ACCESS_TOKEN }}"
devgrid-cli sync

Legacy API key (deprecated):

export DEVGRID_API_KEY=your-api-key
devgrid-cli sync

Init

Create a starter devgrid.yml in the current directory.

devgrid-cli init

If devgrid.yml already exists, the command exits without overwriting.


Lint

Validate devgrid.yml against the CLI schema.

devgrid-cli lint

Checks that required fields are present, types are correct, and no unsupported properties are included. Run this before sync in CI.

Minimal example:

project:
  appId: my-app
  components:
    - name: my-service
      shortId: svc-001

For the full schema, field reference, and examples, see devgrid.yml.


Sync

Apply local devgrid.yml configuration to DevGrid.

devgrid-cli sync [options]

Requires authentication — see Authentication above.

FlagDescription
--repo-idLink synced components to a repository ID in DevGrid
--tokenOAuth access token (overrides env)
--usernameOne-shot password grant username
--passwordOne-shot password grant password
--client-idOne-shot client credentials client ID
--client-secretOne-shot client credentials client secret

The sync process:

  1. Validates devgrid.yml
  2. Fetches current state from DevGrid
  3. Creates or updates applications and components
  4. Establishes relationships and dependencies
  5. Optionally links components to a repository when --repo-id is set

Dry Run

Preview sync changes without applying them.

devgrid-cli dry_run [options]

Accepts the same authentication and sync flags as devgrid sync.

Output is controlled by configuration.dryRunOutput in devgrid.yml:

ValueBehavior
file (default)Writes plan to devgrid_dry_run_plan.json
stdoutPrints the plan to standard output

Example plan file contents include proposed CREATE, UPDATE, DELETE, and WARN actions for each resource.


Event

Send a deployment or build event to DevGrid.

devgrid-cli event [options]

Requires authentication — see Authentication above.

FlagDescription
--tokenOAuth access token
--username / --passwordOne-shot password grant
--client-id / --client-secretOne-shot client credentials

Use events to record deployments, builds, or other lifecycle activity against components defined in devgrid.yml.


Related pages