---
type: api
title: Forget session memories
description: "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."
url: https://www.elastic.co/elastic/docs-builder/docs/5002/api/kibana-serverless/operation/operation-post-context-engine-memory-forget
resource: https://www.elastic.co/elastic/docs-builder/docs/5002/api/kibana-serverless/operation/operation-post-context-engine-memory-forget
products:
  - Kibana
---

# Forget session memories

Authentication: required

Availability: Experimental

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/context_engine/memory/_forget`
- `POST` `/s/{space_id}/api/context_engine/memory/_forget`

#### 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](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Description

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](https://www.elastic.co/docs/explore-analyze/ai-features/context-engine).**

## Required privileges

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

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

- `ids` (string[] · min items: 1 · max items: 100) — required
  The ids of the memories to forget. The route collapses duplicates.
- `user_id` (string · min length: 1 · max length: 1024) — optional
  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`.

## Responses

#### `200`

The outcome for every requested memory.

`application/json`

- `results` (object[] · max items: 100)
  One result per unique id, in request order.
  - `error` (string)
    Why the tombstone failed when `outcome` is `failed`.
  - `id` (string)
    The memory id.
  - `outcome` (enum)
    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: `forgotten`, `already_forgotten`, `not_found`, `failed`
#### `403`

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

`application/json`

- `error` (string)
  The HTTP status text.
- `message` (string)
  A human-readable error message.
- `statusCode` (number)
  The HTTP status code.
#### `404`

Context Engine is turned off in this space.

`application/json`

- `error` (string)
  The HTTP status text.
- `message` (string)
  A human-readable error message.
- `statusCode` (number)
  The HTTP status code.
## Code examples

#### Console

```console
POST kbn:/api/context_engine/memory/_forget
{
  "ids": ["7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10", "0d4e8a91-6c2b-4f3a-8d15-9b7e1c5a2f44"]
}
```

#### curl

```curl
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"]
  }'
```

## Response examples

#### Failed to forget a memory

`application/json`

One memory was forgotten and Elasticsearch rejected the other tombstone

```json
{
  "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"
    }
  ]
}
```

#### Memories forgotten

`application/json`

One memory was forgotten, and the other does not exist for this user

```json
{
  "results": [
    {
      "id": "7c1f0b2e-5a43-4b0e-9a57-2f0f6f1d3a10",
      "outcome": "forgotten"
    },
    {
      "id": "0d4e8a91-6c2b-4f3a-8d15-9b7e1c5a2f44",
      "outcome": "not_found"
    }
  ]
}
```

#### Missing manage memory privilege

`application/json`

The request names another user in `user_id` and the caller lacks the manage memory privilege

```json
{
  "error": "Forbidden",
  "message": "Acting on the memory of another user requires the [contextEngine:manage_memory] privilege.",
  "statusCode": 403
}
```

#### No user profile

`application/json`

`user_id` is missing and the caller has no user profile

```json
{
  "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 \u0060user_id\u0060 if you have the \u0060contextEngine:manage_memory\u0060 privilege.",
  "statusCode": 403
}
```

#### Context Engine turned off

`application/json`

Context Engine is turned off in this space

```json
{
  "error": "Not Found",
  "message": "Not Found",
  "statusCode": 404
}
```

