---
title: "Create a user session"
method: POST
path: "/user/{userId}/session/create"
tags: ["User"]
---

# Create a user session

`POST /user/{userId}/session/create`

## Request

- Base URL: `https://api.chatbotkit.com/api/v1`
- URL: `https://api.chatbotkit.com/api/v1/user/{userId}/session/create`
- Auth: HTTP bearer

## Path parameters

- `userId` string, required: The ID of the user

## Request body

- object
  - `durationInSeconds` number: The lifetime of the session token in seconds
  - `config` object
    - `allowedRoutes` string[]: Glob patterns restricting which API routes the token may access
    - `contactId` string: Optional contact ID to include in the session token

## Response `200`

The session was created successfully

- object
  - `id` string, required: The ID of the created session
  - `token` string, required: The temporary session token
  - `expiresAt` number, required: The timestamp for when the session token expires (in milliseconds)

## Other responses

- `default`: An error response

---

[API](https://skmtc.dev/chatbotkit/apis/cbk-api.md) · [All operations](https://skmtc.dev/chatbotkit/apis/cbk-api/llms.txt) · [OpenAPI document](https://skmtc.dev/chatbotkit/apis/cbk-api/revisions/13d250576136?raw)
