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

# POST /v1/agents/{id}/routes/{routeId}/versions/{version}/restore

> Make an older version the current content of a route.

Puts the content of that version back as the route's current content.

**It does not mutate the history.** A restore writes a *new* version copying the old one and records which one in `restored_from`, so the restore itself can be undone.

## Endpoint

```
POST https://api.keebai.com/v1/agents/{id}/routes/{routeId}/versions/{version}/restore
```

## Required scope

`agents:write`

## Path parameters

| Parameter | Type | Description |
| - | - | - |
| `id` | `string` | `ObjectId` of the agent. |
| `routeId` | `string` | `ObjectId` of the route. |
| `version` | `integer` | The version number, 1 or more. |

## Example request

```bash curl theme={"system"}
curl -X POST https://api.keebai.com/v1/agents/6650a1b2c3d4e5f6a7b8c9d0/routes/6652c0ffee11223344556688/versions/2/restore \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

## Response

### 201 Created

```json theme={"system"}
{
  "route": {
    "id": "6652c0ffee11223344556688",
    "scenario": "6652c0ffee11223344556677",
    "title": "Book an appointment",
    "applies_when": "The customer asks for an appointment for a service.",
    "not_applies_when": "They only ask for the price, without wanting to book.",
    "steps": [
      {
        "instruction": "Ask which service and which day.",
        "actions": [],
        "steps": []
      },
      {
        "instruction": "Offer the available times.",
        "actions": [
          {
            "kind": "native",
            "target": "search_availability"
          }
        ],
        "steps": [
          {
            "instruction": "If none fits, offer the next day with availability.",
            "actions": [],
            "steps": []
          }
        ]
      }
    ],
    "cases": [
      {
        "condition": "There is no availability this week",
        "action": "Offer the waiting list.",
        "actions": [
          {
            "kind": "native",
            "target": "join_waitlist"
          }
        ]
      }
    ],
    "order": 0,
    "status": "approved",
    "version": 3,
    "source": "manual",
    "created_by": "ana@example.com",
    "created_at": "2026-11-11T14:02:10.512000",
    "updated_at": "2026-11-11T14:02:10.512000"
  }
}
```

### 400 Bad Request

`version` is not an integer of 1 or more, or `routeId` is not an `ObjectId`.

### 404 Not Found

`AGENT_NOT_FOUND` when the agent belongs to another project of the company, `UPSTREAM_ERROR` (message `AGENT_NOT_FOUND`) when no agent has that id in the company; `route_not_found` when the route is not the agent's; `version_not_found` when the route has no such version.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `agents:write` scope.

### 502 Bad Gateway

The agent service is unreachable.

## Operational notes

* **The new version number is the next one**, not the restored one.
* **The agent picks it up on its next turn.**


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