Update your agent draft onto the newest version
curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"onTopOf": 5,
"baseRevision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"config": {
"conversation": {
"preamble": "You are a friendly support agent for Hamsa Telecom."
}
}
}
'import requests
url = "https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase"
payload = {
"onTopOf": 5,
"baseRevision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"config": { "conversation": { "preamble": "You are a friendly support agent for Hamsa Telecom." } }
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
onTopOf: 5,
baseRevision: 'e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56',
config: {
conversation: {preamble: 'You are a friendly support agent for Hamsa Telecom.'}
}
})
};
fetch('https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase', 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.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase",
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([
'onTopOf' => 5,
'baseRevision' => 'e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56',
'config' => [
'conversation' => [
'preamble' => 'You are a friendly support agent for Hamsa Telecom.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase"
payload := strings.NewReader("{\n \"onTopOf\": 5,\n \"baseRevision\": \"e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56\",\n \"config\": {\n \"conversation\": {\n \"preamble\": \"You are a friendly support agent for Hamsa Telecom.\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"onTopOf\": 5,\n \"baseRevision\": \"e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56\",\n \"config\": {\n \"conversation\": {\n \"preamble\": \"You are a friendly support agent for Hamsa Telecom.\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"onTopOf\": 5,\n \"baseRevision\": \"e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56\",\n \"config\": {\n \"conversation\": {\n \"preamble\": \"You are a friendly support agent for Hamsa Telecom.\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "success",
"data": {
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"draft": {
"id": "9a4c1e6b-2f3d-4b8a-8e7c-5d1f0a2b3c47",
"author": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
},
"status": "open",
"baseVersionNumber": 4,
"versionsBehind": 0,
"changedPaths": [
"conversation.preamble",
"llm.temperature"
],
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"proposedAt": "2026-10-28T09:15:00.000Z",
"proposalNote": "New opening line for Saudi callers.",
"lastSentBack": {
"by": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
},
"note": "Please keep the greeting under 10 seconds.",
"at": "2026-10-28T09:15:00.000Z"
},
"combinedFrom": [
{
"draftId": "9a4c1e6b-2f3d-4b8a-8e7c-5d1f0a2b3c47",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"author": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
}
}
],
"expiresAt": "2026-11-04T09:15:00.000Z",
"publishedAs": 5,
"closedBy": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
},
"closedAt": "2026-10-28T09:15:00.000Z",
"closedNote": "Covered by the new FAQ flow.",
"lastVia": {
"kind": "api_key",
"keyRef": "sk_live_4f2a",
"keyName": "CRM sync"
},
"proposedVia": {
"kind": "api_key",
"keyRef": "sk_live_4f2a",
"keyName": "CRM sync"
},
"updatedAt": "2026-10-28T09:15:00.000Z",
"valueKeys": [
"ORDER_ID"
]
}
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}Agent Versions & Drafts
Rebase Agent Draft
Moves your draft onto the newest version after someone published. You merge the two yourself and send the result as config, which is applied over version onTopOf. Works for open and proposed drafts.
POST
/
v2
/
voice-agents
/
{voiceAgentId}
/
draft
/
rebase
Update your agent draft onto the newest version
curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"onTopOf": 5,
"baseRevision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"config": {
"conversation": {
"preamble": "You are a friendly support agent for Hamsa Telecom."
}
}
}
'import requests
url = "https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase"
payload = {
"onTopOf": 5,
"baseRevision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"config": { "conversation": { "preamble": "You are a friendly support agent for Hamsa Telecom." } }
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
onTopOf: 5,
baseRevision: 'e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56',
config: {
conversation: {preamble: 'You are a friendly support agent for Hamsa Telecom.'}
}
})
};
fetch('https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase', 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.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase",
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([
'onTopOf' => 5,
'baseRevision' => 'e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56',
'config' => [
'conversation' => [
'preamble' => 'You are a friendly support agent for Hamsa Telecom.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase"
payload := strings.NewReader("{\n \"onTopOf\": 5,\n \"baseRevision\": \"e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56\",\n \"config\": {\n \"conversation\": {\n \"preamble\": \"You are a friendly support agent for Hamsa Telecom.\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"onTopOf\": 5,\n \"baseRevision\": \"e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56\",\n \"config\": {\n \"conversation\": {\n \"preamble\": \"You are a friendly support agent for Hamsa Telecom.\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/draft/rebase")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"onTopOf\": 5,\n \"baseRevision\": \"e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56\",\n \"config\": {\n \"conversation\": {\n \"preamble\": \"You are a friendly support agent for Hamsa Telecom.\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "success",
"data": {
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"draft": {
"id": "9a4c1e6b-2f3d-4b8a-8e7c-5d1f0a2b3c47",
"author": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
},
"status": "open",
"baseVersionNumber": 4,
"versionsBehind": 0,
"changedPaths": [
"conversation.preamble",
"llm.temperature"
],
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"proposedAt": "2026-10-28T09:15:00.000Z",
"proposalNote": "New opening line for Saudi callers.",
"lastSentBack": {
"by": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
},
"note": "Please keep the greeting under 10 seconds.",
"at": "2026-10-28T09:15:00.000Z"
},
"combinedFrom": [
{
"draftId": "9a4c1e6b-2f3d-4b8a-8e7c-5d1f0a2b3c47",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56",
"author": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
}
}
],
"expiresAt": "2026-11-04T09:15:00.000Z",
"publishedAs": 5,
"closedBy": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Sara Ahmad",
"email": "[email protected]"
},
"closedAt": "2026-10-28T09:15:00.000Z",
"closedNote": "Covered by the new FAQ flow.",
"lastVia": {
"kind": "api_key",
"keyRef": "sk_live_4f2a",
"keyName": "CRM sync"
},
"proposedVia": {
"kind": "api_key",
"keyRef": "sk_live_4f2a",
"keyName": "CRM sync"
},
"updatedAt": "2026-10-28T09:15:00.000Z",
"valueKeys": [
"ORDER_ID"
]
}
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}{
"code": 8409,
"message": "Your draft changed in another tab or through your API key. Reload it and try again.",
"messageKey": "DraftStaleRevision",
"params": {
"reason": "STALE_REVISION",
"revision": "e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56"
}
}Authorizations
Headers
Optional, up to 255 characters. Retry with the same key after a network error and you get the first answer back instead of the change being made twice (kept 10 minutes). Same key with a different body: 422 IdempotencyKeyReused. While the first request still runs: 409 IdempotencyKeyInProgress.
Maximum string length:
255Example:
"0b6f3c1e-retry-1"
Path Parameters
Body
application/json
Was this page helpful?