Mailrelay API Reference

Send a campaign

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

Authentication

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

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

If you specify a callback URL, we will send a POST request right after the sent campaign is processed. It will contain a JSON with the type of the callback and the ID of the 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":"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 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, is invalid or has expired
403 The API key or its user doesn't have permission to use this endpoint, or the request comes from an IP address the key doesn't allow.
429 Too many requests. You have exceeded the rate limit, wait and try again later.
500 An internal error happened. Try again later.

Response fields

NameTypeDescription
id integer ID
subject string Subject
sender_id integer Sender
html string HTML
status string Status
scheduled_at string Scheduled at
created_at string Created at
updated_at string Updated at
callback_url string Callback url