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 initably 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 initUsage
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-1In 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 helpGlobal options
The following options can be used with any command for programmatic usage and debugging:
--jsonor--pretty-json— JSON output. Mutually exclusive options.--verbose— Enable verbose logging. Can be combined with--jsonor--pretty-json.
Feature set
You can use the Ably CLI for undertaking operations such as:
| Operation | Description |
|---|---|
| Ably Accounts | |
| List accounts | List the accounts you have access to. |
| Switch accounts | Switch between multiple Ably accounts. |
| Account statistics | Query your account statistics. |
| Ably Apps | |
| List apps | List all apps in your account. |
| Switch apps | Switch between multiple apps. |
| Manage apps | Create and delete apps. |
| Manage API keys | Create, update and revoke API keys in an app. |
| App statistics | Query app statistics. |
| Manage rules | Create, update and delete rules in an app. |
| Logs | Query and subscribe to logs. |
| Integrations and Queues | |
| Manage integrations | List, create and delete integrations. |
| Manage queues | List, create and delete queues. |
| Pub/Sub | |
| List channels | List active channels in an app. |
| Publish | Publish and batch publish messages. |
| Subscribe | Subscribe to messages on channels. |
| Presence | Enter and subscribe to the presence set of channels. |
| History | Query message history. |
| Occupancy | Fetch and subscribe to channel occupancy. |
| Chat | |
| List rooms | List chat rooms in an app. |
| Messages | Send and subscribe to messages. |
| Presence | Enter and subscribe to the presence set of chat rooms. |
| History | Query chat message history. |
| Occupancy | Fetch and subscribe to chat room occupancy. |
| Reactions | Send and subscribe to message-level and room-level reactions. |
| Typing indicators | Send and subscribe to typing indicators. |
| Spaces | |
| List spaces | List spaces in an app. |
| Members | Enter and subscribe the list of members. |
| Locations | Set and subscribe to member locations. |
| Cursors | Set and subscribe to member cursors. |
| Locks | Acquire 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 autocompleteThis 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-interactiveInteractive 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 listinstead ofably channels list.
CLI reference
See the CLI reference, for detailed documentation on every CLI command, including options, arguments, and usage examples.