v2
OpenAPI 3.0.02026-08-051996591.2 MBCreate agent session
Creates a new session for interacting with an agent. A session maintains state across all events, tool use, and agent responses produced during the interaction.
You can set the session's initial properties, including optional metadata. Metadata can influence agent behavior, personalize responses, or apply access controls. Instructions and tools can also reference metadata using ${\session.metadata.field} or $\ref syntax.
A session also serves as the workspace for artifacts. This supports file uploads and multi-step workflows. For more information, see Working with artifacts in sessions.
Example request
\$ curl -X POST https://api.vectara.io/v2/agents/support-agent/sessions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "user_12345_session",
"name": "Customer Support Session",
"metadata": {
"user_role": "premium",
"language": "en"
}
}'
A successful response includes the unique session key, configuration metadata, and timestamps for creation and last update.
Path parameters
A unique key that identifies an agent.
The unique key of the agent to create a session for.
Headers
The platform makes a best effort to complete the request in the specified seconds, or it times out.
The platform makes a best effort to complete the request in the specified milliseconds, or it times out.
Request body
Example request
{
"key": "customer_support_chat",
"name": "Customer Support Session",
"description": "Helping customer troubleshoot issues",
"metadata": {
"customer_id": "12345",
"priority": "medium",
"channel": "web_chat"
},
"enabled": true,
"tti_minutes": 60,
"secrets": {
"slack_user_token": "xoxp-your-token-here"
}
}Response
The complete session configuration, including the unique session key, associated agent key, and creation timestamp.
Example response
{
"key": "customer_support_chat",
"agent_key": "customer_support",
"name": "Customer Support Session",
"description": "Helping customer troubleshoot widget installation issues",
"metadata": {
"customer_id": "12345",
"priority": "high",
"channel": "web_chat"
},
"current_step_name": "billing",
"enabled": true,
"status": "stopped",
"created_by_agent_key": "customer_support",
"created_by_session_key": "customer_support_chat",
"tti_minutes": 60,
"created_at": "2024-01-15T10:30:00Z",
"session_context_usage": {
"input_tokens": {
"count": 120,
"cached_tokens": 100
},
"output_tokens": {
"count": 30
},
"total_tokens": 150,
"model_context_window": 200000
},
"effective_compaction": {
"enabled": true,
"threshold_percent": 80,
"keep_recent_inputs": 1
},
"alias_key": "support",
"secrets": {
"slack_user_token": "****"
}
}