# Erase a user

> Delete everything Tamr holds for one of your users: profile, sessions, conversations, ratings, orders and webhook deliveries.

Source: https://tamr.link/docs/api/erase-user

`DELETE https://tamr.link/api/v1/sdk/users/{externalUserId}`

When one of your users asks to be forgotten, this deletes what Tamr holds for them: their profile, sessions, conversations, ratings, the orders you sent, unspent launch codes and the webhook deliveries that named them. An open chat finds its session gone on its next request. It's safe to call again: `erased` is `false` when there was nothing. It works even with the SDK switched off, so a restaurant can always honour an erasure. URL-encode the id if it has special characters.

## Authentication

**Server API.** Send a secret API key with the **Diner sessions (SDK)** permission (`diner:sdk`) as `Authorization: Bearer <key>`. Secret keys are made in **Settings > API keys** by an owner or admin. Keep them on your server: no browser can call this route.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `externalUserId` | string | Yes | 1 to 200 characters. |

## Response

| Field | Type | Description |
| --- | --- | --- |
| `erased` | boolean |  |

## Example

curl:

```bash
curl -X DELETE https://tamr.link/api/v1/sdk/users/user-88213 \
  -H "Authorization: Bearer $TAMR_SECRET_KEY"
```

Node:

```js
import { createServerClient } from "@tamr/api/server";

const tamr = createServerClient({ secretKey: process.env.TAMR_SECRET_KEY });

const result = await tamr.sdkEraseUser("user-88213");
console.log(result);
```

Python:

```python
import os

import requests

API = "https://tamr.link/api/v1"
headers = {"Authorization": f"Bearer {os.environ['TAMR_SECRET_KEY']}"}
external_user_id = "user-88213"

response = requests.delete(
    f"{API}/sdk/users/{external_user_id}",
    headers=headers,
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

## Example response

```json
{
  "erased": true
}
```

## Errors

Every error has the same body; switch on `data.code`. See [Errors and rate limits](https://tamr.link/docs/errors).

| `data.code` | Status | What to do |
| --- | --- | --- |
| `other` | 401 | No secret key, or one Tamr doesn't accept: wrong, revoked, or made by someone who is no longer an owner or admin. |
| `other` | 403 | The key doesn't have the `diner:sdk` permission. |
| `invalid_request` | 400 | A field doesn't match the spec. The message says which. |
| `rate_limited` | 429 | Wait `retryAfter` seconds (also in the `Retry-After` header), then try again. |
