Ably CLI

Open in

The Ably CLI brings the full power of Ably to your terminal. You can use it to manage your Ably account and its resources, and to explore Ably's APIs and features.

It's a quick and easy way to simulate additional clients when testing how Ably works.

The Ably CLI interacts with:

  • The Control API to manage your Ably account and applications.
  • Pub/Sub to publish and subscribe to messages in realtime.
  • Chat to send messages, display typing indicators and react to what's happening in a chat room.
  • Spaces to enter spaces and register member locations.

Installation

Get started in a single command:

npx -p @ably/cli ably init

ably init installs the Ably CLI globally, authenticates you, and installs the Ably Agent Skills into any AI coding tools it detects on your machine, such as Claude Code, Cursor, VS Code, and Windsurf.

To install the CLI manually first, use npm and then run ably init:

npm install -g @ably/cli
ably init

Usage

During ably init, the CLI authenticates using an OAuth Device Authorization flow: it displays an authorization code and opens your browser to approve it. Once approved, the CLI receives an access token that is stored locally and refreshed automatically, so there is no manual token management.

If you only need to authenticate, without installing Agent Skills, run ably login instead.

After authenticating and selecting your app and API key, you can interact with Ably resources directly from your terminal.

For example, open two terminal windows. In the first, subscribe to a channel:

# Attach to channel `channel-1` and start receiving new messages
ably channels subscribe channel-1

In the second, publish messages to the same channel:

# To publish 1 message:
ably channels publish channel-1 Hi!
# To publish 5 messages:
ably channels publish --count 5 channel-1 "Message number {{.Count}}"

To list all available commands, run:

ably help

Global options

The following options can be used with any command for programmatic usage and debugging:

  • --json or --pretty-json — JSON output. Mutually exclusive options.
  • --verbose — Enable verbose logging. Can be combined with --json or --pretty-json.

Feature set

You can use the Ably CLI for undertaking operations such as:

OperationDescription
Ably Accounts
List accountsList the accounts you have access to.
Switch accountsSwitch between multiple Ably accounts.
Account statisticsQuery your account statistics.
Ably Apps
List appsList all apps in your account.
Switch appsSwitch between multiple apps.
Manage appsCreate and delete apps.
Manage API keysCreate, update and revoke API keys in an app.
App statisticsQuery app statistics.
Manage rulesCreate, update and delete rules in an app.
LogsQuery and subscribe to logs.
Integrations and Queues
Manage integrationsList, create and delete integrations.
Manage queuesList, create and delete queues.
Pub/Sub
List channelsList active channels in an app.
PublishPublish and batch publish messages.
SubscribeSubscribe to messages on channels.
PresenceEnter and subscribe to the presence set of channels.
HistoryQuery message history.
OccupancyFetch and subscribe to channel occupancy.
Chat
List roomsList chat rooms in an app.
MessagesSend and subscribe to messages.
PresenceEnter and subscribe to the presence set of chat rooms.
HistoryQuery chat message history.
OccupancyFetch and subscribe to chat room occupancy.
ReactionsSend and subscribe to message-level and room-level reactions.
Typing indicatorsSend and subscribe to typing indicators.
Spaces
List spacesList spaces in an app.
MembersEnter and subscribe the list of members.
LocationsSet and subscribe to member locations.
CursorsSet and subscribe to member cursors.
LocksAcquire and subscribe to locks.

Auto-completion

The Ably CLI supports shell auto-completion for bash, zsh, and PowerShell. This helps you discover and use commands more efficiently.

To set up auto-completion, run:

ably autocomplete

This displays installation instructions specific to your shell. Follow them to enable tab completion for commands, subcommands, and options.

For more details, see the auto-completion CLI reference and auto completion usage documentation.

Interactive mode

The Ably CLI includes an interactive shell mode that provides a more convenient way to work with multiple commands:

ably-interactive

Interactive mode provides the following features:

  • Command history: Previous commands are saved and can be accessed with up/down arrows.
  • Tab completion: Full support for command and option completion.
  • Ctrl+C handling: A single Ctrl+C interrupts the current command and returns to the prompt. A double Ctrl+C (within 500ms) force quits the shell.
  • No "ably" prefix needed: Commands can be typed directly, for example channels list instead of ably channels list.

CLI reference

See the CLI reference, for detailed documentation on every CLI command, including options, arguments, and usage examples.