Send a campaign
This method sends an existing draft to the lists and/or segments you choose, like Send now in the dashboard. The campaign is marked as sending straight away and delivery starts on the next run of the sending job. The campaign and every list and segment must belong to the brand your API key belongs to.
It's safe to retry: only a draft can be sent, so repeating a request that already went through returns Campaign has already been sent instead of sending twice.
Before anything is sent, Skrybe checks that the campaign's From email domain is allowed for the brand and verified, that the brand isn't under review, that there is at least one active subscriber to send to, and that the send fits in the brand's sending quota. Use dry_run to run all of these checks and get the recipient count without sending.
URL
https://dashboard.skry.be/api/campaigns/send.php
PARAMETERS(POST)
api_keyyour API key.campaign_idthe ID of the draft to send.list_idsencrypted list IDs, single or comma-separated, as Get lists returns them. Required unlesssegment_idsis passed.segment_idssegment IDs (whole numbers), single or comma-separated. Required unlesslist_idsis passed.exclude_list_idsencrypted list IDs to exclude, single or comma-separated. (optional)exclude_segment_idssegment IDs to exclude, single or comma-separated. (optional)dry_runset to1,yesortrueto run every check and count the recipients without sending. (optional)
Recipients are the unique, active (subscribed, confirmed, not bounced, not complained) subscribers in the chosen lists and segments, minus anyone in the excluded ones. If the brand sends to GDPR-consenting subscribers only, only those are counted.
RESPONSE (JSON)
On success you get a JSON object. recipients is the number of emails that will be sent. Errors are returned as plain text. Every response is returned with HTTP status 200.
{"status":"sending","campaign_id":1234,"recipients":5120}
With dry_run:
{"status":"dry_run","campaign_id":1234,"recipients":5120}
Error: No data passed
Error: API key not passed
Error: Invalid API key
Error: Campaign ID not passed
Error: List or segment ID(s) not passed
Error: Brand does not exist
Error: Campaign does not exist (also returned for a campaign in another brand)
Error: Campaign is scheduled (use Unschedule first, or let it send at its scheduled time)
Error: Campaign has already been sent (the campaign isn't a draft)
Error: One or more list IDs are invalid (also returned for an invalid exclude_list_ids entry)
Error: One or more segment IDs are invalid (also returned for an invalid exclude_segment_ids entry)
Error: Unauthorised From email domain
Error: Domain "<domain>" is not verified in SES. Full domain verification is required to send emails.
Error: Account under review: <reason>. Sending is disabled.
Error: Unable to count recipients
Error: No active subscribers to send to
Error: Error: This campaign would exceed your monthly sending allowance. Reduce the recipients, or renew your plan to send more.
Error: Error: This campaign would exceed your sending quota. Reduce the recipients or increase your quota, then try again.
Error: Unable to send campaign
EXAMPLES
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("api_key", "<YOUR_API_KEY>");
urlencoded.append("campaign_id", "1234");
urlencoded.append("list_ids", "<YOUR_LIST_ID>");
urlencoded.append("exclude_list_ids", "<LIST_ID_TO_EXCLUDE>");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://dashboard.skry.be/api/campaigns/send.php", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
const axios = require('axios');
const qs = require('qs');
let data = qs.stringify({
'api_key': '<YOUR_API_KEY>',
'campaign_id': '1234',
'list_ids': '<YOUR_LIST_ID>',
'exclude_list_ids': '<LIST_ID_TO_EXCLUDE>'
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://dashboard.skry.be/api/campaigns/send.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});