Sign inGet started

Send batch messages

POST
/workspaces/{workspaceId}/channels/{channelId}/batch/messages
The send batch messages endpoint allows sending a batch up to 100 messages to a channel. The messages are accepted for validation and processed asynchronously. Messages that fail validation are rejected, and the failure is attached to the message. The response will return a batch ID which can be used to retrieve the messages that were in the batch.
请求载荷
messageRequests
array of object
显示子参数
messageRequests.sender
object
显示子参数
messageRequests.sender.connector
object
必填
The sender of the message. For email messages, the sender is used to override the default sender username.
显示子参数
messageRequests.sender.connector.identifierValue
string
必填
The identifier value of the sender.
messageRequests.sender.connector.annotations
object
Annotations are used to add additional information to a message. For email messages, it can be used to specify a custom sender name.
显示子参数
messageRequests.sender.connector.annotations.name
string
messageRequests.receiver
object
必填
显示子参数
messageRequests.receiver.contacts
array of object
显示子参数
messageRequests.receiver.contacts.id
string
The ID of the receiver. This is a reference to a contact.
messageRequests.receiver.contacts.identifierKey
string
The identifier key for finding the contact. For WhatsApp channels with BSUID support, use whatsappbsuid to send to a contact by their Business-Scoped User ID without needing to know the channel's portfolio ID.
messageRequests.receiver.contacts.identifierValue
string
The identifier value for finding the contact.
messageRequests.receiver.contacts.type
string
The type of the receiver.
Possible values: cc, bcc, to
messageRequests.receiver.contacts.identifiers
array of object
显示子参数
messageRequests.receiver.contacts.identifiers.identifierKey
string
必填
The identifier key for finding the contact.
messageRequests.receiver.contacts.identifiers.identifierValue
string
必填
The identifier value for finding the contact.
messageRequests.receiver.contacts.platformAddress
string
The value that is used to send the message to the platform.
messageRequests.receiver.contacts.platformAddressSelector
string
An expression that defines how we resolve the platform address (e.g. phone number or email address) from a contact. This is an optional override for the default resolution logic (i.e. sending to the first identifier key-value pair for the relevant platform).
messageRequests.reference
string
A reference to the message. This can be used to identify the message in the channel.
messageRequests.template
object
必填
显示子参数
messageRequests.template.name
string
The platform name of the template.
messageRequests.template.projectId
string
the ID of the project from the project from Studio
messageRequests.template.version
string
The version of the template.
messageRequests.template.locale
string
messageRequests.template.attachments
array of object
显示子参数
messageRequests.template.attachments.mediaUrl
string
必填
The URL of the attachment.
messageRequests.template.attachments.filename
string
必填
The filename of the attachment.
messageRequests.template.attachments.inline
boolean
messageRequests.template.shortLinks
object
SMS link shortening options.
显示子参数
messageRequests.template.shortLinks.enabled
boolean
Enables link shortening for SMS messages.
messageRequests.template.shortLinks.domain
string
The domain to use when shortening links. When set to default, uses the default link shortening domain for the workspace.
messageRequests.template.variables
object
Deprecated: Use parameters instead (string parameter for variables). This property is maintained for backward compatibility but will be removed in a future version.
显示子参数
messageRequests.template.variables.default
string
messageRequests.template.utmParameters
array of object
The list of UTM parameters.
显示子参数
messageRequests.template.utmParameters.key
string
必填
The name of the parameter in the query string.
messageRequests.template.utmParameters.value
string
必填
The static value of the parameter. Mutually exclusive with Reference.
messageRequests.template.parameters
array of object
显示子参数
messageRequests.template.parameters.type
string
必填
Possible values: string
messageRequests.template.parameters.key
string
必填
messageRequests.template.parameters.value
string
messageRequests.template.settings
object
显示子参数
messageRequests.template.settings.disallowMmLite
boolean
This is specific for WhatsApp marketing templates and requires MM Lite to be disabled for the WABAID.
messageRequests.meta
object
显示子参数
messageRequests.meta.extraInformation
object
Free-form metadata. The useCase key (marketing, otp, transactional, or conversation) classifies the message and affects handling such as routing, frequency capping, email deliverability, and the messaging type/tag used on Meta channels (Messenger, Instagram).
messageRequests.meta.referral
object
显示子参数
messageRequests.meta.referral.source
string
messageRequests.meta.referral.title
string
messageRequests.meta.referral.text
string
messageRequests.meta.referral.group
string
messageRequests.meta.referral.metadata
object
显示子参数
messageRequests.meta.referral.metadata.source_id
string
messageRequests.meta.referral.metadata.source_url
string
messageRequests.meta.referral.metadata.media_url
string
messageRequests.meta.referral.metadata.tracking_id
string
messageRequests.meta.order
object
The order object contains information about the purchase order.
显示子参数
messageRequests.meta.order.products
array of object
显示子参数
messageRequests.meta.order.products.externalCatalogId
string
The platform-specific catalog ID of the product.
messageRequests.meta.order.products.externalProductId
string
The platform-specific product ID.
messageRequests.meta.order.products.quantity
integer
The number of items purchased.
messageRequests.meta.order.products.price
object
The price of the product.
显示子参数
messageRequests.meta.order.products.price.amount
integer
messageRequests.meta.order.products.price.exponent
integer
messageRequests.meta.order.products.price.currencyCode
string
messageRequests.meta.referredProduct
object
Referred product in an incoming message.
显示子参数
messageRequests.meta.referredProduct.externalCatalogId
string
The platform-specific catalog ID of the product.
messageRequests.meta.referredProduct.externalProductId
string
The platform-specific product ID.
messageRequests.meta.email
object
显示子参数
messageRequests.meta.email.subject
string
messageRequests.meta.email.headers
object
messageRequests.meta.email.from
object
显示子参数
messageRequests.meta.email.from.username
string
messageRequests.meta.email.from.displayName
string
messageRequests.meta.sms
object
显示子参数
messageRequests.meta.sms.smartEncoding
boolean
When enabled, attempts to transliterate Unicode characters to GSM-7 equivalents. If the resulting text is fully GSM-7 compatible, fewer message segments may be required. The original message body is preserved; transliteration is only applied when sending.
messageRequests.meta.pushNotifications
object
显示子参数
messageRequests.meta.pushNotifications.gatewayTypeOverride
string
Possible values: apns, firebase, web
messageRequests.meta.navigatorId
string
messageRequests.meta.navigatorMessageId
string
messageRequests.meta.flow
object
显示子参数
messageRequests.meta.flow.id
string
messageRequests.meta.flow.name
string
messageRequests.meta.flow.stepId
string
messageRequests.meta.flow.runId
string
messageRequests.meta.journey
object
显示子参数
messageRequests.meta.journey.id
string
messageRequests.meta.journey.name
string
messageRequests.meta.journey.stepId
string
messageRequests.meta.journey.runId
string
messageRequests.meta.campaign
object
显示子参数
messageRequests.meta.campaign.id
string
messageRequests.meta.campaign.name
string
messageRequests.replyTo
object
显示子参数
messageRequests.replyTo.id
string
必填
The ID of the message that is being replied to.
messageRequests.replyTo.order
integer
The order of the message in the conversation.
messageRequests.replyTo.type
string
必填
Possible values: message, click, referrals
messageRequests.notification
object
显示子参数
messageRequests.notification.url
string
A custom webhook url to send events to. Note: you should have a created webhook subscription. Refer to the Notifications API to learn how to create a webhook subscription.
messageRequests.capFrequency
boolean
If set to true, the frequency capping settings of the platform will be used to either allow or reject the message to a contact. Can only be set to true if the message is sent to a contact and .meta.extraInformation.useCase is marketing.
messageRequests.enableLinkTracking
boolean
If set to true, UTM parameters will be appended to the links in the message. For SMS channels, the shortLinks property must also be included in the request to enable link tracking.
messageRequests.ignoreQuietHours
boolean
If set to true, quiet hours settings will be ignored and the message will be sent as soon as possible.
messageRequests.ignoreGlobalHoldout
boolean
Do not check if the recipient is part of global holdout. To be used to send transactional messages.
messageRequests.tags
array of string
Tags to associate with the message. Tags are converted to lower case and tags that do not exist are automatically created. You can view your created tags in the UI. You can specify up to 10 tags per message.
messageRequests.shortLinks
object
SMS link shortening options. Must be included in the request for SMS channels when enableLinkTracking is set to true. When using templates, please refer to the template level shortLinks instead.
显示子参数
messageRequests.shortLinks.domain
string
必填
The domain to use when shortening links. When set to default, uses the default link shortening domain for the workspace.
messageRequests.scheduledFor
string
Scheduled time to send message at. Must be formated as RFC3339 timestamp. When set, the message status will be scheduled until it's sent. Messages scheduled for a time in the past or within 10 minutes of the request may be sent immediately. Messages scheduled farther than 35 days will be rejected.
messageRequests.validity
integer
Validity determines for how many seconds a message is valid. If none is provided, the channel message type will be used to determine it. A promotional, conversational or transactional channel message is valid for 36 hours (129600 seconds). A message sent from a 2FA channel is valid for 10 minutes (600 seconds).
响应载荷
id
string
必填
The ID of the batch.
messages
array of object
必填
显示子属性
messages.id
string
The ID of the message.
代码示例
curl -X POST 'https://api.bird.com/workspaces/{workspaceId}/channels/{channelId}/batch/messages' \
  -H 'Authorization: AccessKey YOUR_ACCESS_KEY'

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.