Skip to main content
POST
/
batch
/
create
Create Batch Job
curl --request POST \
  --url https://api.talkifai.dev/batch/create \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form file='@example-file' \
  --form 'fromPhoneNumberId=<string>' \
  --form 'name=<string>' \
  --form 'description=<string>' \
  --form concurrentCallLimit=5 \
  --form maxAttempts=3 \
  --form scheduledStartTime=2023-11-07T05:31:56Z \
  --form timezone=UTC
{
  "success": true,
  "batchJobId": "batch_xyz789",
  "totalContacts": 100,
  "estimatedDuration": "15 minutes",
  "estimatedCost": "$3.50",
  "status": "scheduled",
  "scheduledStartTime": "2023-11-07T05:31:56Z",
  "message": "<string>"
}

Overview

Creates a batch calling job that will automatically dial contacts from your uploaded list. The job can start immediately or be scheduled for a future time. Key Features:
  • CSV file upload (up to 10,000 contacts)
  • Automatic phone number validation (E.164 format)
  • Scheduled start with timezone support
  • Configurable retry policy
  • Two-level concurrency control

Prerequisites

Before creating a batch job:
  1. Register a phone number in Studio → Phone Numbers
  2. Assign an outbound agent to that phone number
  3. Ensure sufficient credits in your organization account
  4. Prepare CSV file with at least a phone column
The agent assigned to the phone number must use Pipeline or Realtime architecture. Text-only agents cannot make voice calls.

Request

POST /batch/create
Content-Type: multipart/form-data

file: [CSV file]
fromPhoneNumberId: phone_abc123
name: January Renewal Campaign
description: Follow up on expiring subscriptions
concurrentCallLimit: 5
maxAttempts: 3
scheduledStartTime: 2025-02-28T09:00:00 (optional)
timezone: America/New_York (optional, default: UTC)

JSON Request (Programmatic)

POST /batch/create
Content-Type: application/json

{
  "fromPhoneNumberId": "phone_abc123",
  "name": "January Renewal Campaign",
  "description": "Follow up on expiring subscriptions",
  "contacts": [
    {
      "phone": "+12025550101",
      "name": "John Smith",
      "customerName": "John Smith",
      "renewalDate": "Feb 1"
    },
    {
      "phone": "+12025550102",
      "name": "Jane Doe",
      "customerName": "Jane Doe",
      "renewalDate": "Feb 5"
    }
  ],
  "concurrentCallLimit": 5,
  "maxAttempts": 3,
  "scheduledStartTime": "2025-02-28T09:00:00",
  "timezone": "America/New_York"
}

Request Parameters

Form/Body Fields

FieldTypeRequiredDefaultDescription
fileFile✅ (CSV mode)CSV file with contacts
fromPhoneNumberIdstringPhone number ID to call from
namestringBatch job name (max 200 chars)
descriptionstringnullOptional description (max 1000 chars)
contactsarray✅ (JSON mode)List of contact objects
concurrentCallLimitinteger5Max concurrent calls (1-50)
maxAttemptsinteger3Max retry attempts (1-10)
scheduledStartTimestringnullSchedule start (ISO 8601 format)
timezonestring"UTC"IANA timezone for scheduled time

Contact Object

FieldTypeRequiredDescription
phonestringPhone number in E.164 format
namestringContact name
*anyAdditional custom fields (stored as-is)

CSV Format

Your CSV file must have a phone column. Additional columns are stored as custom fields.
phone,name,customerName,renewalDate
+12025550101,John Smith,John Smith,Feb 1
+12025550102,Jane Doe,Jane Doe,Feb 5
+12025550103,Bob Johnson,Bob Johnson,Feb 10
ColumnRequiredDescription
phonePhone number in E.164 format (+12025550101)
nameContact name
any otherAdditional columns stored as custom fields
Phone Number Format: All phone numbers must be in E.164 format (e.g., +12025550101, +442071838750). Numbers without + or with formatting characters will be rejected.

Response

{
  "success": true,
  "batchJobId": "batch_xyz789",
  "totalContacts": 2,
  "estimatedDuration": "2 minutes",
  "estimatedCost": "$0.50",
  "status": "scheduled",
  "scheduledStartTime": "2025-02-28T14:00:00Z",
  "message": "Batch job created with 2 contacts"
}

Response Fields

FieldTypeDescription
successbooleanWhether the job was created successfully
batchJobIdstringUnique batch job identifier
totalContactsintegerNumber of valid contacts
estimatedDurationstringHuman-readable duration estimate
estimatedCoststringEstimated cost in USD
statusstringInitial status (scheduled or pending)
scheduledStartTimestringScheduled start time (ISO 8601, UTC)
messagestringSuccess message

