Forget session memories Experimental; added in 9.7.0

POST /api/context_engine/memory/_forget

Spaces method and path for this operation:

post /s/{space_id}/api/context_engine/memory/_forget

Refer to Spaces for more information.

Forgets session memories by ID for the target user. The route reports a memory of another user or another space as not_found, so it does not reveal whether the memory exists.

Requires the contextEngine:write privilege. Without user_id, the route forgets the caller's own memories, and a caller without a user profile gets a 403. Naming another user in user_id also requires contextEngine:manage_memory.

Forgetting writes a tombstone so reads stop returning the memory after the next Elasticsearch refresh, while Elasticsearch keeps its revisions until retention removes them. A read immediately after forgetting can still return the memory, and forgetting a memory right after writing it can return not_found until that write is visible. If Elasticsearch rejects a tombstone, the route returns failed with error and the caller can retry that ID.

After authorization, validation, and feature-flag checks pass, the route writes one memory_forget audit event per unique memory ID. Forgetting still works when memory is turned off.

Returns a 404 response when Context Engine is turned off in this space (contextEngine:enabled).

For more information, refer to the Context Engine documentation.

[Required authorization] Route required privileges: contextEngine:write. Extended privileges (optional, expand functionality when granted): contextEngine:manage_memory.

Headers

  • kbn-xsrf string Required

    A required header to protect against CSRF attacks

application/json

Body

  • ids array[string] Required

    The ids of the memories to forget. The route collapses duplicates.

    At least 1 but not more than 100 elements. Minimum length of each is 1, maximum length of each is 256.

  • user_id string

    The Kibana user profile UID that the memories belong to. Omit this field to use the caller's user profile. Naming another user requires contextEngine:manage_memory.

    Minimum length is 1, maximum length is 1024.

Responses

  • 200 application/json

    The outcome for every requested memory.

    Hide response attribute Show response attribute object
    • results array[object] Required

      One result per unique id, in request order.

      Not more than 100 elements.

      Hide results attributes Show results attributes object
      • error string

        Why the tombstone failed when outcome is failed.

      • id string Required

        The memory id.

      • outcome string Required

        What happened to the memory: forgotten if a tombstone was written, already_forgotten if it was already tombstoned, not_found if it does not exist or belongs to another user or space, or failed if Elasticsearch rejected the tombstone.

        Values are forgotten, already_forgotten, not_found, or failed.

  • 403 application/json

    user_id is missing and the caller has no user profile, or user_id names another user and the caller lacks contextEngine:manage_memory.

    Hide response attributes Show response attributes object
    • error string

      The HTTP status text.

    • message string Required

      A human-readable error message.

    • statusCode number

      The HTTP status code.

  • 404 application/json

    Context Engine is turned off in this space.

    Hide response attributes Show response attributes object
    • error string

      The HTTP status text.

    • message string Required

      A human-readable error message.

    • statusCode number

      The HTTP status code.

POST /api/context_engine/memory/_forget
curl \
  -X POST "https://${KIBANA_URL}/api/context_engine/memory/_forget" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -H "kbn-xsrf: true" \
  -d '{
    "ids": ["7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10", "0d4e8a91-6c2b-4f3a-8d15-9b7e1c5a2f44"]
  }'
POST kbn:/api/context_engine/memory/_forget
{
  "ids": ["7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10", "0d4e8a91-6c2b-4f3a-8d15-9b7e1c5a2f44"]
}
Request example
Example request to forget two of the caller's memories, keeping their revisions until retention removes them
{
  "ids": [
    "7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10",
    "0d4e8a91-6c2b-4f3a-8d15-9b7e1c5a2f44"
  ]
}
Response examples (200)
One memory was forgotten and Elasticsearch rejected the other tombstone
{
  "results": [
    {
      "id": "7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10",
      "outcome": "forgotten"
    },
    {
      "error": "index [.ds-.context-engine-session-memory-2026.11.16-000001] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];",
      "id": "0d4e8a91-6c2b-4f3a-8d15-9b7e1c5a2f44",
      "outcome": "failed"
    }
  ]
}
One memory was forgotten, and the other does not exist for this user
{
  "results": [
    {
      "id": "7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10",
      "outcome": "forgotten"
    },
    {
      "id": "0d4e8a91-6c2b-4f3a-8d15-9b7e1c5a2f44",
      "outcome": "not_found"
    }
  ]
}
Response examples (403)
The request names another user in `user_id` and the caller lacks the manage memory privilege
{
  "error": "Forbidden",
  "message": "Acting on the memory of another user requires the [contextEngine:manage_memory] privilege.",
  "statusCode": 403
}
`user_id` is missing and the caller has no user profile
{
  "error": "Forbidden",
  "message": "The caller has no user profile, so the request cannot be attributed to a user. Log in to Kibana once to create a profile, use an API key whose owner has one, or set `user_id` if you have the `contextEngine:manage_memory` privilege.",
  "statusCode": 403
}
Response examples (404)
Context Engine is turned off in this space
{
  "error": "Not Found",
  "message": "Not Found",
  "statusCode": 404
}