Update agent
curl --request PUT \
--url https://api.lehar.ai/ca/api/v0/agent/{agent_id} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be warm and concise. Confirm the callback time.",
"task": "Qualify the lead and book a callback.",
"custom_variables": [
"callee_name",
"company"
],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"speaker": "shubh"
},
"tools": []
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/agent/{agent_id}"
payload = {
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be warm and concise. Confirm the callback time.",
"task": "Qualify the lead and book a callback.",
"custom_variables": ["callee_name", "company"],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"speaker": "shubh"
},
"tools": []
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Sales Agent',
objective: 'You are a sales assistant for {{company}}.',
instruction: 'Be warm and concise. Confirm the callback time.',
task: 'Qualify the lead and book a callback.',
custom_variables: ['callee_name', 'company'],
config: {llm_provider: 'gemini', tts_provider: 'sarvam', speaker: 'shubh'},
tools: []
})
};
fetch('https://api.lehar.ai/ca/api/v0/agent/{agent_id}', 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.lehar.ai/ca/api/v0/agent/{agent_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Sales Agent',
'objective' => 'You are a sales assistant for {{company}}.',
'instruction' => 'Be warm and concise. Confirm the callback time.',
'task' => 'Qualify the lead and book a callback.',
'custom_variables' => [
'callee_name',
'company'
],
'config' => [
'llm_provider' => 'gemini',
'tts_provider' => 'sarvam',
'speaker' => 'shubh'
],
'tools' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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.lehar.ai/ca/api/v0/agent/{agent_id}"
payload := strings.NewReader("{\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be warm and concise. Confirm the callback time.\",\n \"task\": \"Qualify the lead and book a callback.\",\n \"custom_variables\": [\n \"callee_name\",\n \"company\"\n ],\n \"config\": {\n \"llm_provider\": \"gemini\",\n \"tts_provider\": \"sarvam\",\n \"speaker\": \"shubh\"\n },\n \"tools\": []\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-KEY", "<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.put("https://api.lehar.ai/ca/api/v0/agent/{agent_id}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be warm and concise. Confirm the callback time.\",\n \"task\": \"Qualify the lead and book a callback.\",\n \"custom_variables\": [\n \"callee_name\",\n \"company\"\n ],\n \"config\": {\n \"llm_provider\": \"gemini\",\n \"tts_provider\": \"sarvam\",\n \"speaker\": \"shubh\"\n },\n \"tools\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/agent/{agent_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be warm and concise. Confirm the callback time.\",\n \"task\": \"Qualify the lead and book a callback.\",\n \"custom_variables\": [\n \"callee_name\",\n \"company\"\n ],\n \"config\": {\n \"llm_provider\": \"gemini\",\n \"tts_provider\": \"sarvam\",\n \"speaker\": \"shubh\"\n },\n \"tools\": []\n}"
response = http.request(request)
puts response.read_body{
"error": {
"code": "invalid_request",
"message": "config has keys the agent editor doesn't set for a voice agent: company, tts_speaker. Remove them; per-call values go in custom_variables."
}
}{
"error": {
"code": "conflict",
"message": "Published agents cannot be edited. Clone the agent to make changes."
}
}Agents
Update agent
Replaces a draft agent with the request body, so send the whole agent, including the full config. A field you leave out is cleared (an absent knowledge_base_id or pronunciation_dictionary_id unbinds it). A published agent returns 409 — clone it to change it. Scope sessions:write.
PUT
/
agent
/
{agent_id}
Update agent
curl --request PUT \
--url https://api.lehar.ai/ca/api/v0/agent/{agent_id} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be warm and concise. Confirm the callback time.",
"task": "Qualify the lead and book a callback.",
"custom_variables": [
"callee_name",
"company"
],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"speaker": "shubh"
},
"tools": []
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/agent/{agent_id}"
payload = {
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be warm and concise. Confirm the callback time.",
"task": "Qualify the lead and book a callback.",
"custom_variables": ["callee_name", "company"],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"speaker": "shubh"
},
"tools": []
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Sales Agent',
objective: 'You are a sales assistant for {{company}}.',
instruction: 'Be warm and concise. Confirm the callback time.',
task: 'Qualify the lead and book a callback.',
custom_variables: ['callee_name', 'company'],
config: {llm_provider: 'gemini', tts_provider: 'sarvam', speaker: 'shubh'},
tools: []
})
};
fetch('https://api.lehar.ai/ca/api/v0/agent/{agent_id}', 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.lehar.ai/ca/api/v0/agent/{agent_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Sales Agent',
'objective' => 'You are a sales assistant for {{company}}.',
'instruction' => 'Be warm and concise. Confirm the callback time.',
'task' => 'Qualify the lead and book a callback.',
'custom_variables' => [
'callee_name',
'company'
],
'config' => [
'llm_provider' => 'gemini',
'tts_provider' => 'sarvam',
'speaker' => 'shubh'
],
'tools' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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.lehar.ai/ca/api/v0/agent/{agent_id}"
payload := strings.NewReader("{\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be warm and concise. Confirm the callback time.\",\n \"task\": \"Qualify the lead and book a callback.\",\n \"custom_variables\": [\n \"callee_name\",\n \"company\"\n ],\n \"config\": {\n \"llm_provider\": \"gemini\",\n \"tts_provider\": \"sarvam\",\n \"speaker\": \"shubh\"\n },\n \"tools\": []\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-KEY", "<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.put("https://api.lehar.ai/ca/api/v0/agent/{agent_id}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be warm and concise. Confirm the callback time.\",\n \"task\": \"Qualify the lead and book a callback.\",\n \"custom_variables\": [\n \"callee_name\",\n \"company\"\n ],\n \"config\": {\n \"llm_provider\": \"gemini\",\n \"tts_provider\": \"sarvam\",\n \"speaker\": \"shubh\"\n },\n \"tools\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/agent/{agent_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be warm and concise. Confirm the callback time.\",\n \"task\": \"Qualify the lead and book a callback.\",\n \"custom_variables\": [\n \"callee_name\",\n \"company\"\n ],\n \"config\": {\n \"llm_provider\": \"gemini\",\n \"tts_provider\": \"sarvam\",\n \"speaker\": \"shubh\"\n },\n \"tools\": []\n}"
response = http.request(request)
puts response.read_body{
"error": {
"code": "invalid_request",
"message": "config has keys the agent editor doesn't set for a voice agent: company, tts_speaker. Remove them; per-call values go in custom_variables."
}
}{
"error": {
"code": "conflict",
"message": "Published agents cannot be edited. Clone the agent to make changes."
}
}Authorizations
ApiKeyAuthBearerAuth
Path Parameters
Body
application/json
Only the settings the dashboard's agent editor sets for the agent's channel (see Providers & models). Any other key (alias spellings, nested sections, prompt text, placeholder values) is refused with 400; prompt text belongs in the top-level fields and per-call values in custom_variables.
Response
Updated agent

