Mailrelay API Reference

Send WhatsApp campaign

POST https://{account}/api/v1/whatsapp/campaigns/{id}/send_all

Authentication

Requires an API key sent in the X-AUTH-TOKEN header.

This method is used to send a WhatsApp campaign to groups or a specific segment. It will return some attributes, including the ID of the WhatsApp sent campaign which can be used to check the progress and results of the WhatsApp campaign.

If you specify a callback URL, we will send a POST request right after the WhatsApp sent campaign is processed. It will contain a JSON with the type of the callback and the ID of the WhatsApp sent campaign.

You can use the following command to simulate a callback request:

curl --request POST \
  --url https://your-callback-domain.com/callback-url \
  --header 'content-type: application/json' \
  --data '{"type":"whatsapp_sent_campaign_finished","id":1}'

Parameters

NameTypeRequiredDescription
id integer Yes ID of the record
target string Yes Allows you to specify to whom this campaign will be sent
group_ids array No Groups IDs. This is required if target is set to groups. It should be an array of group ids. Example: [1, 4, 5]
segment_id integer No Segment id. This is required if target is set to segment
scheduled_at string No Allows you to send campaign later. If you want to send it immediately, do not send this parameter. This parameter should be in UTC timezone with the following format: YYYY-MM-DD HH:MM:SS.
callback_url string No A URL that will be called after the campaign is sent. A POST request will be sent to this URL with a JSON payload containing the ID of the WhatsApp sent campaign.

Responses

StatusDescription
200 Success
400 The request is invalid. Check if the field names in the request and the request data is valid.
422 A validation error occurred. Check the response body for more information.
401 The API key wasn't sent or is invalid
429 Too many requests. You have exceeded the rate limit, wait and try again later.
500 An internal error happened. Try again later.
403 WhatsApp endpoints require the WhatsApp add-on package or a paid plan.

Response fields

NameTypeDescription
id integer ID
whatsapp_campaign_id integer Whatsapp campaign
status string Status
target string Target
scheduled_at string Scheduled at
created_at string Created at
updated_at string Updated at