Skip to main content
POST
Create session
Every endpoint on this page requires either a Clerk-issued JWT (Authorization: Bearer <token>) or an organization API key (x-api-key: pk_…). Anonymous calls return 401 Unauthorized. See Authentication for the full setup.

Code examples

Sample response

Store the session id — you’ll pass it as {sessionId} in every subsequent message call.

Authorizations

x-api-key
string
header
required

Organization API key. Obtain from the dashboard. Format: pk_live_…

Body

application/json
agentId
string<uuid>
required

The agent to chat with.

Example:

"a1b2c3d4-e5f6-7890-abcd-ef1234567890"

platform
enum<string>
default:SDK
required

Originating platform. Affects session tagging and analytics.

Available options:
SDK,
WEB,
WHATSAPP,
VOICE
metadata
object

Arbitrary key-value pairs attached to the session (max 4096 characters total). Useful for storing user IDs, locale, etc.

contact
object

Contact information to associate with this session.

Response

Session created.

id
string
Example:

"ses_01j3m8xkqp8v2nw4f7g9hk0r"

agentId
string<uuid>
platform
string
Example:

"SDK"

state
enum<string>
Available options:
OPEN,
CLOSED
Example:

"OPEN"

metadata
object
orgId
string
createdAt
string<date-time>
updatedAt
string<date-time>