Skip to content
Dashboard

Restore a version of a prompt

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

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.

id
required
string
type
required
string
Allowed values: conversation first_message
versionId
required
string
Media typeapplication/json
object
ignore_draft

Restore although a draft waits on this variant. The draft stays in the history, unpublished.

boolean
if_version

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.

integer
Example
{
"if_version": 9
}

The prompt as it is now

Media typeapplication/json
object
data
object
changed

false when the text sent is already the live one: nothing was written.

boolean
type

A text the agent runs on. A private-message agent has conversation (how it replies), first_message and the four follow-ups: cold goes to a lead who never replied, abandoned to a lead who stopped replying, _1 then _2. A group agent has group_reply (in the group) and group_dm (in private).

string
Allowed values: conversation first_message follow_up_cold_1 follow_up_cold_2 follow_up_abandoned_1 follow_up_abandoned_2 group_reply group_dm
variant

Versioned prompts only.

string
Allowed values: A B C D
version

Versioned prompts only. The version now live.

integer | null
version_id

Versioned prompts only.

string | null
previous_version

Versioned prompts only. The version this write replaced. null only when the agent had no text.

integer | null
previous_version_id

Versioned prompts only. The id of that version: pass it to restore to undo this write.

string | null
previous_body

Follow-ups and group texts only. The text this write replaced.

string | null
unknown_tokens

Tokens of the text that match no variable of the agent (promo_code for {{promo_code}}). The agent would read them as they stand. Empty when every token resolves.

Array<string>
prompt
One of:

The conversation or first_message prompt.

object
type
string
Allowed values: conversation first_message
versioned
boolean
ab_test

true while two variants or more share the traffic.

boolean
live

What the agent runs on now. One entry, or one per variant while an A/B test runs.

Array<object>
object
variant
string
Allowed values: A B C D
name

The name a person gave the variant in the dashboard, if any.

string | null
version

null when the text in service is in no version: the agent’s own copy, kept outside the history.

integer | null
version_id
string | null
traffic_share

Share of new conversations this variant gets (1 when it is alone).

number
created_at
string | null format: date-time
body

The text, with its {{tokens}}.

string
rendered_body

Only with rendered=true. The text with variables resolved and the agent’s style inlined.

string
characters
integer
unpublished_drafts

Saved in the editor and never published. Each one is the newest text of its variant and differs from what the agent reads. A write on that variant is refused until the draft is published or ignore_draft is sent.

Array<object>
object
variant
string
Allowed values: A B C D
version
integer
version_id
string
created_at
string | null format: date-time
max_characters
integer
Example
{
"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
}
}
}

Missing, unknown or revoked API key

Media typeapplication/json
object
error
object
code
string
message
string
Examplegenerated
{
"error": {
"code": "example",
"message": "example"
}
}

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)

Media typeapplication/json
object
error
object
code
string
message
string
Examplegenerated
{
"error": {
"code": "example",
"message": "example"
}
}

Resource not found in this workspace

Media typeapplication/json
object
error
object
code
string
message
string
Examplegenerated
{
"error": {
"code": "example",
"message": "example"
}
}

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).

Media typeapplication/json
object
error
object
code
string
message
string
Examplegenerated
{
"error": {
"code": "example",
"message": "example"
}
}