Overview
A Session represents a single conversation with an AI avatar. Each session includes a Daily.co video room for streaming and tracks the lifecycle from creation to completion.
Session Lifecycle:
- Created → Session initialized with Daily.co room
- Started → Avatar server activated and ready
- Ended → Session completed, resources released
Fields
The Session object contains all information needed to connect to and manage an avatar conversation.
| Field | Type | Description |
|---|
session_id | string | Unique session identifier (starts with sess_) |
avatar | object | Avatar information object |
avatar.avatar_id | string | ID of the avatar associated with this session |
avatar.name | string | Display name of the avatar |
avatar.url | string | Preview image URL for the avatar |
session_type | string | Type of session (currently only webrtc_video) |
status | string | Session status: created, started, or ended |
started_at | string | null | ISO 8601 timestamp when session started (null if not started) |
ended_at | string | null | ISO 8601 timestamp when session ended (null if not ended) |
created_at | string | ISO 8601 timestamp when session was created |
access_token | string | Access token for WebSocket authentication (only in create response) |
daily_room | object | null | Daily.co room information for video session |
daily_room.url | string | Daily.co room URL |
daily_room.name | string | Daily.co room name |
daily_room.token | string | Meeting token for joining the room |
expiration | string | null | ISO 8601 timestamp when session expires (based on subscription plan limits) |
duration | number | null | Session duration in seconds (only set after session ends) |
metadata | object | Custom metadata object |
The WebSocket URI for streaming commands is returned by the Start Session endpoint as ws_uri. It is not included in the session objects returned by GET /v1/sessions or GET /v1/sessions/{session_id}.
Status Values
The status field is derived from the session’s timestamps:
| Status | Condition | Description |
|---|
created | started_at is null | Session created but not yet started |
started | started_at is set, ended_at is null | Session is currently active |
ended | ended_at is set | Session has been completed |
Daily.co Room Integration
Sessions include a daily_room object for video streaming via Daily.co infrastructure:
- url: The Daily.co room URL for video connection
- name: Unique room identifier
- token: Authentication token for joining the room
- exp: Room expiration timestamp (based on subscription plan)
Session Expiration
The expiration field indicates when the session will automatically end, based on your subscription plan’s session time limits:
- Free Plan: Sessions expire after a certain duration
- Paid Plans: May have longer or unlimited session durations
Example
Created Session
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W4T",
"avatar": {
"avatar_id": "avat_01H3Z8G9YR3K2N5M6P7Q8W4T",
"name": "Professional Avatar",
"url": "https://example.com/avatars/preview.jpg"
},
"session_type": "webrtc_video",
"status": "created",
"access_token": "access_token_xxxxxxxxxxxxx",
"started_at": null,
"ended_at": null,
"expiration": null,
"duration": null,
"created_at": "2024-01-15T10:30:00Z",
"metadata": {
"user_name": "John Doe",
"session_purpose": "Customer Support"
}
}
Started Session
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W4T",
"avatar": {
"avatar_id": "avat_01H3Z8G9YR3K2N5M6P7Q8W4T",
"name": "Professional Avatar",
"url": "https://example.com/avatars/preview.jpg"
},
"session_type": "webrtc_video",
"status": "started",
"started_at": "2024-01-15T10:35:00Z",
"ended_at": null,
"expiration": "2024-01-15T14:35:00Z",
"duration": null,
"created_at": "2024-01-15T10:30:00Z",
"metadata": {
"user_name": "John Doe",
"session_purpose": "Customer Support"
}
}
Ended Session
{
"session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W4T",
"avatar": {
"avatar_id": "avat_01H3Z8G9YR3K2N5M6P7Q8W4T",
"name": "Professional Avatar",
"url": "https://example.com/avatars/preview.jpg"
},
"session_type": "webrtc_video",
"status": "ended",
"daily_room": {
"url": "https://agenthuman.daily.co/example-room-name",
"name": "example-room-name",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
},
"started_at": "2024-01-15T10:35:00Z",
"ended_at": "2024-01-15T11:20:00Z",
"expiration": "2024-01-15T14:35:00Z",
"duration": 2700,
"created_at": "2024-01-15T10:30:00Z",
"metadata": {
"user_name": "John Doe",
"session_purpose": "Customer Support"
}
}