Cancel Call Batch
Cancels a batch and marks all remaining pending, queued, or scheduled contacts as skipped. In-progress calls will continue until they complete, but no new calls will be initiated. This action is irreversible.
Endpoint
| Property | Value |
|---|---|
| Function Name | calls-batch-cancel |
| HTTP Method | POST |
| Authentication | Supabase JWT (Bearer token) |
| Required Role | agency_owner or agency_admin |
Request
Headers
Authorization: Bearer <supabase_jwt_token>
Content-Type: application/json
Body
| Field | Type | Required | Description |
|---|---|---|---|
batch_id | string (UUID) | Yes | The batch to cancel |
Response
Success (200)
{
"success": true,
"batch_id": "uuid",
"status": "cancelled",
"contacts_skipped": 342,
"message": "Batch cancelled. In-progress calls will complete but no new calls will be initiated."
}
Error Responses
| Status | Condition |
|---|---|
| 400 | batch_id is missing |
| 400 | Batch is already completed or cancelled |
| 401 | Missing or invalid authorization header |
| 403 | User is not associated with an agency |
| 403 | User role is not agency_owner or agency_admin |
| 404 | Batch not found or does not belong to the user's agency |
| 405 | HTTP method is not POST |
| 500 | Failed to update batch status |
Behavior
- Authenticates the user via Supabase JWT and verifies
agency_owneroragency_adminrole. - Validates that the batch exists, belongs to the user's agency, and is not already
completedorcancelled. - Updates all contacts with status
pending,queued, orscheduledtoskippedwithoutcome_notes: 'Batch cancelled'. - Updates the batch: sets
statustocancelled, incrementsskippedcounter, setscompleted_at, and recordserror_message: 'Cancelled by user'. - In-progress calls are not interrupted — they continue and complete normally via the webhook pipeline.
Database Tables
| Table | Operation | Description |
|---|---|---|
users | Read | Fetches user profile to determine agency_id and role |
call_batches | Read/Write | Verifies batch status and updates to cancelled |
campaign_contacts | Read/Write | Marks remaining contacts as skipped |
External APIs
None.
Related Functions
- Pause Call Batch -- Temporarily pause a batch instead of cancelling
- Create Call Batch -- Create a new batch to replace a cancelled one
- Process Call Batches -- Cron processor that skips cancelled batches