Publish an AI phone agent
curl --request POST \
--url http://localhost:8080/phone/{phone_agent_id}/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_revision": 0
}
'import requests
url = "http://localhost:8080/phone/{phone_agent_id}/publish"
payload = { "expected_revision": 0 }
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({expected_revision: 0})
};
fetch('http://localhost:8080/phone/{phone_agent_id}/publish', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/phone/{phone_agent_id}/publish",
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([
'expected_revision' => 0
]),
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 := "http://localhost:8080/phone/{phone_agent_id}/publish"
payload := strings.NewReader("{\n \"expected_revision\": 0\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("http://localhost:8080/phone/{phone_agent_id}/publish")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_revision\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/phone/{phone_agent_id}/publish")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_revision\": 0\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "<string>",
"version": 0,
"revision": 0
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}AI Phone Agents
Publish an AI phone agent
Make an agent’s draft live. Calls that start afterwards use it, and it is recorded as a new version.
POST
/
phone
/
{phone_agent_id}
/
publish
Publish an AI phone agent
curl --request POST \
--url http://localhost:8080/phone/{phone_agent_id}/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_revision": 0
}
'import requests
url = "http://localhost:8080/phone/{phone_agent_id}/publish"
payload = { "expected_revision": 0 }
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({expected_revision: 0})
};
fetch('http://localhost:8080/phone/{phone_agent_id}/publish', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/phone/{phone_agent_id}/publish",
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([
'expected_revision' => 0
]),
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 := "http://localhost:8080/phone/{phone_agent_id}/publish"
payload := strings.NewReader("{\n \"expected_revision\": 0\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("http://localhost:8080/phone/{phone_agent_id}/publish")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_revision\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/phone/{phone_agent_id}/publish")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_revision\": 0\n}"
response = http.request(request)
puts response.read_body{
"agent_id": "<string>",
"version": 0,
"revision": 0
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Requires the
Calls already in progress finish with the settings they started with.
A new agent created with
phone:write scope.
Send the revision you read from Get draft as expected_revision. Publishing is all or nothing: either every setting in the draft goes live, or none does.
Refusals carry a code beside the message, so your code can branch on the reason:
| Status | code | Meaning |
|---|---|---|
201 | The draft is live. The response returns the new version and the draft’s new revision. | |
409 | draft_stale | The draft changed after the revision you sent. Read it again, review it and retry. |
409 | number_held | A phone number in the draft was given to another agent, IVR or interpreter in the meantime. The message names it; free the number or remove it from the draft. |
400 | draft_invalid | A setting is invalid (for example an inactive workflow, or an instruction or knowledge item the agent can no longer use). Things deleted since they were added to the draft are dropped from it, not refused. |
400 | nothing_to_publish | The draft has no changes to publish. |
POST /phone takes no calls until its first publish.
To put an earlier version live again, use Publish earlier version. The draft is reset to that version too, so its unpublished changes are discarded.Authorizations
Body
application/json
Was this page helpful?