Skip to main content

Overview

The update() 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 updated Session 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.