Skip to content

Sessions API

Sessions represent conversations between an agent and a user.

POST /sessions

Required fields:

FieldTypeDescription
agent_idstringAgent to run.
user_idstringStable user ID from your application.

Optional fields:

FieldTypeDescription
modalityvoice, voice+text, or textDefaults to voice.
dynamic_variablesobjectString variables bound to the session token.
ttl_secondsintegerToken TTL, capped at 3600 seconds.
overridesobjectPer-session agent overrides.
voice_stack_overrideobjectPer-session voice stack override.

Example:

Terminal window
curl -X POST "https://api.hyponema.ai/sessions" \
-H "Authorization: Bearer $HYPONEMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent_...",
"user_id": "user_123",
"modality": "voice+text"
}'

The response includes:

  • id: the session ID.
  • status: pending, in_progress, completed, or failed.
  • ws_url: signed voice WebSocket URL.
  • chat_url: signed chat WebSocket URL.
  • token: signed token, returned only on session creation.
  • expires_at: token expiry, returned only on session creation.
GET /sessions/{session_id}

Returns the current lifecycle view of the session. Tenant scope is enforced by the API key.

POST /sessions/{session_id}/end

Request body:

{
"status": "completed",
"reason": "User closed the widget."
}

status can be completed or failed. Ending a session is idempotent; an already closed session returns its current state.