Environments and Releases
Roll Back Agent
Repoint production at a previously deployed version.
POST
/
v2
/
agents
/
{agent_id}
/
rollback
Roll Back Agent
curl --request POST \
--url https://api.bland.ai/v2/agents/{agent_id}/rollback \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"version_id": "<string>"
}
'import requests
url = "https://api.bland.ai/v2/agents/{agent_id}/rollback"
payload = { "version_id": "<string>" }
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({version_id: '<string>'})
};
fetch('https://api.bland.ai/v2/agents/{agent_id}/rollback', 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.bland.ai/v2/agents/{agent_id}/rollback",
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' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$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.bland.ai/v2/agents/{agent_id}/rollback"
payload := strings.NewReader("{\n \"version_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
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.bland.ai/v2/agents/{agent_id}/rollback")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"version_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v2/agents/{agent_id}/rollback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"semver": "1.3.1",
"environments": [
{
"id": "3b4442ac-eaff-4a8d-bd9b-103affc43fc4",
"env_type": "dev",
"current_version_id": null
},
{
"id": "6e92b74f-071f-4a09-85a5-5a3e6625ddf5",
"env_type": "staging",
"current_version_id": "4671db05-2d34-4171-9626-79a468e73f61"
},
{
"id": "2c0ff980-fedf-4ebc-9117-dd21702d6e27",
"env_type": "production",
"current_version_id": "e6926b11-5513-4187-9dcf-5800b899f8da"
}
]
},
"errors": null
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "Cannot roll back to a version that was never deployed to production"
}
]
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "Production is already pinned to this version"
}
]
}
{
"data": null,
"errors": [
{
"error": "NOT_FOUND",
"message": "Version not found on this agent"
}
]
}
Overview
Moves the agent’sproduction pointer back to a version that has been deployed to production before, recording a new deployment with that version’s original semver. Phone numbers attached to the agent begin answering with the restored version, and any active experiment whose baseline is production ends with completed_reason set to baseline_changed. A rollback is never blocked by evaluations, a live rollout, or missing production variable values, so check that every variable the restored version references has a production value. Find candidates with List Agent Deployments, where is_rollback_eligible is true. staging is not changed.
Requires an admin, owner, operator, or prompter role.
Headers
Path Parameters
Body Parameters
ID of the version to restore. It must belong to this agent, have at least one production deployment on record, and not be the current production pin. Missing or empty returns
400 BAD_REQUEST. A version never deployed to production, or one that is already live, also returns 400 BAD_REQUEST with a message explaining which. An ID that is not one of this agent’s versions returns 404 NOT_FOUND.Response
The agent’s three environments after the rollback. Each has
id, env_type (dev, staging, or production), and current_version_id (the pinned version, or null if unpinned).{
"data": {
"semver": "1.3.1",
"environments": [
{
"id": "3b4442ac-eaff-4a8d-bd9b-103affc43fc4",
"env_type": "dev",
"current_version_id": null
},
{
"id": "6e92b74f-071f-4a09-85a5-5a3e6625ddf5",
"env_type": "staging",
"current_version_id": "4671db05-2d34-4171-9626-79a468e73f61"
},
{
"id": "2c0ff980-fedf-4ebc-9117-dd21702d6e27",
"env_type": "production",
"current_version_id": "e6926b11-5513-4187-9dcf-5800b899f8da"
}
]
},
"errors": null
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "Cannot roll back to a version that was never deployed to production"
}
]
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "Production is already pinned to this version"
}
]
}
{
"data": null,
"errors": [
{
"error": "NOT_FOUND",
"message": "Version not found on this agent"
}
]
}
Docs for agents: llms.txt
Was this page helpful?
⌘I
Roll Back Agent
curl --request POST \
--url https://api.bland.ai/v2/agents/{agent_id}/rollback \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"version_id": "<string>"
}
'import requests
url = "https://api.bland.ai/v2/agents/{agent_id}/rollback"
payload = { "version_id": "<string>" }
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({version_id: '<string>'})
};
fetch('https://api.bland.ai/v2/agents/{agent_id}/rollback', 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.bland.ai/v2/agents/{agent_id}/rollback",
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' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$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.bland.ai/v2/agents/{agent_id}/rollback"
payload := strings.NewReader("{\n \"version_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
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.bland.ai/v2/agents/{agent_id}/rollback")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"version_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v2/agents/{agent_id}/rollback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"version_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"semver": "1.3.1",
"environments": [
{
"id": "3b4442ac-eaff-4a8d-bd9b-103affc43fc4",
"env_type": "dev",
"current_version_id": null
},
{
"id": "6e92b74f-071f-4a09-85a5-5a3e6625ddf5",
"env_type": "staging",
"current_version_id": "4671db05-2d34-4171-9626-79a468e73f61"
},
{
"id": "2c0ff980-fedf-4ebc-9117-dd21702d6e27",
"env_type": "production",
"current_version_id": "e6926b11-5513-4187-9dcf-5800b899f8da"
}
]
},
"errors": null
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "Cannot roll back to a version that was never deployed to production"
}
]
}
{
"data": null,
"errors": [
{
"error": "BAD_REQUEST",
"message": "Production is already pinned to this version"
}
]
}
{
"data": null,
"errors": [
{
"error": "NOT_FOUND",
"message": "Version not found on this agent"
}
]
}