Update session status
curl --request PATCH \
--url https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"status": "ended"
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status"
payload = { "status": "ended" }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({status: 'ended'})
};
fetch('https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status', 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/{session_id}/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'status' => 'ended'
]),
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/sessions/{session_id}/status"
payload := strings.NewReader("{\n \"status\": \"ended\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"status\": \"ended\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"status\": \"ended\"\n}"
response = http.request(request)
puts response.read_body{
"id": "01k4qx7m8p2rs5t7v9w1x3y5z7",
"session_id": "session_01k4qx7m8p2rs5t7v9w1x3y5z7",
"customer_id": "customer_01k3ab2c4d6e8f0g2h4j6k8m0n",
"user_id": "user_01k2zzs7q9r1s3t5v7w9x1y3z5",
"user_name": "Priya Sharma",
"agent_id": "agent_01k1mn3p5q7r9s1t3v5w7x9y1z",
"room_name": null,
"participant_identity": "user_01k2zzs7q9r1s3t5v7w9x1y3z5",
"participant_name": "Priya Sharma",
"dispatch_id": null,
"livekit_url": null,
"status": "ended",
"qualification_status": null,
"sentiment": null,
"metadata": {
"agent_id": "agent_01k1mn3p5q7r9s1t3v5w7x9y1z",
"user_name": "Priya Sharma",
"call_type": "web"
},
"call_type": "web",
"origin": "dashboard",
"call_id": null,
"started_at": "2026-09-02T10:15:30.482119+00:00",
"ended_at": "2026-09-02T10:19:04.113587+00:00",
"created_at": "2026-09-02T10:15:30.482119+00:00",
"updated_at": "2026-09-02T10:19:04.113587+00:00"
}{
"error": {
"code": "invalid_request",
"message": "status must be one of active, ended, failed, or expired"
}
}{
"error": {
"code": "unauthorized",
"message": "Authentication required"
}
}{
"error": {
"code": "forbidden",
"message": "Scope 'sessions:write' is required"
}
}{
"error": {
"code": "not_found",
"message": "Session not found"
}
}{
"error": {
"code": "internal_error",
"message": "An unexpected error occurred"
}
}Sessions
Update session status
Sets a session’s lifecycle status. A terminal session (ended/failed/expired) is frozen: its status and ended_at cannot be regressed, so such a request returns the row unchanged; a transition into a terminal status also tears down the LiveKit room. Scope sessions:write.
PATCH
/
sessions
/
{session_id}
/
status
Update session status
curl --request PATCH \
--url https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"status": "ended"
}
'import requests
url = "https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status"
payload = { "status": "ended" }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({status: 'ended'})
};
fetch('https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status', 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/{session_id}/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'status' => 'ended'
]),
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/sessions/{session_id}/status"
payload := strings.NewReader("{\n \"status\": \"ended\"\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"status\": \"ended\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lehar.ai/ca/api/v0/sessions/{session_id}/status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"status\": \"ended\"\n}"
response = http.request(request)
puts response.read_body{
"id": "01k4qx7m8p2rs5t7v9w1x3y5z7",
"session_id": "session_01k4qx7m8p2rs5t7v9w1x3y5z7",
"customer_id": "customer_01k3ab2c4d6e8f0g2h4j6k8m0n",
"user_id": "user_01k2zzs7q9r1s3t5v7w9x1y3z5",
"user_name": "Priya Sharma",
"agent_id": "agent_01k1mn3p5q7r9s1t3v5w7x9y1z",
"room_name": null,
"participant_identity": "user_01k2zzs7q9r1s3t5v7w9x1y3z5",
"participant_name": "Priya Sharma",
"dispatch_id": null,
"livekit_url": null,
"status": "ended",
"qualification_status": null,
"sentiment": null,
"metadata": {
"agent_id": "agent_01k1mn3p5q7r9s1t3v5w7x9y1z",
"user_name": "Priya Sharma",
"call_type": "web"
},
"call_type": "web",
"origin": "dashboard",
"call_id": null,
"started_at": "2026-09-02T10:15:30.482119+00:00",
"ended_at": "2026-09-02T10:19:04.113587+00:00",
"created_at": "2026-09-02T10:15:30.482119+00:00",
"updated_at": "2026-09-02T10:19:04.113587+00:00"
}{
"error": {
"code": "invalid_request",
"message": "status must be one of active, ended, failed, or expired"
}
}{
"error": {
"code": "unauthorized",
"message": "Authentication required"
}
}{
"error": {
"code": "forbidden",
"message": "Scope 'sessions:write' is required"
}
}{
"error": {
"code": "not_found",
"message": "Session not found"
}
}{
"error": {
"code": "internal_error",
"message": "An unexpected error occurred"
}
}Authorizations
ApiKeyAuthBearerAuth
Path Parameters
The session's session_id.
Body
application/json
The status to set. A terminal current status is frozen and cannot be regressed to active.
Available options:
active, ended, failed, expired Response
The session after the status update.
Available options:
active, ended, failed, expired Available options:
pending, qualified, not_qualified, inconclusive Available options:
positive, negative, neutral web, outbound_phone, or inbound_phone.
Available options:
dashboard, api, campaign, inbound, test 
