---
title: "Generate token for the client to connect Azure Web PubSub service."
method: POST
path: "/api/hubs/{hub}/:generateToken"
tags: ["webpubsub"]
---

# Generate token for the client to connect Azure Web PubSub service.

`POST /api/hubs/{hub}/:generateToken`

## Path parameters

- `hub` string, required

## Query parameters

- `userId` string
- `role` string[]
- `minutesToExpire` integer
- `api-version` string, required
- `group` string[]
- `clientType` 'Default' | 'MQTT'

## Response `200`

Success

- ClientTokenResponse — The response object containing the token for the client
  - `token` string — The token value for the WebSocket client to connect to the service

## Other responses

- `default` — Error response

---

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