curl --request POST \
--url https://api.pyai.com/v1/telephony/browser-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"from_number_id": "<string>",
"to": "<string>",
"user_id": "<string>",
"client_reference": "<string>",
"recording": true,
"destinations": [
"<string>"
],
"use_case": "support",
"max_duration_seconds": 3600,
"transfer_enabled": false
}
'import requests
url = "https://api.pyai.com/v1/telephony/browser-sessions"
payload = {
"from_number_id": "<string>",
"to": "<string>",
"user_id": "<string>",
"client_reference": "<string>",
"recording": True,
"destinations": ["<string>"],
"use_case": "support",
"max_duration_seconds": 3600,
"transfer_enabled": False
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from_number_id: '<string>',
to: '<string>',
user_id: '<string>',
client_reference: '<string>',
recording: true,
destinations: ['<string>'],
use_case: 'support',
max_duration_seconds: 3600,
transfer_enabled: false
})
};
fetch('https://api.pyai.com/v1/telephony/browser-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.pyai.com/v1/telephony/browser-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([
'from_number_id' => '<string>',
'to' => '<string>',
'user_id' => '<string>',
'client_reference' => '<string>',
'recording' => true,
'destinations' => [
'<string>'
],
'use_case' => 'support',
'max_duration_seconds' => 3600,
'transfer_enabled' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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.pyai.com/v1/telephony/browser-sessions"
payload := strings.NewReader("{\n \"from_number_id\": \"<string>\",\n \"to\": \"<string>\",\n \"user_id\": \"<string>\",\n \"client_reference\": \"<string>\",\n \"recording\": true,\n \"destinations\": [\n \"<string>\"\n ],\n \"use_case\": \"support\",\n \"max_duration_seconds\": 3600,\n \"transfer_enabled\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.pyai.com/v1/telephony/browser-sessions")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from_number_id\": \"<string>\",\n \"to\": \"<string>\",\n \"user_id\": \"<string>\",\n \"client_reference\": \"<string>\",\n \"recording\": true,\n \"destinations\": [\n \"<string>\"\n ],\n \"use_case\": \"support\",\n \"max_duration_seconds\": 3600,\n \"transfer_enabled\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pyai.com/v1/telephony/browser-sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_number_id\": \"<string>\",\n \"to\": \"<string>\",\n \"user_id\": \"<string>\",\n \"client_reference\": \"<string>\",\n \"recording\": true,\n \"destinations\": [\n \"<string>\"\n ],\n \"use_case\": \"support\",\n \"max_duration_seconds\": 3600,\n \"transfer_enabled\": false\n}"
response = http.request(request)
puts response.read_body{
"object": "telephony.browser_session",
"id": "<string>",
"call_id": "<string>",
"transport": "voice-sdk",
"access_token": "<string>",
"expires_at": 123,
"connect_params": {
"session_id": "<string>"
},
"call": {
"version": 123,
"project_id": "<string>",
"direction": "inbound",
"from": "<string>",
"destination_number_id": "<string>",
"admission_mode": "client",
"admission_status": "pending",
"admission_expires_at": 123,
"max_duration_seconds": 123,
"client_reference": "<string>",
"agent_release_id": "<string>",
"stop_requested": true,
"object": "telephony.call",
"id": "tcall_...",
"from_number_id": "<string>",
"to": "+14155550123",
"dialing_mode": "parallel",
"destinations": [
"<string>"
],
"connected_to": "<string>",
"lines": [
{
"id": "<string>",
"to": "<string>",
"status": "pending",
"duration_seconds": 1
}
],
"agent_id": "<string>",
"call_type": "human",
"user_id": "<string>",
"forwarding": {
"to": "<string>",
"status": "waiting",
"menu": {
"kind": "keypad",
"status": "pending",
"choice_id": "<string>"
}
},
"transfer_enabled": true,
"held": true,
"hold_pending": true,
"transfers": [
{
"id": "<string>",
"mode": "warm",
"to": "<string>",
"status": "holding"
}
],
"use_case": "transactional",
"routing_profile": "quality_first",
"status": "queued",
"attempt_count": 1,
"max_attempts": 2,
"failure_reason": "network_unavailable",
"created_at": 123,
"updated_at": 123,
"answered_at": 123,
"ended_at": 123,
"artifacts": {
"status": "pending",
"omni_call_id": "<string>",
"recording": {
"status": "<string>",
"reason": "<string>",
"resource": "<string>"
},
"transcript": {
"status": "<string>",
"reason": "<string>",
"text": "<string>",
"resource": "<string>"
},
"ai_usage": {
"status": "pending",
"meter": "agents.minutes",
"units": 123,
"billable_units": 123
},
"usage": {
"status": "pending",
"meter": "telephony.minutes",
"units": 123,
"billable": true
}
}
}
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Create a managed human calling session
Create a short-lived, single-use browser calling session for one US, Australian or Indian destination, or a parallel group of two to four distinct destinations. The first answered line connects to the browser and the other lines are canceled. Every line reserves capacity and needs its own consent. Usage includes the actual connected duration of every phone leg; browser time is excluded. Requires a live project key with telephony:manage. Your server supplies the authenticated user ID. Source number, destination, user and client reference are immutable. No phone is dialed until the browser connects. Retry the same Idempotency-Key to recover the same call; a consumed, expired or stopped session returns access_token=null. Use the supported Voice JavaScript SDK with the returned token and connect_params. Managed calling policy, consent and source ownership are checked again when connecting. Human calls produce telephony usage only. Recording, when enabled, is captured from answer and retained privately by PyAI.
curl --request POST \
--url https://api.pyai.com/v1/telephony/browser-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"from_number_id": "<string>",
"to": "<string>",
"user_id": "<string>",
"client_reference": "<string>",
"recording": true,
"destinations": [
"<string>"
],
"use_case": "support",
"max_duration_seconds": 3600,
"transfer_enabled": false
}
'import requests
url = "https://api.pyai.com/v1/telephony/browser-sessions"
payload = {
"from_number_id": "<string>",
"to": "<string>",
"user_id": "<string>",
"client_reference": "<string>",
"recording": True,
"destinations": ["<string>"],
"use_case": "support",
"max_duration_seconds": 3600,
"transfer_enabled": False
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from_number_id: '<string>',
to: '<string>',
user_id: '<string>',
client_reference: '<string>',
recording: true,
destinations: ['<string>'],
use_case: 'support',
max_duration_seconds: 3600,
transfer_enabled: false
})
};
fetch('https://api.pyai.com/v1/telephony/browser-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.pyai.com/v1/telephony/browser-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([
'from_number_id' => '<string>',
'to' => '<string>',
'user_id' => '<string>',
'client_reference' => '<string>',
'recording' => true,
'destinations' => [
'<string>'
],
'use_case' => 'support',
'max_duration_seconds' => 3600,
'transfer_enabled' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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.pyai.com/v1/telephony/browser-sessions"
payload := strings.NewReader("{\n \"from_number_id\": \"<string>\",\n \"to\": \"<string>\",\n \"user_id\": \"<string>\",\n \"client_reference\": \"<string>\",\n \"recording\": true,\n \"destinations\": [\n \"<string>\"\n ],\n \"use_case\": \"support\",\n \"max_duration_seconds\": 3600,\n \"transfer_enabled\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.pyai.com/v1/telephony/browser-sessions")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from_number_id\": \"<string>\",\n \"to\": \"<string>\",\n \"user_id\": \"<string>\",\n \"client_reference\": \"<string>\",\n \"recording\": true,\n \"destinations\": [\n \"<string>\"\n ],\n \"use_case\": \"support\",\n \"max_duration_seconds\": 3600,\n \"transfer_enabled\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pyai.com/v1/telephony/browser-sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from_number_id\": \"<string>\",\n \"to\": \"<string>\",\n \"user_id\": \"<string>\",\n \"client_reference\": \"<string>\",\n \"recording\": true,\n \"destinations\": [\n \"<string>\"\n ],\n \"use_case\": \"support\",\n \"max_duration_seconds\": 3600,\n \"transfer_enabled\": false\n}"
response = http.request(request)
puts response.read_body{
"object": "telephony.browser_session",
"id": "<string>",
"call_id": "<string>",
"transport": "voice-sdk",
"access_token": "<string>",
"expires_at": 123,
"connect_params": {
"session_id": "<string>"
},
"call": {
"version": 123,
"project_id": "<string>",
"direction": "inbound",
"from": "<string>",
"destination_number_id": "<string>",
"admission_mode": "client",
"admission_status": "pending",
"admission_expires_at": 123,
"max_duration_seconds": 123,
"client_reference": "<string>",
"agent_release_id": "<string>",
"stop_requested": true,
"object": "telephony.call",
"id": "tcall_...",
"from_number_id": "<string>",
"to": "+14155550123",
"dialing_mode": "parallel",
"destinations": [
"<string>"
],
"connected_to": "<string>",
"lines": [
{
"id": "<string>",
"to": "<string>",
"status": "pending",
"duration_seconds": 1
}
],
"agent_id": "<string>",
"call_type": "human",
"user_id": "<string>",
"forwarding": {
"to": "<string>",
"status": "waiting",
"menu": {
"kind": "keypad",
"status": "pending",
"choice_id": "<string>"
}
},
"transfer_enabled": true,
"held": true,
"hold_pending": true,
"transfers": [
{
"id": "<string>",
"mode": "warm",
"to": "<string>",
"status": "holding"
}
],
"use_case": "transactional",
"routing_profile": "quality_first",
"status": "queued",
"attempt_count": 1,
"max_attempts": 2,
"failure_reason": "network_unavailable",
"created_at": 123,
"updated_at": 123,
"answered_at": 123,
"ended_at": 123,
"artifacts": {
"status": "pending",
"omni_call_id": "<string>",
"recording": {
"status": "<string>",
"reason": "<string>",
"resource": "<string>"
},
"transcript": {
"status": "<string>",
"reason": "<string>",
"text": "<string>",
"resource": "<string>"
},
"ai_usage": {
"status": "pending",
"meter": "agents.minutes",
"units": 123,
"billable_units": 123
},
"usage": {
"status": "pending",
"meter": "telephony.minutes",
"units": 123,
"billable": true
}
}
}
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Authorizations
Body
- Option 1
- Option 2
Response
Durable call and ephemeral browser capability. Never cache the token.