---
title: "Create PubSub token"
method: POST
path: "/api/pubsub/tokens"
tags: ["PubSub Tokens"]
---

# Create PubSub token

`POST /api/pubsub/tokens`

Generate a PubSub Token to be used to authenticate clients to the PubSub Service.

#### 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](/docs/platform/your-signalwire-api-space).

## Request body

- PubSubNewPubSubToken
  - `ttl` integer, required — The maximum time, in minutes, for which the access token will be valid. Between 1 and 43,200 (30 days).
  - `channels` PubSubPubSubChannels, required — User-defined channel names. Each channel is an object with `read` and/or `write` properties. Max of 500 channels. Either `read`, `write`, or both are required inside each channel and default to `false`. Each channel name can be up to 250 characters. Must be valid JSON.
  - `member_id` string — The unique identifier of the member. Up to 250 characters. If not specified, a random UUID will be generated.
  - `state` PubSubPubSubState — 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 `200`

The request has succeeded.

- PubSubPubSubToken
  - `token` string, required — A PubSub Token to be used to authenticate clients to the PubSub Service.

## Other responses

- `400` — The request is invalid.
- `401` — Access is unauthorized.
- `422` — The request contains invalid parameters. See errors for details.
- `500` — An internal server error occurred.

---

[API](https://skmtc.net/signalwire/apis/signalwire-rest-api.md) · [All operations](https://skmtc.net/signalwire/apis/signalwire-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/signalwire/signalwire-rest-api/versions/05c5164b85c7/schema)
