REST ClientChat

create_token

View as MarkdownOpen in Claude

Create a Chat authentication token.

Request

ttlintegerRequired1-43200
The maximum time, in minutes, that the access token will be valid for. Between 1 and 43,200 (30 days).
channelsobjectRequired
User-defined channel names with read/write permissions. Max of 500 channels. Channel names cannot start with the reserved prefix `sw_` and can be up to 250 characters.
member_idstringOptional<=250 characters
The unique identifier of the member. Up to 250 characters. If not specified, a random UUID will be generated.
stateobjectOptional
An arbitrary JSON object available to store stateful application information in. Must be valid JSON and have a maximum size of 2,000 characters.

Response

tokenstringRequired
The generated Chat Token.

Response Example

Response
1{
2 "token": "eyJ0eXAiOiJWUlQiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE2MjIxMjAxMjMsI...wMCwicnNlIjo5MDB9-BqG-DqC5LhpsdMWEFjhVkTBpQ"
3}

Example

1from signalwire.rest import RestClient
2
3client = RestClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7)
8
9token = client.chat.create_token(
10 channels=["support-room"],
11 member_id="user-456",
12 ttl=3600,
13)
14print("Chat token:", token.get("token"))