Create session
curl --request POST \
--url https://api.lehar.ai/ca/api/v0/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "agent_sales_hi",
"custom_variables": {
"callee_name": "Jane",
"company": "Acme"
},
"config": {
"tts_provider": "sarvam",
"voice": "anushka"
}
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/sessions"
payload = {
"agent_id": "agent_sales_hi",
"custom_variables": {
"callee_name": "Jane",
"company": "Acme"
},
"config": {
"tts_provider": "sarvam",
"voice": "anushka"
}
}
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({
agent_id: 'agent_sales_hi',
custom_variables: {callee_name: 'Jane', company: 'Acme'},
config: {tts_provider: 'sarvam', voice: 'anushka'}
})
};
fetch('https://api.lehar.ai/ca/api/v0/sessions', 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/sessions",
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([
'agent_id' => 'agent_sales_hi',
'custom_variables' => [
'callee_name' => 'Jane',
'company' => 'Acme'
],
'config' => [
'tts_provider' => 'sarvam',
'voice' => 'anushka'
]
]),
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 := "https://api.lehar.ai/ca/api/v0/sessions"
payload := strings.NewReader("{\n \"agent_id\": \"agent_sales_hi\",\n \"custom_variables\": {\n \"callee_name\": \"Jane\",\n \"company\": \"Acme\"\n },\n \"config\": {\n \"tts_provider\": \"sarvam\",\n \"voice\": \"anushka\"\n }\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("https://api.lehar.ai/ca/api/v0/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"agent_sales_hi\",\n \"custom_variables\": {\n \"callee_name\": \"Jane\",\n \"company\": \"Acme\"\n },\n \"config\": {\n \"tts_provider\": \"sarvam\",\n \"voice\": \"anushka\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_id\": \"agent_sales_hi\",\n \"custom_variables\": {\n \"callee_name\": \"Jane\",\n \"company\": \"Acme\"\n },\n \"config\": {\n \"tts_provider\": \"sarvam\",\n \"voice\": \"anushka\"\n }\n}"
response = http.request(request)
puts response.read_body{
"session_id": "session_01EXAMPLE",
"customer_id": "customer_01EXAMPLE",
"user_id": "user_01EXAMPLE",
"user_name": "Jane Operator",
"agent_id": "agent_sales_hi",
"agent_name": "Sales Agent",
"livekit_url": "wss://media.lehar.ai",
"room_name": "room_01EXAMPLE",
"participant_identity": "user_01EXAMPLE",
"participant_name": "Jane Operator",
"participant_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"dispatch_id": "disp_01EXAMPLE",
"metadata": {
"customer_id": "customer_01EXAMPLE",
"user_id": "user_01EXAMPLE",
"agent_id": "agent_sales_hi",
"session_id": "session_01EXAMPLE"
},
"status": "active",
"started_at": "2026-05-22T10:00:00Z",
"ended_at": null,
"call_type": "web"
}{
"error": {
"code": "invalid_request",
"message": "Bearer login is required to create sessions"
}
}Sessions
Create session
Creates a voice session for the logged-in user and returns a participant_token. Requires a bearer login session — an API key alone returns 400. Scope sessions:write.
POST
/
sessions
Create session
curl --request POST \
--url https://api.lehar.ai/ca/api/v0/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "agent_sales_hi",
"custom_variables": {
"callee_name": "Jane",
"company": "Acme"
},
"config": {
"tts_provider": "sarvam",
"voice": "anushka"
}
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/sessions"
payload = {
"agent_id": "agent_sales_hi",
"custom_variables": {
"callee_name": "Jane",
"company": "Acme"
},
"config": {
"tts_provider": "sarvam",
"voice": "anushka"
}
}
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({
agent_id: 'agent_sales_hi',
custom_variables: {callee_name: 'Jane', company: 'Acme'},
config: {tts_provider: 'sarvam', voice: 'anushka'}
})
};
fetch('https://api.lehar.ai/ca/api/v0/sessions', 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/sessions",
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([
'agent_id' => 'agent_sales_hi',
'custom_variables' => [
'callee_name' => 'Jane',
'company' => 'Acme'
],
'config' => [
'tts_provider' => 'sarvam',
'voice' => 'anushka'
]
]),
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 := "https://api.lehar.ai/ca/api/v0/sessions"
payload := strings.NewReader("{\n \"agent_id\": \"agent_sales_hi\",\n \"custom_variables\": {\n \"callee_name\": \"Jane\",\n \"company\": \"Acme\"\n },\n \"config\": {\n \"tts_provider\": \"sarvam\",\n \"voice\": \"anushka\"\n }\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("https://api.lehar.ai/ca/api/v0/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"agent_sales_hi\",\n \"custom_variables\": {\n \"callee_name\": \"Jane\",\n \"company\": \"Acme\"\n },\n \"config\": {\n \"tts_provider\": \"sarvam\",\n \"voice\": \"anushka\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_id\": \"agent_sales_hi\",\n \"custom_variables\": {\n \"callee_name\": \"Jane\",\n \"company\": \"Acme\"\n },\n \"config\": {\n \"tts_provider\": \"sarvam\",\n \"voice\": \"anushka\"\n }\n}"
response = http.request(request)
puts response.read_body{
"session_id": "session_01EXAMPLE",
"customer_id": "customer_01EXAMPLE",
"user_id": "user_01EXAMPLE",
"user_name": "Jane Operator",
"agent_id": "agent_sales_hi",
"agent_name": "Sales Agent",
"livekit_url": "wss://media.lehar.ai",
"room_name": "room_01EXAMPLE",
"participant_identity": "user_01EXAMPLE",
"participant_name": "Jane Operator",
"participant_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"dispatch_id": "disp_01EXAMPLE",
"metadata": {
"customer_id": "customer_01EXAMPLE",
"user_id": "user_01EXAMPLE",
"agent_id": "agent_sales_hi",
"session_id": "session_01EXAMPLE"
},
"status": "active",
"started_at": "2026-05-22T10:00:00Z",
"ended_at": null,
"call_type": "web"
}{
"error": {
"code": "invalid_request",
"message": "Bearer login is required to create sessions"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Agent to run.
Available options:
web, outbound_phone E.164 number to dial for outbound_phone.
Defaults to the auth user id.
Defaults to the logged-in user's name.
Values substituted into the agent's prompt.
Per-session provider overrides.
Client metadata (trusted ids are server-stamped).
Response
Created session with participant token (the only place the token is returned)

