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

# Delete a memory

> DELETE /v1/memories/{id} — soft delete or permanent GDPR erasure.

## `DELETE /v1/memories/{id}`

Delete a memory by ID. Supports two deletion modes:

* **Soft delete** (default) — marks the memory as `deprecated`. It is immediately excluded from all search results but remains in the database. Reversible via the dashboard.
* **Hard delete** (`?hard=true`) — permanently removes the memory from all stores: the relational database, vector index, search cache, and archive. **Irreversible.** Use for GDPR erasure requests.

**Required scope:** `memory:delete`

***

## Request

### Soft delete

```bash theme={null}
curl -X DELETE https://api.thrindex.com/v1/memories/3f2e1d0c-1234-5678-abcd-ef0123456789 \
  -H "Authorization: Bearer th_live_..."
```

### Hard delete (GDPR erasure)

```bash theme={null}
curl -X DELETE "https://api.thrindex.com/v1/memories/3f2e1d0c-1234-5678-abcd-ef0123456789?hard=true" \
  -H "Authorization: Bearer th_live_..."
```

### Path parameters

| Parameter | Type          | Required | Description                     |
| --------- | ------------- | -------- | ------------------------------- |
| `id`      | string (UUID) | yes      | The memory's unique identifier. |

### Query parameters

| Parameter | Type    | Required | Default | Description                                            |
| --------- | ------- | -------- | ------- | ------------------------------------------------------ |
| `hard`    | boolean | no       | `false` | Set to `true` for permanent erasure. **Irreversible.** |

***

## Response

### `204 No Content`

Empty body. The memory has been deleted (or flagged for deletion).

***

## Soft delete vs hard delete

|                      | Soft delete                      | Hard delete                    |
| -------------------- | -------------------------------- | ------------------------------ |
| **Default**          | Yes (`hard` omitted or `false`)  | No — must pass `?hard=true`    |
| **Effect on search** | Immediately excluded             | Permanently removed            |
| **Data retained**    | Yes — status set to `deprecated` | No — removed from all stores   |
| **Reversible**       | Yes — via dashboard              | No — irreversible              |
| **Use case**         | Standard deletion, debugging     | GDPR right-to-erasure requests |

***

## Examples

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from thrindex import Thrindex, NotFoundError

    client = Thrindex(api_key="th_live_...")

    # Soft delete
    try:
        client.delete("3f2e1d0c-1234-5678-abcd-ef0123456789")
        print("Memory soft-deleted.")
    except NotFoundError:
        print("Memory not found.")

    # Hard delete (GDPR erasure)
    try:
        client.delete("3f2e1d0c-1234-5678-abcd-ef0123456789", hard=True)
        print("Memory permanently erased.")
    except NotFoundError:
        print("Memory not found.")
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import { ThrindexClient, NotFoundError } from 'thrindex';

    const client = new ThrindexClient({ apiKey: 'th_live_...' });

    // Soft delete
    try {
      await client.delete('3f2e1d0c-1234-5678-abcd-ef0123456789');
      console.log('Memory soft-deleted.');
    } catch (err) {
      if (err instanceof NotFoundError) console.error('Memory not found.');
    }

    // Hard delete (GDPR erasure)
    try {
      await client.delete('3f2e1d0c-1234-5678-abcd-ef0123456789', { hard: true });
      console.log('Memory permanently erased.');
    } catch (err) {
      if (err instanceof NotFoundError) console.error('Memory not found.');
    }
    ```
  </Tab>
</Tabs>

***

## Errors

| Status | Code             | Description                                                                                  |
| ------ | ---------------- | -------------------------------------------------------------------------------------------- |
| `401`  | `unauthorized`   | Missing or invalid API key                                                                   |
| `401`  | `forbidden`      | API key lacks `memory:delete` scope                                                          |
| `404`  | `not_found`      | Memory does not exist, has already been hard-deleted, or belongs to a different organization |
| `429`  | `rate_limited`   | Rate limit exceeded                                                                          |
| `500`  | `internal_error` | Server error                                                                                 |
