Send batch messages

Examples

Let's establish some of our data that will be used in the following examples:

  • Workspace ID: a1405560-c8d3-4b1a-877d-3f449ad95352

  • AccessKey: abcd

  • Channel ID: a1405560-c8d3-4b1a-877d-3f449ad95352

Send batch of messages

In this example, we're sending multiple SMS messages to different receivers using variations of content.

curl -X POST "https://api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/channels/a1405560-c8d3-4b1a-877d-3f449ad95352/batch/messages" \
-H "Content-Type: application/json" \
-H "Authorization: AccessKey abcd" \
-d '{
    "messageRequests": [
        {
            "receiver": {
                "contacts": [
                    {
                        "identifierValue": "channels@messagebird.com"
                    }
                ]
            },
            "body": {
                "type": "text",
                "text": {
                    "text": "Hey, I am a simple text message"
                }
            }
        },
        {
            "receiver": {
                "contacts": [
                    {
                        "identifierValue": "channels+1@messagebird.com"
                    }
                ]
            },
            "template": {
                "projectId": "4b7e08a9-5d0e-4e56-aaf1-cd0bfa29d431",
                "version": "fe72e43f-340e-4d41-9a9e-a136278ebb04",
                "locale": "en"
            }
        },
        {
            "receiver": {
                "contacts": [
                    {
                        "identifierValue": "channels+2@messagebird.com"
                    }
                ]
            },
            "body": {
                "type": "text",
                "text": {
                    "text": "Hey, I am a scheduled message"
                }
            },
            "scheduledFor": "2024-11-26T15:00:00.000Z"
        }
    ]
}'

Batch messages can be monitored using Retrieving messages endpoints by providing the batchID returned in the response. This allows you to check if any messages within the batch failed. Messages with a rejected status will emit events, containing detailed failure codes, enabling you to identify and address issues efficiently. For more details on how to subscribe to these events, refer to the Notifications API documentation.

Last updated