Channels presence subscribe

Open in

Use the ably channels presence subscribe command to subscribe to presence events on a channel.

Synopsis

ably channels presence subscribe <channel-name> [options]

Arguments

channel-name
Required

The name of the channel to subscribe to presence events on.

Options

--duration | -D

The duration in seconds to subscribe for before automatically unsubscribing.

--client-id

A client ID to use when subscribing.

--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 presence events:

ably channels presence subscribe my-channel

Subscribe for a specific duration:

ably channels presence subscribe my-channel --duration 60

Subscribe to presence events using a specific client ID:

ably channels presence subscribe my-channel --client-id "filter123"

Subscribe to presence using an API key environment variable:

ABLY_API_KEY="YOUR_API_KEY" ably channels presence subscribe my-channel

Subscribe to presence events in JSON format:

ably channels presence subscribe my-channel --json

Subscribe to presence events in formatted JSON:

ably channels presence subscribe my-channel --pretty-json

See also

  • Channels — Explore all ably channels commands.
  • CLI reference — Full list of available commands.