Prompts
Restore a version of a prompt
const url = 'https://app.whatsetter.com/api/v1/campaigns/example/prompts/conversation/versions/example/restore';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"if_version":9}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Body
Section titled “Request Body”object
Restore although a draft waits on this variant. The draft stays in the history, unpublished.
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.
Example
{ "if_version": 9}Responses
Section titled “Responses”The prompt as it is now
object
object
false when the text sent is already the live one: nothing was written.
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).
Versioned prompts only.
Versioned prompts only. The version now live.
Versioned prompts only.
Versioned prompts only. The version this write replaced. null only when the agent had no text.
Versioned prompts only. The id of that version: pass it to restore to undo this write.
Follow-ups and group texts only. The text this write replaced.
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.
The conversation or first_message prompt.
object
true while two variants or more share the traffic.
What the agent runs on now. One entry, or one per variant while an A/B test runs.
object
The name a person gave the variant in the dashboard, if any.
null when the text in service is in no version: the agent’s own copy, kept outside the history.
Share of new conversations this variant gets (1 when it is alone).
The text, with its {{tokens}}.
Only with rendered=true. The text with variables resolved and the agent’s style inlined.
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.
object
A follow-up or a group text. One text, no versions.
object
null when the agent has no text of its own and uses the built-in one.
Follow-ups only. Whether this follow-up is sent.
Follow-ups only. Hours of silence before it is sent.
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
object
object
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)
object
object
Examplegenerated
{ "error": { "code": "example", "message": "example" }}Resource not found in this workspace
object
object
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).
object
object
Examplegenerated
{ "error": { "code": "example", "message": "example" }}