Cancel Batch Job
Batch Calling
Cancel Batch Job
Cancel a scheduled, pending, or running batch job. Stops new calls and marks remaining contacts as cancelled.
POST
Cancel Batch Job
Overview
Cancels a batch job permanently. Behavior depends on job status:- Scheduled: Cancels Redis scheduled job + updates database
- Pending/Running: Marks remaining contacts as cancelled
- Completed/Failed/Cancelled: Returns error (cannot cancel)
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
batch_job_id | string | ✅ | Unique batch job identifier |
Response
Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Whether cancellation succeeded |
message | string | Cancellation result description |
batchJobId | string | Cancelled batch job ID |
redisJobCancelled | boolean | Whether Redis scheduled job was cancelled |
contactsCancelled | integer | Number of contacts marked as cancelled |
Examples
Example 1: Cancel Scheduled Job
Example 2: Cancel Running Job
Example 3: Cancel Already Completed Job (Error)
Behavior by Status
| Job Status | Cancellation Behavior |
|---|---|
scheduled | Cancels Redis defer job + marks DB as cancelled |
pending | Marks all contacts as cancelled |
running | Marks remaining (non-terminal) contacts as cancelled |
completed | ❌ Error: Cannot cancel completed job |
failed | ❌ Error: Cannot cancel failed job |
cancelled | ❌ Error: Already cancelled |
Contact Statuses Affected
When cancelling a running job, only contacts in non-terminal statuses are cancelled: Cancelled Statuses:pending— Not yet calledqueued— Waiting for retryno_answer— Will be retriedbusy— Will be retriedtimeout— Will be retried
completed— Already successfulfailed— Final failureblocked— Permanently blockedinvalid_number— Invalid phone numbercarrier_error— Carrier error (final)cancelled— Already cancelled
Error Handling
404 Not Found
400 Bad Request
| Error Code | Cause |
|---|---|
job_not_found | Batch job ID doesn’t exist |
already_terminal | Job is in completed/failed/cancelled status |
500 Internal Server Error
Use Cases
Cancel Due to Error in Campaign
If you discover an error in your campaign (wrong message, wrong numbers):Cancel Scheduled Job Before Start Time
Related
- Create Batch Job — Create a new batch job
- Get Batch Job Detail — Get job status
- Start Batch Job — Start scheduled job immediately
- Reschedule Batch Job — Change scheduled time
- Batch Calling Guide — Complete guide to batch campaigns
Authorizations
Your TalkifAI API key. Get it from Studio → Settings → API Keys.