> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jelou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory Management

> Read and write per-user session memory through the Memory API v2

The **Memory API** lets you manage Jelou's per-user key-value storage from external services. It is the same memory you see as `$memory` in the builder and that `ctx.memory` uses in Functions — a single memory per user, not a parallel copy.

Use it to persist conversation state across turns: multi-step flows, carts, counters, preferences, and temporary data without an external database.

<Note>
  For usage from Functions with the SDK (`ctx.memory`), see the [Session memory](/en/guides/functions/memoria) guide. This section documents the direct REST endpoints of the Memory API v2.
</Note>

***

## Data model

Each record belongs to a user and has:

* **Key** — the variable name.
* **Value** — any JSON type.
* **Per-variable TTL** — when that individual variable expires (maximum 24h).
* **hashTTL** — when the user's entire memory expires. The platform applies 30 days by default; you can override it per request with the `x-hash-ttl` header.

## User identification

A user's memory is identified by their **`userReferenceId`** together with the **`botId`**. You send these parameters in the body of each request to read or write memory by the user's external reference.

## Authentication

Every request is authenticated with an **API key** in the `x-api-key` header and made through the Jelou gateway.

```
x-api-key: API_KEY
```

<Warning>
  The API key must have the corresponding scopes: `memory:read` for reading and `memory:write` for writing. See [API Keys](/en/guides/configuracion/claves-api) to create and manage your keys.
</Warning>

***

## Resources

<Steps>
  <Step title="Read memory">
    Get all records for a user or a single record by key.

    [See get records →](/en/api/memoria/obtener-registros) · [See get one record →](/en/api/memoria/obtener-registro)
  </Step>

  <Step title="Write memory">
    Save one or several records by user reference (up to 20 keys per request).

    [See save records →](/en/api/memoria/guardar-registros)
  </Step>
</Steps>
