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-tokenIssue 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-onlyPipe the token to another command:
ably auth issue-ably-token --token-only | pbcopyIssue a token with multiple channel capabilities and a custom TTL:
ably auth issue-ably-token --capability '{"chat:*":["publish","subscribe"], "status:*":["subscribe"]}' --ttl 3600Issue a token with no associated client ID:
ably auth issue-ably-token --client-id "none" --ttl 3600Use 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 --jsonIssue a token and output the full result in formatted JSON:
ably auth issue-ably-token --pretty-jsonSee also
- Auth — Explore all
ably authcommands. - CLI reference — Full list of available commands.