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

# Deletion & Deactivation

> Deactivate sub-accounts and understand the 14-day deletion grace period

## Deactivate a Sub-Account (API)

The `DELETE /v1/sub-accounts/:id` endpoint **deactivates** a sub-account immediately. All API keys are revoked and messaging stops.

<CodeGroup>
  ```typescript TypeScript theme={null}
  const result = await zavu.subAccounts.deactivate("jx7abc123def456");
  console.log(`Keys revoked: ${result.keysRevoked}`);
  ```

  ```python Python theme={null}
  result = zavu.sub_accounts.deactivate("jx7abc123def456")
  print(f"Keys revoked: {result.keys_revoked}")
  ```

  ```bash cURL theme={null}
  curl -X DELETE https://api.zavu.dev/v1/sub-accounts/jx7abc123def456 \
    -H "Authorization: Bearer zv_live_xxx"
  ```
</CodeGroup>

Response:

```json theme={null}
{
  "message": "Sub-account deactivated",
  "keysRevoked": 2
}
```

<Info>
  Deactivation via the API sets the sub-account status to `inactive` and revokes all API keys. This is **not** the same as permanent deletion.
</Info>

## Delete a Sub-Account (Dashboard)

Permanent deletion is available from the Zavu dashboard and follows a **14-day grace period** to prevent accidental data loss.

### How It Works

<Steps>
  <Step title="Schedule deletion">
    From the dashboard workspace switcher, select the sub-account and choose "Delete". This schedules deletion but does not remove any data yet.
  </Step>

  <Step title="API keys are revoked">
    All API keys for the sub-account are revoked immediately. The sub-account can no longer send or receive messages.
  </Step>

  <Step title="Email notifications">
    The team owner receives email notifications at multiple intervals:

    | When   | Email                           |
    | ------ | ------------------------------- |
    | Day 0  | Deletion scheduled notification |
    | Day 1  | Reminder: 13 days remaining     |
    | Day 7  | Reminder: 7 days remaining      |
    | Day 12 | Urgent: 2 days remaining        |
    | Day 14 | Sub-account permanently deleted |
  </Step>

  <Step title="Restore or wait">
    During the 14-day grace period, you can restore the sub-account from the dashboard. After 14 days, all data is permanently deleted.
  </Step>
</Steps>

### Restoring a Deleted Sub-Account

If you change your mind during the 14-day grace period:

1. Open the dashboard workspace switcher
2. Find the sub-account marked as "Pending Deletion"
3. Click "Restore"

The sub-account returns to `active` status. You'll need to create new API keys since the originals were revoked.

<Warning>
  After 14 days, deletion is **permanent and irreversible**. All messages, contacts, and configuration associated with the sub-account are removed.
</Warning>

## Deletion Rules

* You **cannot delete the last active sub-account** in a team. At least one project must remain active.
* The main account follows the same deletion rules as sub-accounts.
* Scheduled reminder emails are automatically cancelled if the sub-account is restored.

## Deactivation vs Deletion

| Action                 | API Keys | Data                  | Reversible                   | Method                        |
| ---------------------- | -------- | --------------------- | ---------------------------- | ----------------------------- |
| **Deactivate** (API)   | Revoked  | Preserved             | Yes — set status to `active` | `DELETE /v1/sub-accounts/:id` |
| **Delete** (Dashboard) | Revoked  | Removed after 14 days | Yes — within 14 days         | Dashboard UI                  |

## Next Steps

<CardGroup cols={2}>
  <Card title="Creating Sub-Accounts" icon="plus" href="/guides/sub-accounts/creating">
    Create new sub-accounts to replace deactivated ones
  </Card>

  <Card title="Managing Sub-Accounts" icon="sliders" href="/guides/sub-accounts/managing">
    Monitor spending and manage API keys
  </Card>
</CardGroup>
