Rooms messages subscribe

Open in

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-room

Subscribe to messages in multiple rooms:

ably rooms messages subscribe my-room another-room

Subscribe and show metadata:

ably rooms messages subscribe my-room --show-metadata

Subscribe to room messages for a specific duration:

ably rooms messages subscribe my-room --duration 30

Subscribe to room messages using an API key environment variable:

ABLY_API_KEY="YOUR_API_KEY" ably rooms messages subscribe my-room

Subscribe to room messages in JSON format:

ably rooms messages subscribe my-room --json

Subscribe to room messages in formatted JSON:

ably rooms messages subscribe my-room --pretty-json

See also

  • Rooms — Explore all ably rooms commands.
  • CLI reference — Full list of available commands.