Skip to main content

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

PropertyValue
Function Namecalls-batch-cancel
HTTP MethodPOST
AuthenticationSupabase JWT (Bearer token)
Required Roleagency_owner or agency_admin

Request

Headers

Authorization: Bearer <supabase_jwt_token>
Content-Type: application/json

Body

FieldTypeRequiredDescription
batch_idstring (UUID)YesThe 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

StatusCondition
400batch_id is missing
400Batch is already completed or cancelled
401Missing or invalid authorization header
403User is not associated with an agency
403User role is not agency_owner or agency_admin
404Batch not found or does not belong to the user's agency
405HTTP method is not POST
500Failed to update batch status

Behavior

  • Authenticates the user via Supabase JWT and verifies agency_owner or agency_admin role.
  • Validates that the batch exists, belongs to the user's agency, and is not already completed or cancelled.
  • Updates all contacts with status pending, queued, or scheduled to skipped with outcome_notes: 'Batch cancelled'.
  • Updates the batch: sets status to cancelled, increments skipped counter, sets completed_at, and records error_message: 'Cancelled by user'.
  • In-progress calls are not interrupted — they continue and complete normally via the webhook pipeline.

Database Tables

TableOperationDescription
usersReadFetches user profile to determine agency_id and role
call_batchesRead/WriteVerifies batch status and updates to cancelled
campaign_contactsRead/WriteMarks remaining contacts as skipped

External APIs

None.