What you’ll build
- Create the job.
- Ingest recipients, in as many calls as you need.
- Run the job once everyone is in.
- Poll for progress.
Prerequisites
- A published template, or an event ID mapped to one
- Your deduplicated recipient list, with an email or phone for each
- A Courier API key
Run a bulk job
Create the job with the notification and any shared data, ingest recipients into it, then run it once and poll for progress. Ingestion is open-ended and the job doesn’t expire while you fill it. A job runs once, and you can’t recall it after you run it.1
Create the job
POST /bulk defines the job with an event and any global data that applies to everyone. The required event is either a notification ID or a custom event ID mapped to a notification.201 Created with the job ID you use for every call that follows:brand, locale, and override. To send something other than the notification attached to the event, add template. event stays required.2
Ingest your recipients
POST /bulk/{job_id} adds recipients to the job. Identify each one in to, and put their personal variables in data, which merges into the job’s global message.data.200 OK, where total is the running count for the whole job rather than the current call:profile.email, not to.email. Put each recipient’s address in profile.email so the job delivers to it.Each recipient accepts four fields:to.user_id, who they areprofile, inline contact datadata, per-recipient variablespreferences, per-recipient overrides
502 instead of a validation error.3
Run the job
Once everyone is in, Returns
POST /bulk/{job_id}/run triggers the send. Courier fans out and delivers to each recipient.202 Accepted with an empty body, and the job starts processing in the background. Running it again returns 400 BulkJobDuplicateInvocationError, so create a new job to reach more recipients.4
Track progress
GET /bulk/{job_id} returns the job’s counts and overall status.received: recipients ingested.enqueued: messages that reached the delivery pipeline.failures: errors hit while processing.status:CREATED,PROCESSING,COMPLETED, orERROR.COMPLETEDandERRORare both terminal, so stop polling on either one.
Verify
1
Confirm the counts line up
Poll the job until it reaches
COMPLETED, then check that enqueued matches received and failures is zero.2
Spot-check a recipient
GET /bulk/{job_id}/users pages through the job’s recipients. Leave cursor off the first request, then keep passing paging.cursor back while paging.more is true.status of PENDING, ENQUEUED, or ERROR, and a messageId once enqueued:3
Trace one message end to end
A
messageId is the same ID a regular send returns, so look one up in message logs and confirm it delivered.message:updated, which fires on every status change for every message the job produced.