# Version 3.0.1 Admin Clear Leads Fix

This patch fixes the v3.0 admin/testing cleanup issues.

## Fixes

### 1. Fixes 500 on SMS event ledger clear

`/admin/api/testing/clear-sms-event-ledger` used SQLite event-ledger helpers but the helpers were not imported in `routesAdmin.js`, which caused a 500.

### 2. Delete Lead now correctly archives and hides

v3.0 changed delete to archive, but the dashboard still showed archived leads because `listLeads()` did not exclude archived leads.

Now archived leads are hidden by default.

### 3. Adds Clear Test Leads button

The dashboard now has a `Clear Test Leads` button.

It clears:

- leads
- messages
- call events
- SMS event ledger
- TextBee poll cursor
- old deleted-lead suppressions

It keeps System Settings by default.

### 4. Adds browser-console endpoint

POST /admin/api/testing/purge-all-leads

Body optional:

{
  "keepSettings": true,
  "clearSmsLedger": true
}

## Browser console command

fetch('/admin/api/testing/purge-all-leads', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ keepSettings: true, clearSmsLedger: true })
})
  .then(r => r.json())
  .then(console.log)
  .catch(console.error);
