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

# destroy()

> `protected` **destroy**(): `Promise`\<`void`>

Erase everything this agent has accumulated, in one call.

For when the thing the agent represents is over — a phone number is
released, an account closes, a case is settled — and what comes next must
inherit nothing. Rather than hand-deleting each piece and hoping none was
missed, `destroy()` empties them together:

* **State** — [`getState`](/docs/agent-sdk/interface/getState) reads back
  [`initialState()`](/docs/agent-sdk/interface/initialState) again.
* **Timers** — every pending `queue` / `schedule` / `every` task is
  removed, [`listSchedules`](/docs/agent-sdk/interface/listSchedules) is empty, and the
  agent's wake-up is cancelled. A 24-hour follow-up booked before the
  number changed hands never fires.
* **Conversation history** — [`this.messages`](/docs/agent-sdk/interface/messages) is
  emptied, seq counter included, so the next message is `seq` 1.
* **Progress events** — [`this.events`](/docs/agent-sdk/interface/events) likewise.
* **Connections** — every client the agent is holding is closed, and
  [`attachments`](/docs/agent-sdk/interface/attachments) drops to zero.

The erasure is persistent, not just in-memory: an agent that is destroyed and
later activated again — a stray inbound message routed to the same name —
comes up as a fresh agent, with nothing left to fire, replay, or read.

`destroy()` empties an agent; it does not remove it. The instance keeps
existing and stays usable: the very next call writes into a clean agent,
exactly as the first call to a brand-new one does. Removing the instance
itself is a separate, platform-level operation.

Two things are deliberately left alone, because the agent does not own
them:

* **Objects in a bucket.** Content offloaded through a
  `BlobStore` lives in object storage under keys of
  your choosing, and may be large, shared between agents, or subject to
  your own retention rules. Delete what you no longer want through the
  bucket, before calling this.
* **Keys you wrote yourself.** Anything the subclass put in
  `ctx.storage` directly is yours to manage; only the agent's own stores
  are emptied.

Safe to call on an agent that has never been used, and safe to call twice:
emptying what is already empty succeeds and changes nothing.

Nothing calls this for you — expose it however your application decides an
agent is finished (an [`@rpc()`](/docs/agent-sdk/interface/rpc)-decorated method, a `fetch`
route, a task that fires when a retention window closes):

```ts theme={null}
async release(): Promise<void> {
  await this.destroy(); // state, timers, history, events, clients
}
```

Added with SDK 0.15 — a new inherited member, so a subclass that already
declares `destroy` must rename it (or align it to override this method).

**Returns**

`Promise`\<`void`>
