Environment variables

Open in

The Ably CLI supports environment variables for authentication and configuration of default settings. These variables are useful in scripts, CI/CD pipelines, and automated workflows where interactive login is not possible. When authentication variables are set, the CLI bypasses the ably login workflow entirely.

Synopsis

ably env [env-var-name] [options]

Arguments

env-var-name

Name of an environment variable. Supported variables:

  • ABLY_API_KEY — API key for data plane commands.
  • ABLY_TOKEN — Token/JWT for data plane commands.
  • ABLY_ACCESS_TOKEN — Access token for Control API commands.
  • ABLY_ENDPOINT — Override Realtime/REST API endpoint.
  • ABLY_APP_ID — Default app for the --app flag.
  • ABLY_CLI_CONFIG_DIR — Custom config directory.
  • ABLY_HISTORY_FILE — Custom history file location.
  • ABLY_CLI_DEFAULT_DURATION — Auto-exit long-running commands after N seconds.
  • ABLY_CLI_NON_INTERACTIVE — Auto-confirm "Did you mean?" prompts.

Options

--json

Output results as compact JSON. Mutually exclusive with --pretty-json.

--pretty-json

Output results in formatted, colorized JSON. Mutually exclusive with --json.

--verbose | -v

Enable verbose logging. Can be combined with --json or --pretty-json.

Examples

Show usage doc for ABLY_API_KEY:

ably env ABLY_API_KEY

Show usage doc for ABLY_TOKEN:

ably env ABLY_TOKEN

Show usage doc for ABLY_ACCESS_TOKEN:

ably env ABLY_ACCESS_TOKEN

Show usage doc for ABLY_ENDPOINT:

ably env ABLY_ENDPOINT

Show usage doc for ABLY_API_KEY as compact JSON (machine-readable, useful in scripts):

ably env ABLY_API_KEY --json

Usage

To publish using ABLY_API_KEY:

ABLY_API_KEY="your-app-id.key-id:key-secret" ably channels publish my-channel "Hello"

To subscribe using ABLY_TOKEN:

export ABLY_TOKEN="$(ABLY_API_KEY='appId.keyId:keySecret' ably auth issue-jwt-token --token-only)"
ably channels subscribe my-channel

To list all apps using ABLY_ACCESS_TOKEN:

ABLY_ACCESS_TOKEN="your-access-token" ably apps list --json

To publish to a custom Ably endpoint using ABLY_ENDPOINT:

export ABLY_ENDPOINT="custom-endpoint.example.com"
ably channels publish my-channel "Hello"

See also

  • Login — Log in to your Ably account via OAuth instead of using environment variables.
  • CLI reference — Full list of available commands.