Create agent session
POST/v2/agents/:agent_key/sessions
Create a new session for interacting with an agent. A session is the conversation container that maintains state across all messages, events, tool use, and agent responses.
This endpoint initializes the session and enables you to configure its 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, enabling 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.
Request
Responses
- 201
- 400
- 403
- 404
The response includes the complete session configuration including the unique session key, associated agent key, and creation timestamp.
Session creation request was malformed or references invalid agent.
Permissions do not allow creating sessions for this agent.
Referenced agent not found.