Create agent
curl --request POST \
--url https://api.lehar.ai/ca/api/v0/agent \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"id": "agent_sales_hi",
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be polite, concise, and never invent prices.",
"task": "Qualify the lead and book a callback.",
"custom_variables": [
"callee_name",
"company"
],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"voice": "anushka"
},
"tools": []
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/agent"
payload = {
"id": "agent_sales_hi",
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be polite, concise, and never invent prices.",
"task": "Qualify the lead and book a callback.",
"custom_variables": ["callee_name", "company"],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"voice": "anushka"
},
"tools": []
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 'agent_sales_hi',
name: 'Sales Agent',
objective: 'You are a sales assistant for {{company}}.',
instruction: 'Be polite, concise, and never invent prices.',
task: 'Qualify the lead and book a callback.',
custom_variables: ['callee_name', 'company'],
config: {llm_provider: 'gemini', tts_provider: 'sarvam', voice: 'anushka'},
tools: []
})
};
fetch('https://api.lehar.ai/ca/api/v0/agent', 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",
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([
'id' => 'agent_sales_hi',
'name' => 'Sales Agent',
'objective' => 'You are a sales assistant for {{company}}.',
'instruction' => 'Be polite, concise, and never invent prices.',
'task' => 'Qualify the lead and book a callback.',
'custom_variables' => [
'callee_name',
'company'
],
'config' => [
'llm_provider' => 'gemini',
'tts_provider' => 'sarvam',
'voice' => 'anushka'
],
'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"
payload := strings.NewReader("{\n \"id\": \"agent_sales_hi\",\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be polite, concise, and never invent prices.\",\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 \"voice\": \"anushka\"\n },\n \"tools\": []\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.lehar.ai/ca/api/v0/agent")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"agent_sales_hi\",\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be polite, concise, and never invent prices.\",\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 \"voice\": \"anushka\"\n },\n \"tools\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/agent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"agent_sales_hi\",\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be polite, concise, and never invent prices.\",\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 \"voice\": \"anushka\"\n },\n \"tools\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "agent_sales_hi",
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be polite, concise, and never invent prices.",
"task": "Qualify the lead and book a callback.",
"faqs": null,
"sample_conversations": null,
"channel": "voice",
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"voice": "anushka"
},
"tools": [],
"custom_variables": [
"callee_name",
"company"
],
"questionnaire": null,
"template_agent_id": null,
"customer_id": "customer_01EXAMPLE",
"owner_user_id": "user_01EXAMPLE",
"created_by_user_id": "user_01EXAMPLE",
"visibility": "private",
"status": "draft",
"published_at": null,
"created_at": "2026-05-22T10:00:00Z",
"updated_at": "2026-05-22T10:00:00Z"
}{
"error": {
"code": "conflict",
"message": "Agent already exists"
}
}Agents
Create agent
Creates a draft agent. id is client-supplied. Prompt fields support {{placeholders}} filled from session custom_variables. Scope sessions:write.
POST
/
agent
Create agent
curl --request POST \
--url https://api.lehar.ai/ca/api/v0/agent \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"id": "agent_sales_hi",
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be polite, concise, and never invent prices.",
"task": "Qualify the lead and book a callback.",
"custom_variables": [
"callee_name",
"company"
],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"voice": "anushka"
},
"tools": []
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/agent"
payload = {
"id": "agent_sales_hi",
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be polite, concise, and never invent prices.",
"task": "Qualify the lead and book a callback.",
"custom_variables": ["callee_name", "company"],
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"voice": "anushka"
},
"tools": []
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 'agent_sales_hi',
name: 'Sales Agent',
objective: 'You are a sales assistant for {{company}}.',
instruction: 'Be polite, concise, and never invent prices.',
task: 'Qualify the lead and book a callback.',
custom_variables: ['callee_name', 'company'],
config: {llm_provider: 'gemini', tts_provider: 'sarvam', voice: 'anushka'},
tools: []
})
};
fetch('https://api.lehar.ai/ca/api/v0/agent', 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",
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([
'id' => 'agent_sales_hi',
'name' => 'Sales Agent',
'objective' => 'You are a sales assistant for {{company}}.',
'instruction' => 'Be polite, concise, and never invent prices.',
'task' => 'Qualify the lead and book a callback.',
'custom_variables' => [
'callee_name',
'company'
],
'config' => [
'llm_provider' => 'gemini',
'tts_provider' => 'sarvam',
'voice' => 'anushka'
],
'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"
payload := strings.NewReader("{\n \"id\": \"agent_sales_hi\",\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be polite, concise, and never invent prices.\",\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 \"voice\": \"anushka\"\n },\n \"tools\": []\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.lehar.ai/ca/api/v0/agent")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"agent_sales_hi\",\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be polite, concise, and never invent prices.\",\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 \"voice\": \"anushka\"\n },\n \"tools\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/agent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"agent_sales_hi\",\n \"name\": \"Sales Agent\",\n \"objective\": \"You are a sales assistant for {{company}}.\",\n \"instruction\": \"Be polite, concise, and never invent prices.\",\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 \"voice\": \"anushka\"\n },\n \"tools\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "agent_sales_hi",
"name": "Sales Agent",
"objective": "You are a sales assistant for {{company}}.",
"instruction": "Be polite, concise, and never invent prices.",
"task": "Qualify the lead and book a callback.",
"faqs": null,
"sample_conversations": null,
"channel": "voice",
"config": {
"llm_provider": "gemini",
"tts_provider": "sarvam",
"voice": "anushka"
},
"tools": [],
"custom_variables": [
"callee_name",
"company"
],
"questionnaire": null,
"template_agent_id": null,
"customer_id": "customer_01EXAMPLE",
"owner_user_id": "user_01EXAMPLE",
"created_by_user_id": "user_01EXAMPLE",
"visibility": "private",
"status": "draft",
"published_at": null,
"created_at": "2026-05-22T10:00:00Z",
"updated_at": "2026-05-22T10:00:00Z"
}{
"error": {
"code": "conflict",
"message": "Agent already exists"
}
}Authorizations
ApiKeyAuthBearerAuth
Body
application/json
Client-supplied agent id (alias: agent_id).
Required before the agent can be published.
Available options:
voice, whatsapp Provider selection and per-agent settings (see Providers & Models).
Response
Created agent (status draft)

