package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore"
payload := strings.NewReader("{\n \"note\": \"Back to the menu before the holiday change\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore")
.header("If-Match", "<if-match>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"note\": \"Back to the menu before the holiday change\"\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://api.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"note\": \"Back to the menu before the holiday change\"\n}"
response = http.request(request)
puts response.read_body
{
"error": {
"code": "CALL_FLOWS.HEADER_VALUE_REQUIRED",
"message": "This version no longer keeps some HTTP Request header values, and the live flow has none to reuse (see details). Read the version, set those values and save the flow with PUT.",
"target": "/steps/2/headers/0/value",
"details": [
{
"code": "CALL_FLOWS.HEADER_VALUE_REQUIRED",
"message": "Step 7103: this version no longer keeps the value of its header \"Authorization\", and the live step has no header of that name with a value. Read the version, set the value and save the flow.",
"target": "/steps/2/headers/0/value"
}
]
},
"requestId": "8c1f4a2e60"
}
{
"error": {
"code": "CALL_FLOWS.IF_MATCH_REQUIRED",
"message": "Send If-Match with the ETag of your last read of the flow.",
"target": "If-Match"
},
"requestId": "c41f0a9e2b"
}
Makes the version the live flow, through the same checks as Replace a number’s call flow. It answers the next call, so a mistake reaches callers at once. The new version has source: restore, and restoredFromVersionId names the version you restored. Send If-Match with the ETag of the live flow.
Steps whose id the live flow still has, with the same type, keep their id. Every other step of the version comes back as a new step with a new id, and the references to it follow it.
HTTP Request header values come back from the version. A version older than 7 days that is not among the number’s 5 newest versions (drafts not counted) may keep only valueSet: true for a header, without its value: the next save of the flow after that removes the values. Drafts always keep theirs. For such a header, the restore takes the value of the live step with the same id, from its header with the same name. When the live flow has none, because that step or header is gone or its value is empty, the restore is 422 CALL_FLOWS.HEADER_VALUE_REQUIRED and changes nothing.
Jump to steps in other numbers that were deleted when the version was replaced do not come back; the answer warns about each one with JUMP_TO_NOT_RESTORED.
POST
/
numbers
/
{numberId}
/
call-flow
/
versions
/
{versionId}
/
restore
Restore a call flow version
curl --request POST \ --url https://api.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore \ --header 'Authorization: Basic <encoded-value>' \ --header 'Content-Type: application/json' \ --header 'If-Match: <if-match>' \ --data '{ "note": "Back to the menu before the holiday change"}'
import requests
url = "https://api.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore"
payload = { "note": "Back to the menu before the holiday change" }
headers = {
"If-Match": "<if-match>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
const options = {
method: 'POST',
headers: {
'If-Match': '<if-match>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({note: 'Back to the menu before the holiday change'})
};
fetch('https://api.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore"
payload := strings.NewReader("{\n \"note\": \"Back to the menu before the holiday change\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("If-Match", "<if-match>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore")
.header("If-Match", "<if-match>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"note\": \"Back to the menu before the holiday change\"\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://api.cloudtalk.io/v1/numbers/{numberId}/call-flow/versions/{versionId}/restore")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["If-Match"] = '<if-match>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"note\": \"Back to the menu before the holiday change\"\n}"
response = http.request(request)
puts response.read_body
{
"error": {
"code": "CALL_FLOWS.HEADER_VALUE_REQUIRED",
"message": "This version no longer keeps some HTTP Request header values, and the live flow has none to reuse (see details). Read the version, set those values and save the flow with PUT.",
"target": "/steps/2/headers/0/value",
"details": [
{
"code": "CALL_FLOWS.HEADER_VALUE_REQUIRED",
"message": "Step 7103: this version no longer keeps the value of its header \"Authorization\", and the live step has no header of that name with a value. Read the version, set the value and save the flow.",
"target": "/steps/2/headers/0/value"
}
]
},
"requestId": "8c1f4a2e60"
}
{
"error": {
"code": "CALL_FLOWS.IF_MATCH_REQUIRED",
"message": "Send If-Match with the ETag of your last read of the flow.",
"target": "If-Match"
},
"requestId": "c41f0a9e2b"
}
HTTP Basic Authentication. Use your API Access Key ID as the username and your API Access Key Secret as the password. Generate keys in the CloudTalk Dashboard under Account -> Settings -> API Keys (https://dashboard.cloudtalk.io/menu/account/settings/API-keys).
Headers
If-Match
string
required
The ETag of the live flow, from your last read. A missing value, or *, is 428 CALL_FLOWS.IF_MATCH_REQUIRED; a value that no longer matches is 412 CALL_FLOWS.ETAG_MISMATCH.
A version id from List call flow versions, or live (the version the number runs now), latest (the newest version of any source) or latest-draft (the newest draft).
Example:
"1834"
Body
application/json
note
string
Optional, up to 255 characters, stored on the new version.
Maximum string length: 255
Response
The live flow, with its new ETag, versionId and any warnings.
The live flow after a save, a restore or a publish. New steps carry their stored id, and the ref you sent, once.
numberId
string
required
read-only
The number. Read-only.
Example:
"600"
etag
string
required
read-only
The same value as the ETag header. Read-only.
Example:
"\"cf1-9fJ2kQx7Lr0aT3\""
editable
boolean
required
read-only
false when the stored flow cannot be sent back unchanged; problems says why. With only DANGLING_REFERENCE problems, correct those fields and the save takes the document. true is not a guarantee: a flow saved in the Dashboard over a size limit, or with a ring step that has no ring time, reads editable: true, but sending it back unchanged is refused with 422, as the call flow document says. Read-only.
problems
object[]
required
read-only
Stored data the API cannot represent. Read-only.
Show child attributes
businessHours
object
required
Whether business hours run before this flow. When closed, they decide what the caller hears, instead of the flow. Read-only.
Show child attributes
steps
(Ring user · object | Ring favorite user · object | Ring group · object | Voice agent · object | Playback · object | Voicemail · object | Redirect · object | Call recording · object | Fax · object | Change of caller · object | Dial by extension · object | IVR menu · object | Day/time splitter · object | Jump to · object | Condition splitter · object | HTTP request · object | Collect input · object | Mark call as resolved · object | Unsupported step · object)[]
required
The main sequence, from "Call comes in". The first step runs first, then the next one in the array. A step that branches, or that ends the call, is the last in its array. 1 to 200 steps in the whole flow on a save; a number with no steps reads [].
One step of a call flow. type picks its fields. A step that branches, or that ends the call, is the last in its array. A branch is an array of steps with the same rules.
Ring user
Ring favorite user
Ring group
Voice agent
Playback
Voicemail
Redirect
Call recording
Fax
Change of caller
Dial by extension
IVR menu
Day/time splitter
Jump to
Condition splitter
HTTP request
Collect input
Mark call as resolved
Unsupported step
Show child attributes
updatedAt
string<date-time>
required
read-only
Time of the latest saved version, or of the latest step change when no version exists. Read-only.
versionId
string | null
required
read-only
The latest version other than a draft, or null before the flow's first save. Read-only.
dashboardUrl
string
required
read-only
Opens this flow in the Dashboard designer, for an Admin. Read-only.
warnings
object[]
required
Warnings about the saved flow. They never stop a save.