---
title: "Undo one dedup merge (restore the merged-away memory)"
method: POST
path: "/api/v1/admin/sleep/actions/{action_id}/undo-merge"
tags: ["admin-sleep"]
---

# Undo one dedup merge (restore the merged-away memory)

`POST /api/v1/admin/sleep/actions/{action_id}/undo-merge`

## Request

- Base URL: `https://memory.kagura-ai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://memory.kagura-ai.com/api/v1/admin/sleep/actions/{action_id}/undo-merge`
- Auth: none declared

Restore the loser of ONE dedup merge — row and Qdrant vector (#1209).

Self-scoped like the manual sleep trigger: the merge's report must belong
to the calling admin. The undo is itself audited as an ``undo_merge``
action on the same sleep report, so the merge's full history reads out of
one audit log. Reversibility is bounded by the declared retention window;
a purged loser returns 410 with the setting named.

## Path parameters

- `action_id` integer, required

## Response `200`

Successful Response

- UndoMergeResponse: 200 response for POST /admin/sleep/actions/{action_id}/undo-merge. Attributes: restored_memory_id: The merge loser brought back into recall. winner_id: The merge winner (unchanged by the undo). report_id: The sleep report whose audit log records both the merge and this undo. undone_action_id: The original merge action that was undone.
  - `restored_memory_id` string, required
  - `winner_id` string, nullable, required
  - `report_id` string, required
  - `undone_action_id` integer, required

## Other responses

- `400`: The action is not a dedup merge.
- `404`: Action not found or not owned by the caller.
- `409`: Conflicts with current state. ``SLEEP-UNDO-already_restored``: the memory or shadow edge is already back in its post-undo state (no-op). ``SLEEP-UNDO-not_merge_deleted``: the memory was deleted by something other than this merge. ``SLEEP-UNDO-edge_changed`` (#1450): a later writer changed or removed the shadow edge, so the pre-merge state could not be restored — unlike the other two, the undo did NOT happen.
- `410`: The merge loser was purged by the Sleep retention window (sleep_merge_retention_days) or the platform cleanup sweep (CLEANUP_DELETED_MEMORIES_RETENTION_DAYS, default 30 days) — no longer restorable.
- `422`: Validation Error

---

[API](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud.md) · [All operations](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/llms.txt) · [OpenAPI document](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/revisions/09f17f5ada29?raw)
