curl --request POST \
--url https://api.goyappr.com/agents/{id}/workflow/restore \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2,
"expected_version": 4503599627370496,
"discard_draft": false
}
'import requests
url = "https://api.goyappr.com/agents/{id}/workflow/restore"
payload = {
"version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2,
"expected_version": 4503599627370496,
"discard_draft": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
version_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
version: 2,
expected_version: 4503599627370496,
discard_draft: false
})
};
fetch('https://api.goyappr.com/agents/{id}/workflow/restore', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goyappr.com/agents/{id}/workflow/restore",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'version' => 2,
'expected_version' => 4503599627370496,
'discard_draft' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goyappr.com/agents/{id}/workflow/restore"
payload := strings.NewReader("{\n \"version_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"version\": 2,\n \"expected_version\": 4503599627370496,\n \"discard_draft\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goyappr.com/agents/{id}/workflow/restore")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"version_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"version\": 2,\n \"expected_version\": 4503599627370496,\n \"discard_draft\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goyappr.com/agents/{id}/workflow/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"version\": 2,\n \"expected_version\": 4503599627370496,\n \"discard_draft\": false\n}"
response = http.request(request)
puts response.read_body{
"revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2,
"content_hash": "<string>",
"published_at": "2023-11-07T05:31:56Z",
"environment": "local"
},
"execution_version": "workflow_v1",
"restored_from": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2
},
"draft_version": 2,
"discarded_draft": true,
"settings_updated_at": "2023-11-07T05:31:56Z"
}Restore workflow version
Make an earlier version’s workflow live again, as a new version.
curl --request POST \
--url https://api.goyappr.com/agents/{id}/workflow/restore \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2,
"expected_version": 4503599627370496,
"discard_draft": false
}
'import requests
url = "https://api.goyappr.com/agents/{id}/workflow/restore"
payload = {
"version_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2,
"expected_version": 4503599627370496,
"discard_draft": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
version_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
version: 2,
expected_version: 4503599627370496,
discard_draft: false
})
};
fetch('https://api.goyappr.com/agents/{id}/workflow/restore', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.goyappr.com/agents/{id}/workflow/restore",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'version' => 2,
'expected_version' => 4503599627370496,
'discard_draft' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.goyappr.com/agents/{id}/workflow/restore"
payload := strings.NewReader("{\n \"version_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"version\": 2,\n \"expected_version\": 4503599627370496,\n \"discard_draft\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.goyappr.com/agents/{id}/workflow/restore")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"version_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"version\": 2,\n \"expected_version\": 4503599627370496,\n \"discard_draft\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.goyappr.com/agents/{id}/workflow/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"version\": 2,\n \"expected_version\": 4503599627370496,\n \"discard_draft\": false\n}"
response = http.request(request)
puts response.read_body{
"revision": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2,
"content_hash": "<string>",
"published_at": "2023-11-07T05:31:56Z",
"environment": "local"
},
"execution_version": "workflow_v1",
"restored_from": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 2
},
"draft_version": 2,
"discarded_draft": true,
"settings_updated_at": "2023-11-07T05:31:56Z"
}agents:update. Restoring publishes a copy of an earlier version’s
workflow as a new version. It rolls forward: version numbers only go up, the
version you restored from stays in the history, and callers reach the new version
on their next call. A call already in progress keeps the version it started on.
id of the version to restore, from List workflow versions. Send exactly one of version_id and version.409 WORKFLOW_CONFLICT and nothing is published. Optional.true replaces a saved draft that holds unpublished changes with the restored workflow. false refuses instead of losing them.curl -X POST 'https://api.goyappr.com/agents/AGENT_ID/workflow/restore' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'x-company-id: COMPANY_ID' \
-H 'Content-Type: application/json' \
-d '{"version_id":"VERSION_ID","expected_version":7,"discard_draft":false}'
201 returns the new revision (id, version, content_hash,
published_at, environment), execution_version, restored_from (id and
version of the copy’s source), draft_version, discarded_draft, and
settings_updated_at, the same token Publish workflow
returns. Send it as expected_updated_at on your next agent PATCH.
What a restore does and does not promise
- It is a new version. The restored workflow is published again, so the
list shows a new row with
source: "restore"andrestored_from_version. - It is not guaranteed to be byte-identical. The old document is checked and built again with today’s rules. For most versions the result matches; an agent whose version was rebuilt on 2026-11-12 can differ from it in compiled details (the document text you read with Get workflow version is what is restored).
- It can be refused. If the old document no longer passes today’s checks
(a tool in it was archived, an app account was disconnected) the answer is
422 WORKFLOW_REFERENCE_INVALIDorWORKFLOW_VALIDATION_FAILEDwithissues[], nothing is published, and your draft is put back as it was. - It is not idempotent. Every successful call makes one more version. If you never received the answer, read the version list before sending it again.
Refusals
| Status | Code | Meaning |
|---|---|---|
| 400 | WORKFLOW_REQUEST_INVALID | Both or neither of version_id and version, a malformed value, another field, or a query parameter. issues[] names each by path. |
| 404 | WORKFLOW_NOT_FOUND | No version of this agent has that id or number. |
| 409 | WORKFLOW_CONFLICT | expected_version is not the saved draft’s version now. current_version names it. |
| 409 | WORKFLOW_DRAFT_HAS_UNPUBLISHED_CHANGES | The saved draft differs from the published version. The body also carries reason: "draft_has_unpublished_changes". Publish or discard the draft, or send discard_draft: true. |
| 409 | WORKFLOW_VERSION_IS_CURRENT | That version is the one callers reach now; there is nothing to restore. |
| 422 | WORKFLOW_REFERENCE_INVALID, WORKFLOW_VALIDATION_FAILED | The old document no longer passes today’s checks. |
| 503 | WORKFLOW_COMPILER_UNAVAILABLE | Nothing was published. Read the version list before retrying. |
{
"error": "The saved draft has changes that are not published. Publish or discard them first, or restore with discard_draft set to true.",
"code": "WORKFLOW_DRAFT_HAS_UNPUBLISHED_CHANGES",
"reason": "draft_has_unpublished_changes"
}
base_revision.Authorizations
Your Yappr API key (e.g. ypr_live_...). Generate one in the dashboard under Settings → API Keys. No key is 401 MISSING_KEY; a key that is not one of ours, or is revoked, is 401 INVALID_KEY; an expired one is 401 EXPIRED_KEY. A valid key without the scope an operation needs is 403 INSUFFICIENT_SCOPE on every operation, and the message names the scope. Every response, a 401 included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset: the budget is 60 requests a minute per API key. Every 429, whatever its code, carries Retry-After (whole seconds, never zero): the per-key budget's RATE_LIMIT asks for what is left of the minute, a route's daily cap (RATE_LIMITED) for the time until that cap resets. All four headers are listed in Access-Control-Expose-Headers, so a browser can read them. A path the API does not serve (an unknown sub-path, an id left empty) is 404 ROUTE_NOT_FOUND, and a method a served path does not take is 405 METHOD_NOT_ALLOWED with an Allow header; both are answered before any scope check, and nothing is read or changed. A trailing slash is ignored where it cannot be an id left empty (POST /calls/ is POST /calls) and refused where it can (GET /calls/). A doubled slash inside a path is merged into one before the request reaches the API (GET //calls is GET /calls).
Headers
Body
Name the version with exactly one of version_id and version.
Response
The restored workflow is live as a new version.