# Erasing a customer's data

> When one of your customers asks to be forgotten, one call deletes their sessions, decisions, outcomes and events, in every flow, before it answers.

## Erase from your code

`eraseSubject()` takes the customer's subject id, exactly as your code sends it to Zigbongo, and erases them in every flow of the key's environment:

```js
const erased = await zb.eraseSubject(user.id);
// { subjectId: "u_81723", sessions: 2, decisions: 7, outcomes: 1 }
```

```php
$erased = $zb->eraseSubject($user->id);
// $erased->sessions, $erased->decisions, $erased->outcomes
```

Over HTTP it's `POST /v1/subjects:erase`:

```sh
curl -X POST "https://zigbongo.com/v1/subjects:erase" \
  -H "Authorization: Bearer $ZIGBONGO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subjectId": "u_81723"}'
```

The erasure is done before the call answers: what's stored goes first, then, two seconds later, whatever was still on its way. A key belongs to one environment, so a customer in both your live and test environments needs a call with each key, or the dashboard (below).

## The counts it returns

The counts are the stored records it erased:

- `sessions`: the customer's sessions erased.
- `decisions`: the decisions in those sessions.
- `outcomes`: their outcomes, both those reported by session and those reported by subject, in any flow.

A call about the customer still on its way when the erasure runs isn't counted, and is discarded when it arrives.

## Safe to repeat

Erasing is idempotent. Erasing again, or erasing an id Zigbongo never saw, answers with zeros, never an error, since you can't know whether there was anything. When the SDK had to retry, the counts are the last attempt's, so zeros can mean an earlier attempt did the erasing.

## It never falls back

Unlike a decision, an erasure has no default to show: it succeeds, or it throws a `ZigbongoError` (`ZigbongoException` in PHP). An empty id throws before anything is sent.

- **Its own timeout.** An erasure may wait for Zigbongo to finish learning from the customer's flows, and Zigbongo gives it up to 60 seconds. The SDK waits a little longer, up to 65 seconds an attempt (`erasureTimeoutMs`), so that a slow erasure ends with Zigbongo's own answer. A client that gives up first may leave the erasure part done; erasing again finishes it, as the SDK's next attempt does.
- **Retried like outcomes.** Timeouts, `429` and `5xx` are retried, up to 3 attempts (`outcomeAttempts`), waiting for `Retry-After` within `maxRetryWaitMs`. Erasure counts against the `other` allowance, 20 calls a second by default, so a batch of erasures will meet `429`s ([Retries and rate limits](https://zigbongo.com/docs/retries-and-rate-limits.md)).
- **Run it from a job,** not a page someone waits on: with retries, a call can take over three minutes when Zigbongo is struggling. Under PHP-FPM, `request_terminate_timeout` counts the wait.
- **The id stays out of logs.** It travels in the request body, never the URL, and no error names it, so neither your logs nor anything between you and Zigbongo records whom you erased.

## Erase from the dashboard

Owners and admins can erase a customer without an engineer: Organization settings, Privacy.

1. Enter the customer's id exactly as your systems send it. It isn't trimmed: `" ada"` and `"ada"` are different ids.
2. Choose the projects. All are ticked to start with; if two of your products use the same id for different people, untick the one where it's someone else.
3. Add a reference if you like, such as a ticket number. Never put the customer's id there.
4. Confirm. The confirm step shows the id between quotes, with its length, so stray spaces show.

It erases in each chosen project's live and test environments, and shows what went in each: "2 sessions, 3 decisions, 1 outcome", "Nothing held", or "Didn't finish", in which case erase again: what's already gone is skipped. The organization's audit log records the erasure with the projects, the counts and your reference, never the customer's id.

## What's erased

- The customer's sessions, with the inputs they carried, and their decisions, with the results reported (such as answers).
- Their outcomes, by session and by subject, in every flow.
- The fallback reports for their decisions.
- Every event about them in Zigbongo's event log.
- Their sessions whose window is still open, which are dropped from learning so they're never learned from.

## What isn't erased

These hold no record of the person:

- **What Zigbongo has learned.** The models, including what they learned from the customer's sessions whose windows had already closed. A model is a set of statistics about everyone, not a record of anyone, and old evidence fades over time.
- **Daily counts:** usage for billing, and the traffic per option the dashboard shows.
- **Lift numbers already tallied.** Sessions whose window closed over an hour before the erasure are part of the lift comparison's daily totals, which are kept.
- **Zigbongo's statistics about inputs,** which an erasure doesn't search. If you send identifying values as inputs, such as an e-mail address, one can end up there; so don't ([Context inputs](https://zigbongo.com/docs/inputs.md)).
- **Fallback reports for calls that never reached Zigbongo,** which nothing links to the customer.

Nothing records the erasure itself with the id: Zigbongo's log line names only the counts.

## After the erasure

- **New calls are new data.** If your code keeps sending decisions or outcomes for the same id, Zigbongo keeps them. Stop sending them first, then erase. A session the erasure removed answers `404`, so a decide that continues it falls back to your default.
- **Retention applies to everyone anyway.** Inputs and step results are forgotten after each flow's retention period, 90 days unless you set another, and sessions, decisions, outcomes and events are deleted 180 days after their last activity.
- **Backups.** Erasure works on Zigbongo's database. Its backups are kept for about five weeks, as the [DPA](https://zigbongo.com/dpa/) describes.

For other requests from your customers, such as for a copy of their data, the [DPA](https://zigbongo.com/dpa/) says how we help.

---

The Markdown of https://zigbongo.com/docs/erasing-customers/. Every docs page: https://zigbongo.com/llms.txt
