Skip to content

Create a campaign

Use this API method to create a new campaign from scratch. Specify the group or segment IDs that this campaign will be sent to.
You can use API to provide plain text or a custom HTML campaign content. For drag&drop templates, you must create its content in your Sender application interface.

HTTP method: POST

https://api.sender.net/v2/campaigns


ParameterTypeDescription
titlestringName of the campaign (shown in reports, optional)
subjectstring requiredChoose the subject of the campaign.
fromstring requiredSender name to be shown to subscribers.
preheaderstringEmail preview text.
reply_tostring requiredEmail that will be shown as the sender. This email must belong to a valid, verified domain in your account.
content_typestring requiredThe value must be one of “editor”, “html”, or “text”.
google_analyticsnumericEnable or disable Google Analytics tracking for the links in this campaign. Choose from 1 for true and 0 for false.
auto_followup_subjectstringProvide the auto follow up subject
auto_followup_delaynumericHours before automatic followup. The value must be one of 12, 24, 48, 72, 96, 120, 144, or 168.
auto_followup_activebooleanIf 1 - automatic followup campaign will be sent to those subscribers who did not open.
groupsarrayProvide the groups ids that would be added to the campaign. For more than 1 use comma to separate each group.
segmentsarrayArray of segment IDs that this campaign will be sent to.
contentstringProvide the content of your campaign. Only plain text and html options are available for providing campaign content using the API. For drag&drop builder you need to use the interface.

const url = new URL("https://api.sender.net/v2/campaigns");
let headers = {
"Authorization": "Bearer [your-token]",
"Content-Type": "application/json",
"Accept": "application/json",
};
let bodyContent = {
"title": "Example campaign",
"subject": "Example campaign subject",
"from": "Sender support",
"reply_to": "[email protected]",
"preheader": "Preview text of my campaign",
"content_type": "text",
"google_analytics": 1,
"auto_followup_subject": "Example follow up subject",
"auto_followup_delay": 72,
"auto_followup_active": true,
"groups": ["eZVD4w", "dN9n8z"],
"segments": ["elY9Ma"],
"content": "Adding the first content of my campaign"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(bodyContent)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Example Response
{
"success": true,
"message": "Campaign created",
"data": {
"id": "e1VMRZ",
"subject": "Example campaign subject",
"reply_to": "[email protected]",
"language": "eng",
"recipient_count": null,
"from": "Sender support",
"schedule_time": null,
"last_action": "api",
"sent_time": null,
"status": "DRAFT",
"created": "2022-06-06 05:59:50",
"modified": "2022-06-06 05:59:50",
"title": "Example campaign",
"domain_id": "bDPoxb",
"preheader": "Preview text of my campaign",
"auto_followup_active": true,
"auto_followup_subject": "Example follow up subject",
"auto_followup_delay": 72,
"editor": "text",
"opens": 0,
"clicks": 0,
"bounces_count": 0,
"send_to_all": null,
"html": {
"id": "azxXQq",
"thumbnail_url": "https://cdn.sender.net/email_images/9918/886278/html_l5fbNNTWji6R.png?timestamp=1654509593",
"has_preview": true,
"html_content": "Adding the first content of my campaign",
"html_body": null
},
"sent_count": 0,
"campaign_groups": [
"eZVD4w",
"dN9n8z"
],
"segments": [
"elY9Ma"
]
}
}