Resume Call Batch
Resumes a paused batch. The batch will be picked up by the calls-batch-process cron function on its next run. If the batch has a future scheduled_for time, it resumes to scheduled status; otherwise it resumes to processing.
Endpoint
| Property | Value |
|---|---|
| Function Name | calls-batch-resume |
| 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 resume |
Response
Success (200)
{
"success": true,
"batch_id": "uuid",
"status": "processing",
"message": "Batch resumed. The processor will start making calls on the next run."
}
If the batch has a future scheduled_for:
{
"success": true,
"batch_id": "uuid",
"status": "scheduled",
"message": "Batch scheduled to resume at 2025-01-16T09:00:00Z"
}
Error Responses
| Status | Condition |
|---|---|
| 400 | batch_id is missing |
| 400 | Batch is not paused (only paused batches can be resumed) |
| 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 has a status of
paused. - Determines the resume status:
- If
scheduled_foris in the future → resumes toscheduled. - Otherwise → resumes to
processing.
- If
- Clears the
paused_attimestamp. - Uses an optimistic concurrency check: the update includes a
status = 'paused'filter.
Database Tables
| Table | Operation | Description |
|---|---|---|
users | Read | Fetches user profile to determine agency_id and role |
call_batches | Read/Write | Verifies batch is paused and updates to processing or scheduled |
External APIs
None.
Related Functions
- Pause Call Batch -- Pause a processing batch
- Process Call Batches -- Cron processor that picks up resumed batches
- Cancel Call Batch -- Cancel a batch entirely