# Data retention and erasure (https://docs.opensequence.dev/docs/security/data-retention)

What OpenSequence stores about contacts and messages, what it prunes on its own, how to erase a person on request, and what leaves in webhooks.

This page lists the personal data OpenSequence keeps and how long it keeps it. Read it before you answer a privacy request or set your own retention policy.

<CodeGroup>

```bash title="curl"
# Erase a person (admin key)
curl -X DELETE $SEQ/v1/contacts/p_7 -H "Authorization: Bearer $ADMIN_KEY"

# Do not store reply bodies (merged into the project settings)
curl -X PUT $SEQ/v1/project/settings -H "Authorization: Bearer $ADMIN_KEY" \
  -H "Content-Type: application/json" -d '{"store_inbound_bodies":false}'
```

```ts title="TypeScript"
await oseq.contacts.delete('p_7');
await oseq.project.updateSettings({ store_inbound_bodies: false });
```

</CodeGroup>

## What is stored [#what-is-stored]

| Data | Stored | Why |
|---|---|---|
| Contacts, senders | what you send, `attrs` included | to address and personalize messages |
| Outbound messages | subject and body as rendered, addresses, provider ids, thread reference | to match replies and show the timeline |
| Inbound replies | addresses, subject, thread reference, provider id. The body only when `store_inbound_bodies` is on (default off): plain text, the quoted history cut off, at most 20,000 characters. With the setting off the service does not even download the body, except to read the return date of an out-of-office reply. Turning it on applies to replies that arrive afterwards; earlier replies stay without a body | to stop the sequence and attribute the reply, and to show what the contact wrote |
| Runs | node, status, branch, the facts a condition read, the values a template rendered, provider references | the journey of each enrollment |
| Signals | kind, channel, source, external id, attribution, a small payload | replies, bounces, opt-outs, calls, meetings |
| Tasks | title, body and link as rendered, outcome, note (an Allo call summary when completed automatically) | the reps' task inbox |
| Webhook deliveries | the full event payload, attempts, errors | delivery and replay |
| Secrets | encrypted, write-only | provider access |

The service reads only threads it started, from the last 30 days, and never stores anything else it sees in a mailbox.

## What is pruned automatically [#what-is-pruned-automatically]

The `retention` job runs when a worker starts and then once a day. It deletes:

| Rows | After |
|---|---|
| idempotency keys | 1 day |
| dead-letter queue messages | 30 days |
| delivered webhook deliveries | 30 days |

<Warning>`retention_days` (7 to 3650, default 365) is accepted in the project settings but not enforced yet. Runs, messages, signals and tasks are kept until the contact is erased. Plan your own pruning until the engine honours the setting.</Warning>

## Erase on request [#erase-on-request]

`DELETE /v1/contacts/{id}` (scope `admin`, accepts the id or your external id) erases a person in one transaction:

1. Every active enrollment of the contact exits with reason `deleted`, and an `enrollment.exited` webhook is queued so your systems follow.
2. The contact is deleted, and with it its enrollments, runs, messages, signals and their effects, tasks and suppressions.

Analytics (enrolled, replies, meetings per sequence) are computed from what remains, so an erased contact leaves the totals.

<Warning>Erasing a contact also erases its suppressions. If the same person is created again later, nothing remembers that they opted out. Keep your own do-not-contact list, and when you re-create a person who opted out, suppress them again: `POST /v1/contacts/{id}/events` with `{ "id": "dnc-1", "type": "suppressed", "channel": "all" }`.</Warning>

## What leaves the service [#what-leaves-the-service]

Webhook payloads carry personal data in two places: `signal.received` includes the contact's id, external id, email, phone and name, and `task.created` includes the task's rendered title, body and link. The [webhook events reference](/reference/webhook-events) shows every payload. Copies of those payloads stay in `webhook_deliveries` until they are pruned 30 days after delivery, even when the contact has been erased. Your endpoints keep what they received: delete it there under your own policy.
