Save session events

Base URL
https://{kibana_url}
  • POST /api/context_engine/memory/_save_event
  • POST /s/{space_id}/api/context_engine/memory/_save_event
Auth

Saves the events of an agent session, one document per event, so the session can be searched later. User and assistant messages are indexed for semantic search.

Takes 1 to 1000 events and a body of up to 10 MB. A request that fails validation is rejected as a whole. Any field an event carries beyond the documented ones, such as a tool event's result or a tool call's args, is stored as sent, whatever its JSON type.

Each event gets its own result, in request order. A failed event, for example when its content could not be embedded, does not fail the request; resend it to retry. A resent event is stored again, and readers drop duplicates by session and event id.

The route needs the contextEngine:write privilege. Without user_id the events belong to the caller's user profile, and a caller without one gets a 403. Naming another user in user_id also needs contextEngine:manage_memory. Each AI index in ai_index_ids must exist in this space, and the caller needs the Elasticsearch write privilege on its backing index. Otherwise the request is rejected and nothing is saved.

After authorization, validation, and feature-flag checks pass, each request writes one memory_save_event audit event.

Returns a 404 response when Context Engine is turned off in this space (contextEngine:enabled), when memory is turned off (contextEngine:memoryEnabled), or when an AI index in ai_index_ids does not exist.

For more information, refer to the Context Engine documentation.

Required privileges

contextEngine:write. Extended privileges (optional, expand functionality when granted): contextEngine:manage_memory

Path parameters

space_id string optional

An identifier for the space. If space_id is not provided in the URL, the default space is used. Refer to Spaces for more information.

Header parameters

kbn-xsrf string required

A required header to protect against CSRF attacks

Request body

ai_index_ids string[] · max items: 100

The AI indices the agent could use in the session. Each must exist in this space, and the caller needs the Elasticsearch write privilege on its backing index.

events union oneOf[] · min items: 1 · max items: 1000 required

The events to save.

One of:

A user message event.

type enum required
Values: user
content string · max length: 1048576 required

The user message. It is indexed for semantic search.

event_at string · max length: 64 required

When the agent created the event, as an ISO 8601 date and time such as 2026-11-16T09:58:00.000Z.

id string · min length: 1 · max length: 256 required

The event id, unique within the session. Readers drop resent duplicates by session and event id.

seq number · min: 0 · max: 9007199254740991

An integer order key for events within the session.

turn_id string · min length: 1 · max length: 256 required

The turn the event belongs to. Events are grouped into turns by this id.

session_id string · min length: 1 · max length: 256 required

The session the events belong to.

user_id string · min length: 1 · max length: 1024

The Kibana user profile UID that the events belong to. Defaults to the caller's user profile. Naming another user requires contextEngine:manage_memory.

Responses

The result for every event.

application/json
results object[] · max items: 1000 required

One result per event, in request order.

error string

Why the event failed. Resend it to retry.

id string required

The event id.

status enum required

Whether the event was stored.

Values: created failed
Base URL
https://{kibana_url}