Use the ably auth issue-jwt-token command to create an Ably JWT token with specified capabilities.
Synopsis
ably auth issue-jwt-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 JWT token:
ably auth issue-jwt-tokenIssue a JWT token with specific capabilities:
ably auth issue-jwt-token --capability '{"my-channel":["publish","subscribe"]}'Output only the token string:
ably auth issue-jwt-token --token-onlyIssue a JWT with multiple channel capabilities and a custom TTL:
ably auth issue-jwt-token --capability '{"chat:*":["publish","subscribe"], "status:*":["subscribe"]}' --ttl 3600Issue a JWT with a specific client ID and 24-hour TTL:
ably auth issue-jwt-token --client-id client123 --ttl 86400Use a JWT inline to publish a message to a channel:
ABLY_TOKEN="$(ably auth issue-jwt-token --token-only)" ably channels publish my-channel "Hello"Issue a JWT and output the full result in JSON format:
ably auth issue-jwt-token --jsonIssue a JWT and output the full result in formatted JSON:
ably auth issue-jwt-token --pretty-jsonSee also
- Auth — Explore all
ably authcommands. - CLI reference — Full list of available commands.