How To Send Bulk Notifications
Learn how to incrementally build a notification that goes out to a very large number of users and then execute the send with a single API call.
The Bulk API makes it possible to incrementally build a notification that goes out to a very large number of users and then execute the send with a single API call. While the Send API can be used to deliver messages to multiple recipients, the Bulk API provides more tools to examine the progress of the job as it executes.
Like sending a single message, the Bulk API can used across channels (eg. email, SMS, chat, in-app inbox, push) and providers (eg. Twilio, Sendgrid, etc).
Create a Bulk Job
Bulk jobs must first be defined. The structure of a job mimics the set of available configuration values for sending an individual message.
Request:
All bulk endpoints also support idempotent requests using the Idempotency-Key
header.
Response:
Ingest Users to the Bulk Job
Using the job ID, multiple users can be ingested into the job.
The ingestion does not have to happen in a single call, you could have multiple ingestion invocations as long as job is not triggered. The bulk job will not expire until it is invoked.
Request:
Response with errors:
Executing the Job
Once you have added the users to your job, it can be triggered by calling the /run
endpoint with the jobId
.
A jobId
can only be triggered once. If you wish to send messages to more users after the job was triggered, you’ll have to create a new job definition and add the remaining users to the new job.
Request:
Response:
Fetching Bulk Job Information
Job Status
The jobId
can be used to track the status of the individual messages in the bulk job. You should expect the status as you see in the GET /messages
endpoint which includes delivery statistics like sent
, delivered
, clicked
and more.
Job Items/Users
Message Information
The messageId
from each item is the same as you get from looking up an individual message from /send
requests. Messages are visible on the Courier Logs or can be fetched via Messages API as expected. If you have Outbound Webhooks configured, Courier will invoke it with the message data throughout the lifecycle of the message.