Skip to main content

Overview

Batches can be controlled independently of their parent campaign. This is useful when you have multiple batches under one campaign and want to pause just one.

Pause Batch

POST https://api.graine.ai/api/v1/batches/{batch_id}/pause Sets a Redis pause flag that stops the Kafka consumer from dispatching new contacts. In-flight calls complete naturally.

What happens internally

  • batch.statuspaused
  • Redis pause flag set for this batch ID
  • Kafka consumer skips this batch’s pending contacts
  • Scheduled retry / follow-up jobs are preserved

Example Request

Response 200 OK


Resume Batch

POST https://api.graine.ai/api/v1/batches/{batch_id}/resume Clears the Redis pause flag and re-triggers execute_batch to dispatch remaining PENDING contacts.

What happens internally

  • batch.statusin_progress
  • Redis pause flag cleared
  • execute_batch re-invoked — publishes all PENDING contacts to the dispatch Kafka topic

Example Request

Response 200 OK


Cancel Batch

POST https://api.graine.ai/api/v1/batches/{batch_id}/cancel Hard-stops a batch. This is terminal — a cancelled batch cannot be resumed.
Cancellation is irreversible. Any contacts in PENDING, DISPATCHED, RETRYING, or FOLLOWUP_SCHEDULED states will be marked SKIPPED and will never be called.

What happens internally

  1. batch.statusCANCELLED
  2. Redis cancel flag set for the batch
  3. All PENDING, DISPATCHED, RETRYING, and FOLLOWUP_SCHEDULED contacts → SKIPPED
  4. All APScheduler retry / follow-up jobs for this batch removed from Postgres
Calls already accepted by the telephony router finish naturally.

Example Request

Response 200 OK


Pause vs Cancel — Which to Use?

Next Steps

Force Dispatch

Manually re-trigger call dispatch

Debug Batch

Diagnose stuck or slow batches