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/campaigns' \
-H "Authorization: Bearer $KARTA_API_KEY" \
-H "X-Request-ID: $KARTA_REQUEST_ID" \
-H 'Content-Type: application/json' \
-d '{
"campaign_name": "Example follow-up",
"agent_id": "agentexample",
"from_number": "+12025550124",
"max_attempts": 1,
"call_window": {
"time_zone": "Asia/Kolkata",
"days": [
1,
2,
3,
4,
5,
6
],
"start": "10:00",
"end": "18:00"
},
"call_details": [
{
"to_number": "+12025550123",
"llm_dynamic_variable": {
"customer_name": "Alex"
},
"transit_data": {
"external_id": "example-001"
}
}
]
}'import json
import os
from urllib.request import Request, urlopen
# Preserve KARTA_REQUEST_ID and the body when retrying this action.
body = {'campaign_name': 'Example follow-up', 'agent_id': 'agentexample', 'from_number': '+12025550124', 'max_attempts': 1, 'call_window': {'time_zone': 'Asia/Kolkata', 'days': [1, 2, 3, 4, 5, 6], 'start': '10:00', 'end': '18:00'}, 'call_details': [{'to_number': '+12025550123', 'llm_dynamic_variable': {'customer_name': 'Alex'}, 'transit_data': {'external_id': 'example-001'}}]}
request = Request(
'https://api.getkarta.ai/public/v1/voice/campaigns',
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/campaigns", {
method: "POST",
headers: {
"Authorization": `Bearer ${KARTA_API_KEY}`,
"X-Request-ID": KARTA_REQUEST_ID,
"Content-Type": "application/json",
},
body: JSON.stringify({
"campaign_name": "Example follow-up",
"agent_id": "agentexample",
"from_number": "+12025550124",
"max_attempts": 1,
"call_window": {
"time_zone": "Asia/Kolkata",
"days": [
1,
2,
3,
4,
5,
6
],
"start": "10:00",
"end": "18:00"
},
"call_details": [
{
"to_number": "+12025550123",
"llm_dynamic_variable": {
"customer_name": "Alex"
},
"transit_data": {
"external_id": "example-001"
}
}
]
}),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
console.log(await response.json());{
"campaign_id": "campaign_example",
"campaign_name": "Example follow-up",
"accepted_count": 1,
"config": {
"agent_id": "agentexample",
"from_number": "+12025550124",
"max_attempts": 1,
"time_gap_between_attempts": 1,
"call_window": {
"time_zone": "Asia/Kolkata",
"days": [
1,
2,
3,
4,
5,
6
],
"start": "10:00",
"end": "18:00"
}
}
}Campaigns
Create campaign
Schedule outbound calls to multiple recipients.
POST
/
voice
/
campaigns
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/campaigns' \
-H "Authorization: Bearer $KARTA_API_KEY" \
-H "X-Request-ID: $KARTA_REQUEST_ID" \
-H 'Content-Type: application/json' \
-d '{
"campaign_name": "Example follow-up",
"agent_id": "agentexample",
"from_number": "+12025550124",
"max_attempts": 1,
"call_window": {
"time_zone": "Asia/Kolkata",
"days": [
1,
2,
3,
4,
5,
6
],
"start": "10:00",
"end": "18:00"
},
"call_details": [
{
"to_number": "+12025550123",
"llm_dynamic_variable": {
"customer_name": "Alex"
},
"transit_data": {
"external_id": "example-001"
}
}
]
}'import json
import os
from urllib.request import Request, urlopen
# Preserve KARTA_REQUEST_ID and the body when retrying this action.
body = {'campaign_name': 'Example follow-up', 'agent_id': 'agentexample', 'from_number': '+12025550124', 'max_attempts': 1, 'call_window': {'time_zone': 'Asia/Kolkata', 'days': [1, 2, 3, 4, 5, 6], 'start': '10:00', 'end': '18:00'}, 'call_details': [{'to_number': '+12025550123', 'llm_dynamic_variable': {'customer_name': 'Alex'}, 'transit_data': {'external_id': 'example-001'}}]}
request = Request(
'https://api.getkarta.ai/public/v1/voice/campaigns',
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/campaigns", {
method: "POST",
headers: {
"Authorization": `Bearer ${KARTA_API_KEY}`,
"X-Request-ID": KARTA_REQUEST_ID,
"Content-Type": "application/json",
},
body: JSON.stringify({
"campaign_name": "Example follow-up",
"agent_id": "agentexample",
"from_number": "+12025550124",
"max_attempts": 1,
"call_window": {
"time_zone": "Asia/Kolkata",
"days": [
1,
2,
3,
4,
5,
6
],
"start": "10:00",
"end": "18:00"
},
"call_details": [
{
"to_number": "+12025550123",
"llm_dynamic_variable": {
"customer_name": "Alex"
},
"transit_data": {
"external_id": "example-001"
}
}
]
}),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
console.log(await response.json());{
"campaign_id": "campaign_example",
"campaign_name": "Example follow-up",
"accepted_count": 1,
"config": {
"agent_id": "agentexample",
"from_number": "+12025550124",
"max_attempts": 1,
"time_gap_between_attempts": 1,
"call_window": {
"time_zone": "Asia/Kolkata",
"days": [
1,
2,
3,
4,
5,
6
],
"start": "10:00",
"end": "18:00"
}
}
}Campaign calls consume credits.
202 response means recipients were accepted for scheduling. See run a campaign and idempotency.Body
application/json