---
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`

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

## Path parameters

- `hub` string, required

## Query parameters

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

## Response `200`

The request has succeeded.

- ClientTokenResponse — The response object containing the client access token
  - `token` string, required — Access token for the client to connect Azure Web PubSub service

## Other responses

- `default` — The error response.

## Changes

- **2026-07-13** (2021-05-01-preview) `3c12a9fc6305` — 1 info
  - api operation id `WebPubSub_GenerateClientToken` removed and replaced with `GenerateClientToken`
- **2026-07-13** (2021-05-01-preview) `f4b776f5fabc` — 1 info
  - added the new optional `query` request parameter `group`
- **2026-07-13** (2021-05-01-preview) `662e3d90e2d3` — 1 info
  - endpoint added
- **2026-07-13** (2021-05-01-preview) `a1fc29b91d68` — 1 info
  - added the new optional `query` request parameter `clientType`
- **2026-07-13** (2021-05-01-preview) `db70e5df6e15` — 1 breaking
  - the `query` request parameter `api-version` became required

[Full history](https://skmtc.dev/azure/apis/webpubsub/changes/api/hubs/:hub/:generateToken/post.md)

---

[API](https://skmtc.dev/azure/apis/webpubsub.md) · [All operations](https://skmtc.dev/azure/apis/webpubsub/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/azure/webpubsub/revisions/3c12a9fc6305/schema)
