Use the ably rooms messages subscribe command to subscribe to messages in one or more Ably Chat rooms.
Synopsis
ably rooms messages subscribe <room-names> [options]Arguments
room-names Required
The names of the chat rooms to subscribe to.
Options
--show-metadata
Display metadata attached to messages. Defaults to false.
--duration | -D
The duration in seconds to subscribe for before automatically unsubscribing.
--sequence-numbers
Display sequence numbers for messages. Defaults to false.
--client-id
A client ID to use for the subscription.
--json
Output results as compact JSON. Mutually exclusive with --pretty-json.
--pretty-json
Output results in formatted JSON. Mutually exclusive with --json.
--verbose | -v
Enable verbose logging. Can be combined with --json or --pretty-json.
Examples
Subscribe to messages in a single room:
ably rooms messages subscribe my-roomSubscribe to messages in multiple rooms:
ably rooms messages subscribe my-room another-roomSubscribe and show metadata:
ably rooms messages subscribe my-room --show-metadataSubscribe to room messages for a specific duration:
ably rooms messages subscribe my-room --duration 30Subscribe to room messages using an API key environment variable:
ABLY_API_KEY="YOUR_API_KEY" ably rooms messages subscribe my-roomSubscribe to room messages in JSON format:
ably rooms messages subscribe my-room --jsonSubscribe to room messages in formatted JSON:
ably rooms messages subscribe my-room --pretty-jsonSee also
- Rooms — Explore all
ably roomscommands. - CLI reference — Full list of available commands.