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.
Endpoint
Section titled “Endpoint”HTTP method: POST
https://api.sender.net/v2/campaigns
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
title | string | Name of the campaign (shown in reports, optional) |
subject | string required | Choose the subject of the campaign. |
from | string required | Sender name to be shown to subscribers. |
preheader | string | Email preview text. |
reply_to | string required | Email that will be shown as the sender. This email must belong to a valid, verified domain in your account. |
content_type | string required | The value must be one of “editor”, “html”, or “text”. |
google_analytics | numeric | Enable or disable Google Analytics tracking for the links in this campaign. Choose from 1 for true and 0 for false. |
auto_followup_subject | string | Provide the auto follow up subject |
auto_followup_delay | numeric | Hours before automatic followup. The value must be one of 12, 24, 48, 72, 96, 120, 144, or 168. |
auto_followup_active | boolean | If 1 - automatic followup campaign will be sent to those subscribers who did not open. |
groups | array | Provide the groups ids that would be added to the campaign. For more than 1 use comma to separate each group. |
segments | array | Array of segment IDs that this campaign will be sent to. |
content | string | Provide 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. |
Request Examples
Section titled “Request Examples”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", "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));$client = new \GuzzleHttp\Client();
$json = [ "title" => "Example campaign", "subject" => "Example campaign subject", "from" => "Sender support", "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"];
$response = $client->post( 'https://api.sender.net/v2/campaigns', [ 'headers' => [ 'Authorization' => 'Bearer [your-token]', 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'json' => $json ]);
$body = $response->getBody()->getContents();$data = json_decode($body, true);print_r($data);import requestsimport json
url = "https://api.sender.net/v2/campaigns"
headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",}
payload = { "title": "Example campaign", "subject": "Example campaign subject", "from": "Sender support", "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"}
response = requests.request('POST', url, headers=headers, json=payload)
print(response.json())curl -X POST \"https://api.sender.net/v2/campaigns" \-H "Authorization: Bearer [your-token]" \-H "Content-Type: application/json" \-H "Accept: application/json" \-d '{"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"}'Response
Section titled “Response”{ "success": true, "message": "Campaign created", "data": { "id": "e1VMRZ", "subject": "Example campaign subject", "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" ] }}