PubSub Tokens
Create PubSub token
Creates a time-limited PubSub Token that a client consumes to read from or publish to the channels allowed in the request. Call this operation from your server when granting PubSub access to a client; choose a lifetime from 1 minute through 30 days and never expose the project API token used to create it. Use Create chat token for Chat channels or Create API token for server-side REST authentication.
Permissions
The API token used to authenticate must have the following scope(s) enabled to make a successful request: PubSub.
Learn more about API scopes.
post/api/pubsub/tokens
Request body
Example request
{
"ttl": 15,
"channels": {
"channela": {
"read": true,
"write": false
},
"channelb": {
"read": true
}
},
"member_id": "John Doe",
"state": {
"display_name": "Joe",
"an_array": [
"foo",
"bar",
"baz"
]
}
}Response
The request has succeeded.
Example response
{
"token": "eyJ0eXAiOiJWUlQiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MjIxMjAxMjMsI...wMCwicnNlIjo5MDB9-BqG-DqC5LhpsdMWEFjhVkTBpQ"
}Changes
No changes found, but 3 of the 137 revisions have a changelog that could not be searched — this endpoint may have changed in one of them.