Skip to main content

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

PropertyValue
Function Namecalls-batch-resume
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 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

StatusCondition
400batch_id is missing
400Batch is not paused (only paused batches can be resumed)
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 has a status of paused.
  • Determines the resume status:
    • If scheduled_for is in the future → resumes to scheduled.
    • Otherwise → resumes to processing.
  • Clears the paused_at timestamp.
  • Uses an optimistic concurrency check: the update includes a status = 'paused' filter.

Database Tables

TableOperationDescription
usersReadFetches user profile to determine agency_id and role
call_batchesRead/WriteVerifies batch is paused and updates to processing or scheduled

External APIs

None.