Create WebSocket session
curl --request POST \
--url https://api.getkarta.ai/public/v1/websocket/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "agentexample"
}
'import requests
url = "https://api.getkarta.ai/public/v1/websocket/sessions"
payload = { "agent_id": "agentexample" }
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: 'agentexample'})
};
fetch('https://api.getkarta.ai/public/v1/websocket/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"signed_url": "wss://voice.example.invalid/ws/?token=EXAMPLE_SINGLE_USE_TOKEN"
}WebSocket sessions
Create WebSocket session
Create a WebSocket session for a voice agent.
POST
/
websocket
/
sessions
Create WebSocket session
curl --request POST \
--url https://api.getkarta.ai/public/v1/websocket/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "agentexample"
}
'import requests
url = "https://api.getkarta.ai/public/v1/websocket/sessions"
payload = { "agent_id": "agentexample" }
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: 'agentexample'})
};
fetch('https://api.getkarta.ai/public/v1/websocket/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"signed_url": "wss://voice.example.invalid/ws/?token=EXAMPLE_SINGLE_USE_TOKEN"
}The connection URL is single-use and expires after 300 seconds by default. Keep it private.
See the WebSocket guide to connect.
Body
application/json