Skip to main content

Endpoint

POST https://api.graine.ai/api/v1/batches/{batch_id}/dispatch Forces a re-run of execute_batch. This re-publishes every PENDING contact in the batch to the apollo.batch.dispatch Kafka topic.

When to Use This

Use /dispatch when:
  • The worker container was down at the time the batch was created — calls never went out because nobody was consuming Kafka
  • A batch shows PENDING contacts with stale timestamps and the debug endpoint confirms the worker is stuck
  • You want to manually re-trigger dispatch after a worker restart
This endpoint only re-publishes PENDING contacts. Contacts already dispatched, completed, failed, etc. are not affected.

Path Parameters

ParameterTypeRequiredDescription
batch_idstringYesBatch to re-dispatch

Headers

HeaderRequiredDescription
AuthorizationYesBearer gat_<token>

Example Request

curl -X POST "https://api.graine.ai/api/v1/batches/btc_xyz001/dispatch" \
  -H "Authorization: Bearer gat_your_token"

Response

200 OK

{
  "batch_id": "btc_xyz001",
  "status": "in_progress",
  "dispatched_count": 22,
  "message": "Batch dispatch re-triggered successfully"
}

Typical Recovery Flow

If a batch created successfully but calls never went out:
1

Check Debug Endpoint

GET /batches/{id}/debug — look for diagnostics.stuck_pending: true
2

Restart Worker

Restart the Apollo worker container so it reconnects to Kafka
3

Force Dispatch

POST /batches/{id}/dispatch to re-publish pending contacts
4

Monitor

Poll GET /batches/{id} and watch counters.dispatched increase

Next Steps

Debug Batch

Diagnose why calls aren’t going out

Monitor Contacts

Track per-contact status