PATCH /api/v1/documents/doc-55/restore • HTTP 200 OK

Soft Delete & Restore State API Example — Request & Response Example

Shows how real-world applications handle soft-deletion: toggling a deleted_at timestamp rather than permanently executing raw SQL DELETE.

1. HTTP Client Request (PATCH)

PATCH /api/v1/documents/doc-55/restore HTTP/1.1
{
  "Content-Type": "application/json"
}

{
  "action": "restore"
}

2. Server JSON Response (HTTP 200 OK)

{
  "id": "doc-55",
  "title": "Q3 Financial Projections Memo",
  "is_deleted": false,
  "deleted_at": null,
  "restored_at": "2026-10-06T12:55:00Z",
  "status": "active"
}

Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)

curl -X PATCH "https://cometflow.space/api/v1/documents/doc-55/restore" \
  -H "Content-Type: application/json" \
  -d '{"action": "restore"}'
fetch('https://cometflow.space/api/v1/documents/doc-55/restore', {
  method: 'PATCH',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ action: 'restore' })
}).then(res => res.json()).then(console.log);
import requests

res = requests.patch('https://cometflow.space/api/v1/documents/doc-55/restore', json={"action": "restore"})
print(res.json())

How This API Call Works Step-by-Step

  1. 1. Action Route: POST or PATCH to a sub-action endpoint /restore.
  2. 2. Timestamp Reset: Server resets deleted_at = NULL.
  3. 3. Re-activation: The document reappears in active user workspaces.

Backend API Functions: The API function restoreDocument(req, res) updates the record to set deleted_at = null and logs an audit trail event.

Frequently Asked Questions

Why do production databases use soft deletion?

Soft deletion protects against accidental data loss, maintains relational foreign key integrity, and allows immediate "Undo" functionality.