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

# Delete a lead

> Remove a test lead from Erdo so the same phone number and email can arrive as a new lead.

# Delete a lead

Lead identity matches on the exact phone and email, so one phone number is one
lead for as long as that lead exists. That gets in the way when you test or demo
the follow-up engine on your own number: the second submission is matched to the
first lead, with its whole history. Deleting the first lead lets the number go.

> [!NOTE]
>
> Deleting a lead is a tool for demos and tests. It is switched off by default and
> is not offered to customers. It removes the lead from Erdo's own databases only,
> so it is not an answer to a "delete my data" request: see
> [What stays](#what-stays).

To make the engine read a real lead afresh without removing anything, start it
over instead. See [Lead next action](/lead-next-action.md).

## What a delete removes

| Where | What goes |
| - | - |
| The leads dataset | The lead's row, its permanent reference, the email and phone evidence bound to it, what it told us, and its capture history. A lead that other leads were merged into is deleted whole. |
| Text and WhatsApp | Every conversation with the lead and its messages, and the consent recorded for its number. |
| Calls and website chats | Every call and chat with the lead, and the bookings made during them. |
| Email | The emails sent to the lead and its replies, and the alerts about it. |
| Follow-up engine | Every decision about the lead, open or past. Anything waiting for approval is withdrawn first. |
| Lead forms | The submitted payload kept with each of the lead's form submissions. |
| Automations | The records of paid steps an automation ran for the lead. |

Afterwards the lead's reference no longer resolves, and the same phone and email
submitted again create a new lead with a new reference and nothing behind it.

## A phone or email two leads share

Two leads can hold the same phone number. A delete removes one lead, never
everything on a number, so a record Erdo keeps by number or address is removed
only when no other lead in your organization still holds that detail, in this
dataset or another:

* a text conversation that belongs to the other lead stays with it;
* consent for the number stays while another lead holds it;
* calls with no lead attached stay while another lead holds the number.

The response counts these as `shared_phones` and `shared_emails`. To free a
number that several test leads share, delete each of them.

Phone numbers are matched in full international form. A lead stored with a
national number and no country code releases nothing that is kept by number.

## What stays

* **Opt-outs.** A STOP reply, a do-not-call entry and the bounce and complaint
  record for an address are kept, so a deleted person is not contacted again. To
  text your own number after a STOP, reply START.
* **Copies outside Erdo's databases.** Message bodies at the SMS provider, call
  audio and transcripts at the voice provider, sent mail at the email provider,
  and anything already delivered to a mailbox, a CRM or a calendar.
* **Earlier versions of the leads dataset**, which still contain the row. See
  [Dataset revisions](/dataset-revisions.md).
* **Contact details taken from conversations.** When a call, text, WhatsApp or
  website chat gave Erdo the lead's contact details, the copy saved with that
  capture stays in your Conversation leads pipeline's run history. Nothing
  reads it to match or contact the lead, so the same phone and email still
  arrive as a new lead.
* **Analytics and logs**: page events, conversions already reported to an ad
  platform, and agent conversations that quoted the lead.
* **The daily contact cap.** Contacts made to the lead today still count toward
  today's cap.
* **A record of the delete**: the lead's reference, who deleted it, when, and how
  many records were removed. It holds no contact details.

## When a delete is refused

* A message to the lead is being sent, or the follow-up engine is deciding the
  lead, at that moment. Try again in a minute.
* An automation started a paid step for the lead in a run that is still going.
  Try again when the run has finished.
* The dataset has no lead identity. There is no lead to delete, only a row.

## Deleting

A delete cannot be undone. Only an organization admin can run it, and only on a
dataset the organization owns and the admin can edit.

```bash theme={null}
erdo leads get acme-leads <lead>
erdo leads delete acme-leads <lead>
```

The command asks you to type `delete` before it runs; `--yes` skips the prompt
and `--json` prints the raw result. `<lead>` is the lead's UUID or its
22-character reference.

| Route | What it does |
| - | - |
| `DELETE /v1/datasets/{slug}/leads/{lead}` | Delete the lead. `deleted_by_external_ref` (query) records your own handle for the person who asked. `check_only=true` removes nothing and answers `"state": "deletable"`, or the refusal the delete would give; use it before removing records of your own about the lead. |

The response says what was removed:

```json theme={null}
{
  "state": "deleted",
  "lead_id": "0b2f3c5e-6d1a-4a57-9a0e-5d3d0c7a9f10",
  "reference": "0NkfXq2b7cZt1yUe4wRmQA",
  "removed": {
    "lead_rows": 1,
    "lead_identities": 1,
    "sms_conversations": 1,
    "sms_messages": 14,
    "calls": 2,
    "emails_sent": 3,
    "engine_decisions": 6
  },
  "shared_phones": 0,
  "shared_emails": 0
}
```

If a delete stops part-way, run the same command again: it resumes. A lead that
was already deleted answers `"state": "already_deleted"` with what that delete
removed.

There is deliberately no MCP tool for this. A delete cannot be undone, so an
agent is never one tool call away from it. Scoped API keys cannot delete a lead.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.