---
title: "Edit a single memory in place while preserving its ID and usefulness posterior. Modes: 'replace' overwrites entire content; 'exact' performs surgical find-and-replace of oldString→newString (fails if missing or ambiguous)"
method: POST
path: "/api/memory/edit"
tags: ["Memory"]
---

# Edit a single memory in place while preserving its ID and usefulness posterior. Modes: 'replace' overwrites entire content; 'exact' performs surgical find-and-replace of oldString→newString (fails if missing or ambiguous)

`POST /api/memory/edit`

## Request body

- object
  - `memoryId` string, uuid
  - `key` string
  - `scope` 'agent' | 'swarm'
  - `mode` 'replace' | 'exact'
  - `content` string
  - `oldString` string
  - `newString` string
  - `intent` string, required
  - `expectedVersion` integer

## Response `200`

Memory edited

- object
  - `memory` AgentMemory, required
    - `id` string, uuid, required
    - `agentId` string, nullable, required
    - `scope` 'agent' | 'swarm', required
    - `key` string, nullable
    - `name` string, required
    - `content` string, required
    - `summary` string, nullable, required
    - `source` 'manual' | 'file_index' | 'session_summary' | 'task_completion', required
    - `sourceTaskId` string, uuid, nullable, required
    - `sourcePath` string, nullable, required
    - `chunkIndex` integer
    - `totalChunks` integer
    - `tags` string[], required
    - `createdAt` string, required
    - `updatedAt` string, nullable
    - `accessedAt` string, required
    - `expiresAt` string, nullable
    - `accessCount` integer
    - `embeddingModel` string, nullable
    - `contentHash` string, nullable
    - `version` integer
  - `changed` boolean, required
  - `previousVersion` number, required
  - `version` number, required
  - `contentHash` string, required

## Other responses

- `400` — Validation error
- `404` — Memory not found
- `409` — Version conflict

---

[API](https://skmtc.net/desplega-ai/apis/agent-swarm-api.md) · [All operations](https://skmtc.net/desplega-ai/apis/agent-swarm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/desplega-ai/agent-swarm-api/versions/0375890be8c4/schema)
