# Bring back something deleted

URL: /agents/restore-something-deleted · Id: `guide:restore-something-deleted` · Status: `live`

> Restore a deleted record: nothing is purged, so every deleted Thing comes back with its history and its links.

Nothing is purged. A deleted [Thing](/business/nouns/thing) leaves every list and keeps its history, and [restore](/business/nouns/thing/restore) brings it back with its [Relationships](/business/nouns/relationship) intact.

**Before it runs**

- You leave the chat: Never.

## What you get
- 1 record back in every list and search it left, with its history and links intact (Thing)
- 1 entry in its history saying who restored it and when (Event)

## Your agent does
**For agents**

- Guide: `guide:restore-something-deleted`, status `live`. Page: [/agents/restore-something-deleted.md](/agents/restore-something-deleted.md).
- Approval: none. Run it when the founder asks.
- Leaves the chat: never.
- Run: call the steps in order, each through the API, SDK, CLI or MCP tab below; a later step passes the `$id` an earlier one returns. Each value marked example is the sample business’s: pass the founder’s own.

| Step | Verb | Inputs (type, required, this guide’s value) | Returns |
| --- | --- | --- | --- |
| 1 | [`Thing.restore`](/business/nouns/thing/restore) (`verb:Thing.restore`) | `thing` Thing (an id), required: the `$id` of the first Thing `Thing.list` returns for `where: deleted = true` | `thing` Thing |

Returns: the last call answers with `thing` and its `action`, whose `status` is `done`, `pending` (waiting on an Approval or a Worker), `failed`, `canceled` or `refused`:

```json
{
  "api": "https://api.sb/leaseline.app",
  "thing": {
    "$id": "https://api.sb/leaseline.app/things/thing_8ds0r9vvRl",
    "$type": "Thing"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Thing.restore",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

Next: offer “Restore everything deleted yesterday”, or “Undo what the agent just did instead”.

Calls: `Thing.restore`

Ask:

```text
Bring back the lease I deleted.
Restore the page the agent deleted.
I deleted that by mistake, get it back.
```

API:

```bash
# Look up the Thing: Thing.list
THING=$(curl "https://api.sb/leaseline.app/things?where=deleted%20%3D%20true&limit=1" \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" | jq -r '.things[0]["$id"] | split("/") | last')

# Thing.restore
curl -X POST https://api.sb/leaseline.app/things/$THING/restore \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

SDK:

```ts
import { $ } from 'startup-builder'

const [thing] = await $.Thing.list({ where: 'deleted = true', limit: 1 })
await $.Thing.restore({ thing: thing.$id })
```

CLI:

```bash
THING=$(npx startup-builder do Thing.list --json '{"where":"deleted = true","limit":1}' | jq -r '.things[0]["$id"] | split("/") | last')
npx startup-builder do Thing.restore --json '{"thing":"'"$THING"'"}'
```

MCP:

```json
{
  "name": "do",
  "arguments": {
    "code": "const [thing] = await $.Thing.list({ where: 'deleted = true', limit: 1 })\nreturn await $.Thing.restore({ thing: thing.$id })"
  }
}
```

## Change it
- Restore everything deleted yesterday.
- Undo what the agent just did instead.
- Show me the history of the restored lease.

## Under the hood
- Systems: [Work queue](/agents/work-queue)
- Nouns: [Thing](/business/nouns/thing), [Event](/business/nouns/event)
- Events: [`Thing.restored`](/business/events/Thing.restored)