---
title: "Save, edit, remove or clear a personal memory [write]"
method: POST
path: "/memory"
tags: ["Memory"]
---

# Save, edit, remove or clear a personal memory \[write\]

`POST /memory`

## Request

- Base URL: `https://api.agentsky.dev/v1`
- URL: `https://api.agentsky.dev/v1/memory`
- Auth: HTTP bearer

Requires write scope and unrestricted owner-facing credentials in your personal universe. Read GET /memory first and copy its version exactly into expectedVersion, even when entries is empty. The sample uses null for a store before its first write; replace it with the returned version for an existing document. Stale writes return 409; reload and resolve the change instead of overwriting. Entries are limited to 2048 UTF-8 bytes and the complete recall context to 4000 characters. A state-changing clear advances the version; a no-op on an existing document retains it. Clear preserves allocated indexes.

## Request body

- union
  - object
    - `op` 'save', required
    - `text` string, required
    - `expectedVersion` string, nullable, required
  - object
    - `op` 'update', required
    - `index` integer, required
    - `text` string, required
    - `expectedVersion` string, nullable, required
  - object
    - `op` 'remove', required
    - `index` integer, required
    - `expectedVersion` string, nullable, required
  - object
    - `op` 'clear', required
    - `expectedVersion` string, nullable, required

## Response `200`

Saved entries and the opaque version required for the next write.

- object
  - `entries` object[], required
    - `index` integer, required
    - `text` string, required
  - `version` string, nullable, required

## Other responses

- `400`: invalid_memory: invalid operation or memory limit reached
- `401`: Authentication required
- `403`: insufficient_scope or personal_memory_only: caller or universe is not eligible
- `409`: memory_conflict: reload before writing
- `default`: Error — { error: { code, message, request_id } }

## Changes

- **2026-11-02** `e5e8f0229a99`: 4 info
  - added the media type `application/json` for the response with the status `400`
  - added the media type `application/json` for the response with the status `401`
  - added the media type `application/json` for the response with the status `403`
  - added the media type `application/json` for the response with the status `409`

[Operation history](https://skmtc.dev/agentsky/apis/agentsky-developer-api/changes/memory/post.md)

---

[API](https://skmtc.dev/agentsky/apis/agentsky-developer-api.md) - [All operations](https://skmtc.dev/agentsky/apis/agentsky-developer-api/llms.txt) - [OpenAPI document](https://skmtc.dev/agentsky/apis/agentsky-developer-api/revisions/0d435187cd55?raw)
