Create a realtime session
Mints a short-lived (60s), single-use token that authorizes opening
exactly one connection to the /ws/{user_id} realtime voice/video
engine, scoped to the given agent_id and user_id: the only
supported way for an API-key holder to authenticate into that engine
(it otherwise only accepts a public-widget-style origin allowlist or a
dashboard session token, neither appropriate for a third-party API key).
Connect using the returned ws_url before expires_at; the token is
consumed on the first successful connection attempt and cannot be
reused, including for reconnects. Mint a fresh one for each connection,
including after a dropped connection you want to resume.
curl --request POST \
--url https://app.eclatira.com/api/v1/realtime/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "<string>",
"user_id": "<string>",
"source": "audio",
"variables": {}
}
'import requests
url = "https://app.eclatira.com/api/v1/realtime/sessions"
payload = {
"agent_id": "<string>",
"user_id": "<string>",
"source": "audio",
"variables": {}
}
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: '<string>', user_id: '<string>', source: 'audio', variables: {}})
};
fetch('https://app.eclatira.com/api/v1/realtime/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://app.eclatira.com/api/v1/realtime/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' => '<string>',
'user_id' => '<string>',
'source' => 'audio',
'variables' => [
]
]),
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://app.eclatira.com/api/v1/realtime/sessions"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"source\": \"audio\",\n \"variables\": {}\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://app.eclatira.com/api/v1/realtime/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"source\": \"audio\",\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.eclatira.com/api/v1/realtime/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\": \"<string>\",\n \"user_id\": \"<string>\",\n \"source\": \"audio\",\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"session_token": "<string>",
"expires_at": "<string>",
"ws_url": "<string>"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}Authorizations
A long-lived, privileged API key (ek_... prefix), minted once from the dashboard. Intended for trusted server-side use only; never expose it in client-side code. Send as Authorization: Bearer ek_.... Required by every Calls, Batches, Agents, Tools, MCP Servers, Documents, and Realtime route.
Body
curl --request POST \
--url https://app.eclatira.com/api/v1/realtime/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "<string>",
"user_id": "<string>",
"source": "audio",
"variables": {}
}
'import requests
url = "https://app.eclatira.com/api/v1/realtime/sessions"
payload = {
"agent_id": "<string>",
"user_id": "<string>",
"source": "audio",
"variables": {}
}
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: '<string>', user_id: '<string>', source: 'audio', variables: {}})
};
fetch('https://app.eclatira.com/api/v1/realtime/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://app.eclatira.com/api/v1/realtime/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' => '<string>',
'user_id' => '<string>',
'source' => 'audio',
'variables' => [
]
]),
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://app.eclatira.com/api/v1/realtime/sessions"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"source\": \"audio\",\n \"variables\": {}\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://app.eclatira.com/api/v1/realtime/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"<string>\",\n \"user_id\": \"<string>\",\n \"source\": \"audio\",\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.eclatira.com/api/v1/realtime/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\": \"<string>\",\n \"user_id\": \"<string>\",\n \"source\": \"audio\",\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"session_token": "<string>",
"expires_at": "<string>",
"ws_url": "<string>"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}