Link Search Menu Expand Document Documentation Menu

You're viewing version 3.3 of the OpenSearch documentation. This version is no longer maintained. For the latest version, see the current documentation. For information about OpenSearch version maintenance, see Release Schedule and Maintenance Policy.

Create session

Introduced 3.3

Use this API to create a new session in a memory container. Sessions represent distinct interaction contexts between users and agents.

Path and HTTP methods

POST /_plugins/_ml/memory_containers/<memory_container_id>/memories/sessions

Path parameters

The following table lists the available path parameters.

Parameter Data type Required/Optional Description
memory_container_id String Required The ID of the memory container where the session will be created.

Request fields

The following table lists the available request body fields.

Field Data type Required/Optional Description
session_id String Optional A custom session ID. If provided, this ID is used for the session. If not provided, a random ID is generated.
summary String Optional A session summary or description.
metadata Object Optional Additional metadata for the session provided as key-value pairs.
namespace Object Optional Namespace information for organizing the session.

Example request: Create a session with a custom ID

POST /_plugins/_ml/memory_containers/SdjmmpgBOh0h20Y9kWuN/memories/sessions
{
  "session_id": "abc123",
  "metadata": {
    "key1": "value1"
  }
}

Example response: Custom session ID

{
  "session_id": "abc123",
  "status": "created"
}

Example request: Create a session with an autogenerated ID

POST /_plugins/_ml/memory_containers/SdjmmpgBOh0h20Y9kWuN/memories/sessions
{
  "summary": "This is a test session",
  "metadata": {
    "key1": "value1"
  },
  "namespace": {
    "user_id": "bob"
  }
}

Example response: Autogenerated session ID

{
  "session_id": "jTYm35kBt8CyICnjxJl9",
  "status": "created"
}

Response fields

The following table lists all response body fields.

Field Data type Description
session_id String The ID of the created session (either provided or auto-generated).
status String The status of the creation operation.