> ## Documentation Index
> Fetch the complete documentation index at: https://velt-raghul-agent-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Restore Agent Version

Use this API to roll back an agent one version step. The current version `N` is deleted from the versions subcollection and the main document's `version` pointer is decremented to `N-1`.

This is a single-step undo. Call it repeatedly to walk backward through version history. The operation cannot go below version 1 — the agent must always have at least one version on file.

There is no target-version parameter. The operation always undoes the most recent change.

# Endpoint

`POST https://api.velt.dev/v2/agents/versions/restore`

# Headers

<ParamField header="x-velt-api-key" type="string" required>
  Your API key.
</ParamField>

<ParamField header="x-velt-auth-token" type="string" required>
  Your [Auth Token](/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="agentId" type="string" required>
      Min 1 char. Agent ID.
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

#### Restore an agent's previous version

```JSON theme={null}
{
  "data": {
    "agentId": "abc123def456"
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "Version restored successfully",
    "data": {
      "version": 2
    }
  }
}
```

| Field          | Type   | Description                                   |
| -------------- | ------ | --------------------------------------------- |
| `data.version` | number | The version the agent was restored to (`N-1`) |

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "FAILED_PRECONDITION"
  }
}
```

**Errors:** `NOT_FOUND` (agent does not exist) / `FAILED_PRECONDITION` (already at version 1; cannot go below).

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "Version restored successfully",
      "data": {
        "version": 2
      }
    }
  }
  ```
</ResponseExample>