Status Values

StatusDescription
pendingJob created, will start immediately
scheduledJob created, waiting for scheduled start time
runningJob is actively processing contacts
completedAll contacts processed
failedJob failed due to errors
cancelledJob was cancelled manually

Examples

Example 1: Immediate Start (CSV)

curl -X POST "https://api.talkifai.com/batch/create" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@contacts.csv" \
  -F "fromPhoneNumberId=phone_abc123" \
  -F "name=Payment Reminders" \
  -F "concurrentCallLimit=5" \
  -F "maxAttempts=3"

Example 2: Scheduled Start with Timezone

curl -X POST "https://api.talkifai.com/batch/create" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fromPhoneNumberId": "phone_abc123",
    "name": "Morning Follow-ups",
    "contacts": [
      {"phone": "+12025550101", "name": "John Smith"},
      {"phone": "+12025550102", "name": "Jane Doe"}
    ],
    "scheduledStartTime": "2025-03-01T09:00:00",
    "timezone": "America/New_York",
    "concurrentCallLimit": 3,
    "maxAttempts": 2
  }'

Example 3: Custom Fields for Personalization

curl -X POST "https://api.talkifai.com/batch/create" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fromPhoneNumberId": "phone_abc123",
    "name": "Renewal Campaign",
    "contacts": [
      {
        "phone": "+12025550101",
        "name": "John Smith",
        "customerName": "John Smith",
        "renewalDate": "Feb 1",
        "planType": "Premium"
      }
    ],
    "concurrentCallLimit": 5
  }'
Then in your Agent System Prompt, use the custom fields:
You are calling {{customerName}} about their {{planType}} plan renewal on {{renewalDate}}.
Greet them by name and confirm the renewal date.

Cost Estimation

The system estimates cost based on:
  • Number of contacts
  • Agent architecture (pipeline vs realtime)
  • Average call duration (assumed 2 minutes)
Example calculation for 100 contacts:
  • Pipeline agent: ~3.50(3.50 (0.035/call)
  • Realtime agent: ~7.00(7.00 (0.07/call)
Actual costs may vary based on call duration. The estimate assumes 2-minute average calls.

Error Handling

400 Bad Request

{
  "detail": "CSV must have 'phone' column. Found columns: ['name', 'email']"
}
Error CodeCause
invalid_csvCSV file missing or invalid format
missing_phone_columnCSV missing required phone column
no_valid_contactsCSV contains no valid phone numbers
too_many_contactsExceeds 10,000 contact limit
invalid_timezoneInvalid IANA timezone
past_scheduled_timeScheduled time is in the past
invalid_phone_formatPhone number not in E.164 format
insufficient_creditsOrganization has insufficient credits
no_outbound_agentPhone number has no outbound agent assigned

404 Not Found

{
  "detail": "Phone number phone_abc123 not found"
}

500 Internal Server Error

{
  "detail": "Failed to process CSV file: Database connection error"
}

How It Works

1. Upload CSV / Send JSON


2. Validate phone numbers (E.164 format)


3. Look up fromPhoneNumberId
         ├── Not found → 404 Error
         └── Found → Get org + agent


4. Check agent architecture
         ├── Text agent → 400 Error
         └── Voice agent → Continue


5. Validate contacts (remove duplicates)


6. Check organization credits
         ├── Insufficient → 400 Error
         └── Sufficient → Continue


7. Create batch job record

         ├── Scheduled? → Store in Redis defer queue
         └── Immediate? → Enqueue contacts to worker queue


8. Return batch job ID

Authorizations

Authorization
string
header
required

Your TalkifAI API key. Get it from Studio → Settings → API Keys.

Body

file
file
required

CSV file with contacts (must have 'phone' column)

fromPhoneNumberId
string
required

Phone number ID to call from

name
string
required

Batch job name

description
string

Optional description

concurrentCallLimit
integer
default:5
Required range: 1 <= x <= 50
maxAttempts
integer
default:3
Required range: 1 <= x <= 10
scheduledStartTime
string<date-time>

Schedule start time (ISO 8601)

timezone
string
default:UTC

IANA timezone for scheduled time

Response

Batch job created

success
boolean
Example:

true

batchJobId
string
Example:

"batch_xyz789"

totalContacts
integer
Example:

100

estimatedDuration
string
Example:

"15 minutes"

estimatedCost
string
Example:

"$3.50"

status
string
Example:

"scheduled"

scheduledStartTime
string<date-time> | null
message
string