Auth issue-ably-token

Open in

Use the ably auth issue-ably-token command to create an Ably Token with specified capabilities.

Synopsis

ably auth issue-ably-token [options]

Options

--app

The app ID to issue the token for. Uses the currently selected app if not specified.

--capability

A JSON string specifying the capabilities for the token. Defaults to '{"*":["*"]}'. Available operations are subscribe, publish, presence, history, stats, channel-metadata, push-subscribe, push-admin, privileged-headers, object-subscribe, object-publish, annotation-subscribe, annotation-publish, message-update-own, message-update-any, message-delete-own, and message-delete-any.

--client-id

The client ID to associate with the token. Use "none" to issue a token with no client ID.

--ttl

The time to live for the token in seconds. Defaults to 3600.

--token-only

Output only the token string, without any additional information.

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

Issue a default Ably Token:

ably auth issue-ably-token

Issue a token with specific capabilities:

ably auth issue-ably-token --capability '{"my-channel":["publish","subscribe"]}'

Issue a token with a specific client ID:

ably auth issue-ably-token --client-id "user-123"

Output only the token string for scripting:

ably auth issue-ably-token --token-only

Pipe the token to another command:

ably auth issue-ably-token --token-only | pbcopy

Issue a token with multiple channel capabilities and a custom TTL:

ably auth issue-ably-token --capability '{"chat:*":["publish","subscribe"], "status:*":["subscribe"]}' --ttl 3600

Issue a token with no associated client ID:

ably auth issue-ably-token --client-id "none" --ttl 3600

Use a token inline to publish a message to a channel:

ABLY_TOKEN="$(ably auth issue-ably-token --token-only)" ably channels publish my-channel "Hello"

Issue a token and output the full result in JSON format:

ably auth issue-ably-token --json

Issue a token and output the full result in formatted JSON:

ably auth issue-ably-token --pretty-json

See also

  • Auth — Explore all ably auth commands.
  • CLI reference — Full list of available commands.