cURL
: "${KARTA_API_KEY:?Set your API key}"
: "${KARTA_REQUEST_ID:?Set a unique ID; preserve it for retries}"
curl --fail-with-body 'https://api.getkarta.ai/public/v1/voice/calls/web' \
-H "Authorization: Bearer $KARTA_API_KEY" \
-H "X-Request-ID: $KARTA_REQUEST_ID" \
-H 'Content-Type: application/json' \
-d '{
"agent_id": "agentexample",
"interaction_mode": "voice",
"source": "api"
}'import json
import os
from urllib.request import Request, urlopen
# Preserve KARTA_REQUEST_ID and the body when retrying this action.
body = {'agent_id': 'agentexample', 'interaction_mode': 'voice', 'source': 'api'}
request = Request(
'https://api.getkarta.ai/public/v1/voice/calls/web',
data=json.dumps(body).encode(),
headers={
"Authorization": f"Bearer {os.environ['KARTA_API_KEY']}",
"X-Request-ID": os.environ["KARTA_REQUEST_ID"],
"Content-Type": "application/json",
},
method="POST",
)
with urlopen(request, timeout=30) as response:
print(response.status, json.load(response))// Run on your server. Preserve this ID and body when retrying.
const { KARTA_API_KEY, KARTA_REQUEST_ID } = process.env;
if (!KARTA_API_KEY || !KARTA_REQUEST_ID) throw new Error("Set API key and request ID");
const response = await fetch("https://api.getkarta.ai/public/v1/voice/calls/web", {
method: "POST",
headers: {
"Authorization": `Bearer ${KARTA_API_KEY}`,
"X-Request-ID": KARTA_REQUEST_ID,
"Content-Type": "application/json",
},
body: JSON.stringify({
"agent_id": "agentexample",
"interaction_mode": "voice",
"source": "api"
}),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
console.log(await response.json());{
"call_id": "call_example",
"call_status": "call_registered",
"call_type": "web_call",
"agent_id": "agentexample",
"interaction_mode": "voice",
"source": "api",
"llm_dynamic_variables": {},
"transit_data": null,
"token": "EXAMPLE_CONNECTION_TOKEN",
"url": "wss://connection.example.invalid"
}Calls
Create web call
Create a web call and retrieve its connection credentials.
POST
/
voice
/
calls
/
web
cURL
: "${KARTA_API_KEY:?Set your API key}"
: "${KARTA_REQUEST_ID:?Set a unique ID; preserve it for retries}"
curl --fail-with-body 'https://api.getkarta.ai/public/v1/voice/calls/web' \
-H "Authorization: Bearer $KARTA_API_KEY" \
-H "X-Request-ID: $KARTA_REQUEST_ID" \
-H 'Content-Type: application/json' \
-d '{
"agent_id": "agentexample",
"interaction_mode": "voice",
"source": "api"
}'import json
import os
from urllib.request import Request, urlopen
# Preserve KARTA_REQUEST_ID and the body when retrying this action.
body = {'agent_id': 'agentexample', 'interaction_mode': 'voice', 'source': 'api'}
request = Request(
'https://api.getkarta.ai/public/v1/voice/calls/web',
data=json.dumps(body).encode(),
headers={
"Authorization": f"Bearer {os.environ['KARTA_API_KEY']}",
"X-Request-ID": os.environ["KARTA_REQUEST_ID"],
"Content-Type": "application/json",
},
method="POST",
)
with urlopen(request, timeout=30) as response:
print(response.status, json.load(response))// Run on your server. Preserve this ID and body when retrying.
const { KARTA_API_KEY, KARTA_REQUEST_ID } = process.env;
if (!KARTA_API_KEY || !KARTA_REQUEST_ID) throw new Error("Set API key and request ID");
const response = await fetch("https://api.getkarta.ai/public/v1/voice/calls/web", {
method: "POST",
headers: {
"Authorization": `Bearer ${KARTA_API_KEY}`,
"X-Request-ID": KARTA_REQUEST_ID,
"Content-Type": "application/json",
},
body: JSON.stringify({
"agent_id": "agentexample",
"interaction_mode": "voice",
"source": "api"
}),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
console.log(await response.json());{
"call_id": "call_example",
"call_status": "call_registered",
"call_type": "web_call",
"agent_id": "agentexample",
"interaction_mode": "voice",
"source": "api",
"llm_dynamic_variables": {},
"transit_data": null,
"token": "EXAMPLE_CONNECTION_TOKEN",
"url": "wss://connection.example.invalid"
}Web calls consume credits.
Body
application/json
Response
Successful response.