Create campaign (admin)
This method creates a campaign for any brand in the account, and can also send or schedule it. It takes the same parameters as Create campaign, plus brand_id for drafts and json to get the new draft's id.
URL
https://dashboard.skry.be/api/admin/campaigns/create.php
PARAMETERS(POST)
api_keythe main account's API key. Brand keys are rejected withInvalid API key.from_namethe 'From name' of your campaignfrom_emailthe 'From email' of your campaign. When the campaign is sent or scheduled, its domain must be one of the brand's allowed sending domains.reply_tothe 'Reply to' of your campaigntitlethe 'Title' of your campaign (optional)subjectthe 'Subject' of your campaignplain_textthe 'Plain text version' of your campaign (optional)html_textthe 'HTML version' of your campaignlist_idsrequired only if you setsend_campaignto 1 and pass nosegment_ids. Encrypted list ids, single or comma-separated.segment_idsrequired only if you setsend_campaignto 1 and pass nolist_ids. Segment ids, single or comma-separated.exclude_list_idslists to exclude, single or comma-separated (optional)exclude_segments_idssegments to exclude, single or comma-separated (optional)brand_idthe numeric id of the brand, as returned by Get brands (admin). Required whensend_campaignis 0 (including when scheduling). When the campaign is sent or scheduled, the brand is taken from its lists and segments, which must all belong to one brand.query_stringeg. Google Analytics tags (optional)track_opens0 to disable, 1 to enable, 2 for anonymous opens tracking. Default is 1. (optional)track_clicks0 to disable, 1 to enable, 2 for anonymous clicks tracking. Default is 1. (optional)send_campaignset to 1 to send the campaign now rather than just creating a draft. Default is 0. (optional)schedule_date_timeschedules the campaign for this date and time, eg.June 15, 2021 6:05pm. (optional)schedule_timezonethe timezone ofschedule_date_time, eg.America/New_York. Defaults to the main account's timezone. (optional)jsonset to 1 to get a JSON response with the new campaign's id. Only applies to drafts. (optional)
RESPONSE (Plain text)
Success: Campaign created
Success (draft with json=1): {"status":"Campaign created", "campaign_id": "123"}
Success: Campaign created and now sending
Success: Campaign scheduled
Error: No data passed
Error: API key not passed
Error: Invalid API key
Error: From name not passed
Error: From email not passed
Error: Reply to email not passed
Error: Subject not passed
Error: HTML not passed
Error: List or segment ID(s) not passed
Error: Brand ID not passed.
Error: One or more list IDs are invalid
Error: One or more segment IDs are invalid
Error: List or segment IDs does not belong to a single brand
Error: Unauthorised From email domain
Error: schedule_date_time is invalid
Error: Unable to calculate totals
Error: Unable to create campaign
Error: Unable to create and send campaign
Error: Unable to schedule campaign
Brand ID not passed. ends with a full stop on this endpoint. Drafts are not checked against the brand's allowed sending domains; sends and schedules are.
EXAMPLES
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("api_key", "<MAIN_ACCOUNT_API_KEY>");
urlencoded.append("brand_id", "<BRAND_ID>");
urlencoded.append("from_name", "Acme");
urlencoded.append("from_email", "news@acme.com");
urlencoded.append("reply_to", "hello@acme.com");
urlencoded.append("title", "May newsletter");
urlencoded.append("subject", "What's new in May");
urlencoded.append("html_text", "<html><body><h1>Hello</h1></body></html>");
urlencoded.append("json", "1");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://dashboard.skry.be/api/admin/campaigns/create.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': '<MAIN_ACCOUNT_API_KEY>',
'brand_id': '<BRAND_ID>',
'from_name': 'Acme',
'from_email': 'news@acme.com',
'reply_to': 'hello@acme.com',
'title': 'May newsletter',
'subject': 'What\'s new in May',
'html_text': '<html><body><h1>Hello</h1></body></html>',
'json': '1'
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://dashboard.skry.be/api/admin/campaigns/create.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);
});