Overview
Theupdate() method allows you to modify an existing session after it has been created. This is useful when you need to update session metadata, status, or other properties.
Parameters
string
required
The ID of the session to update.
string
The custom ID associated with the session.
string
The status of the session. Valid values are
PENDING, COMPLETED, FAILED. Other string values are sent to the API unchanged, so values added in newer API versions can be used; the API rejects invalid ones.string
The context provided to the AI product during the session or ground-truth related context.
string
The reason the session was stopped. Useful for recording why a conversation ended.
object
Additional metadata to associate with the session.
string
Any error message associated with the session. Useful for tracking failed sessions or sessions that encountered issues.
Returns
Returns the updatedSession object.
Example
Use Cases
Recording Session Errors
Store error information when a session encounters issues:Adding Session Metadata
Update a session with additional metadata:Notes
All fields except
session_id default to PydanticUndefined (from pydantic_core).
Omit a field (or pass PydanticUndefined) to leave it unchanged.
Pass None to explicitly clear an optional field.
Pass a value to update it.Related Methods
- Create Session - Create a new session
- Get Session - Retrieve a session
- Get Session By Custom ID - Retrieve a session by its Custom ID
- List Sessions - List all sessions