# Your account and data

What agental keeps about your account and you, how long, how to take it away, and how to close the account.

## How long history is kept

A sandbox's history is the output of its commands, its agent conversations, its events and the runs of its schedules, though each schedule keeps its newest 10 runs however old, to say when it last ran and whether it keeps failing. Each account chooses how long it is kept: 1, 7, 30 or 90 days, or until the sandbox is deleted. Until you choose, it is 30 days. Set it in the console under Settings › Your data, or:

`PATCH /v1/data-retention`

```shell
curl -X PATCH https://agental.io/v1/data-retention \
  -H "Authorization: Bearer $AGENTAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"keepDays":7}'
```

- `keepDays` is 1, 7, 30 or 90, or `null` to keep history until the sandbox is deleted. A command still running and a conversation not yet answered are kept until they end. One a restart of the API cut off ends then: the command `failed` with no exit code and a line saying why, the conversation `interrupted`.
- A clean-up runs every 10 minutes. History older than the period goes by the next one, and cannot be brought back. Copies in the database's backups last 30 days more.
- A deleted sandbox's history goes with it, whatever is set: its commands and conversations by the next clean-up, its events a day later, so a collector that was down still hears of the deletion.
- `GET /v1/data-retention` answers with the period, what the last clean-up deleted, and what agental keeps for periods of its own: received email 7 days, metrics 15, webhook deliveries 30. Changing it needs a key with `account.admin`. In the CLI, `agental data-retention 7`.

## Take what is kept

`GET /v1/me/export`

```shell
curl -X GET https://agental.io/v1/me/export \
  -H "Authorization: Bearer $AGENTAL_API_KEY"
```

- One JSON document: the account, its sessions with the address and browser each began from, its keys by name and first characters with what each may do and where, billing, payments, top-up credit, usage, and its organizations, sandboxes, snapshots, templates, webhooks and collector.
- Secrets are named, never given: no key, signing secret, header value or secret variable is in it. What is inside sandboxes is read with the rest of the API.
- It works from the console, under Settings, or with a key that has `account.admin`. The CLI writes it with `agental account export --out agental-account.json`.

## Close the account

Only a person signed in can close an account, from Settings in the console. An API key is refused with `session_required`, so no agent can close the account it works for.

- The plan ends at once, and what is left of the month is not refunded. See [Refunds](https://agental.io/legal/refunds).
- Every API key, and every session but the one that closed it, stops working.
- Running sandboxes stop with their disks kept, and mail is switched off on every sandbox.
- Everything else is refused with `account_closed`, except reading the account, its billing and its usage, taking the export, reopening and erasing.
- An email says the day it will be erased: 30 days after it was closed.

`POST /v1/me/reopen`

Opens a closed account again, with its sandboxes as they were left. The plan, keys and mail have to be set up again.

## Erasing

On the 30th day a closed account is erased: its sandboxes, snapshots, mail, templates, webhooks, collector, settings and sign-in, and everything that names you. Usage, payments and credit are kept under the account's id alone, as accounting law asks. After that, the same address can sign up as a new account.

`DELETE /v1/me`

Erases a closed account now, rather than on its day. It needs `X-Agental-Confirm-Delete` set to the account's email address, and cannot be undone.

> **Tip:** How long each kind of data is kept is in the [Privacy Policy](https://agental.io/legal/privacy).

---

Every page of these docs as Markdown: [llms.txt](https://agental.io/llms.txt)
