# Restore a version of a prompt

`POST https://app.whatsetter.com/api/v1/campaigns/{id}/prompts/{type}/versions/{versionId}/restore`

Puts an earlier version back in service, **live on the agent's next
message**. It is published as a new version with the same text, so the
history stays a straight line and this call can itself be undone.
The version goes back to its own variant. The text is stored again
exactly as it was.

Restoring a draft publishes it. Restoring another version while a
draft waits on the variant is refused with `409 draft_pending`, unless
the body carries `ignore_draft: true` (see `PUT …/prompts/{type}`).
Pass `if_version`, the live version you read of the variant this
version belongs to (it matters for an agent in an A/B test), so a
change made meanwhile is not replaced: the restore is then refused
with `409 version_conflict`, as a write is.
Requires scope `prompts:write`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes |  |
| `type` | path | conversation \| first_message | yes |  |
| `versionId` | path | string | yes |  |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `ignore_draft` | boolean | no | Restore although a draft waits on this variant. The draft stays in the history, unpublished. |
| `if_version` | integer | no | The live version number you read of the variant this version belongs to (`0` when that text has no version). Refused with `409 version_conflict` if it is no longer the live one. |

```json
{
  "if_version": 9
}
```

## Example request

```bash
curl --request POST \
  --url 'https://app.whatsetter.com/api/v1/campaigns/{id}/prompts/{type}/versions/{versionId}/restore' \
  --header 'Authorization: Bearer ws_live_…'
  --header 'Content-Type: application/json' \
  --data '{"if_version":9}'
```

## Responses

### 200: The prompt as it is now

```json
{
  "data": {
    "changed": true,
    "type": "conversation",
    "variant": "A",
    "version": 9,
    "version_id": "68e6220a0017a4c2e9f3",
    "previous_version": 8,
    "previous_version_id": "68e61f7700093d5b1c02",
    "unknown_tokens": [],
    "prompt": {
      "type": "conversation",
      "versioned": true,
      "ab_test": false,
      "live": [
        {
          "variant": "A",
          "name": null,
          "version": 9,
          "version_id": "68e6220a0017a4c2e9f3",
          "traffic_share": 1,
          "created_at": "2026-10-08T14:13:30.000+00:00",
          "body": "## Identity\nYou are {{agent_name}} from {{company_name}}.\n\n## Goal\nQualify the lead, then send {{goal_link}}.",
          "characters": 109
        }
      ],
      "unpublished_drafts": [],
      "max_characters": 40000
    }
  }
}
```

### 401: Missing, unknown or revoked API key

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 403: The key lacks the required scope (`insufficient_scope`), the plan does not have this part of the API (`not_in_plan`), or Instagram is not enabled on the workspace (`instagram_not_enabled`, Instagram routes)

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 404: Resource not found in this workspace

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 409: `version_conflict` (the live version is not `if_version`),
`draft_pending` (a draft waits on the variant: see
`ignore_draft`), `variant_not_live` (the version's variant is out
of the rotation while another one serves) or `invalid_state` (this
text keeps no history, or the version holds no text).


```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```


Source: https://docs.whatsetter.com/api-reference/operations/restorepromptversion/
