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
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_idstringoptional -
An identifier for the space. If
space_idis not provided in the URL, the default space is used. Refer to Spaces for more information.
Request body
-
ai_index_idsstring[] · 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
writeprivilege on its backing index. -
eventsunion oneOf[] · min items: 1 · max items: 1000required -
The events to save.
- One of:
-
event_atstring · max length: 64required -
When the agent created the event, as an ISO 8601 date and time such as
2026-11-16T09:58:00.000Z. -
idstring · min length: 1 · max length: 256required -
The event id, unique within the session. Readers drop resent duplicates by session and event id.
-
statusenumnullable -
Whether the tool succeeded. Leave it out or send null when unknown; it is stored as
unknown. -
Values:
successfulfailednull
A user message event.
An assistant message or tool call request event.
A model reasoning text event.
A tool execution result event.
A session metadata event carrying custom fields.
Responses
The result for every event.
user_id is missing and the caller has no user profile, user_id names another user and the caller lacks contextEngine:manage_memory, or the caller cannot write to one of the AI indices.