Create a regular email campaign
POST /campaigns
/campaignsCreates a regular email campaign as a draft: sender, subject, content, recipients and tracking are saved, but nothing is sent. The campaign stays a draft until someone sends or schedules it. To be valid it needs a title, an audience, who it goes to (send_to, with groups, contact_segment or filter when needed), email_config (from name, subject, and sender and reply-to unless the audience has defaults), campaign_config and the content (template, template_html or template_simple_json_code).
When to use: To prepare a one-off email for an audience, some of its groups, a contact segment or a filter of its own. Afterwards check it with get_campaign (recipient_count), send yourself a preview with campaign_send_test, and then send it (campaign_send_now) or schedule it (campaign_schedule).
When not to use: For an A/B test use create_campaign_test_ab_subject, create_campaign_test_ab_sender or create_campaign_test_ab_template. To ask inactive subscribers to confirm they want to stay, use create_campaign_revalidation. To send a survey, use create_campaign_survey. To start from an existing campaign, use duplicate_campaign. For text messages, use create_sms_campaign.
Side effects: Nothing is sent to anyone. If you send template_html or template_simple_json_code, a new template is created in your account; the campaign thumbnail is generated in the background. With contact_segment, a draft follows the current revision of the segment until it is scheduled or sent; then that revision is fixed.
Permissions: Requires the author role or higher, or the marketing.campaigns.write capability. Choosing contact_segment or filter also requires the contacts.read capability.
Value for the X-Auth-Token header parameter.
In: header
The new Campaign resource
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/problem+json
application/problem+json
application/problem+json
application/problem+json
curl -X POST "https://api.easymailing.com/campaigns" \ -H "X-Auth-Token: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "template_html": "string", "template_simple_json_code": {}, "email_config": { "from_name": "string", "from_email": "/entity/1", "reply_to": "/entity/1", "enable_to_name": true, "to_name": "string", "subject": "string", "preview_text": "string" }, "campaign_config": { "track_opens": true, "track_clicks": true, "track_ecommerce": true, "use_conversations": true, "public": true, "track_google_analytics": true, "google_analytics_tag": "string" }, "template": "/entity/1", "title": "string", "send_to": "send_to_all", "audience": "string", "list_segment": "/entity/1", "groups": [ "string" ], "contact_segment": "/entity/1", "filter": { "match": "all", "conditions": [ { "field": "string", "operator": "string", "value": null, "audience": "0ff0092a-9631-4ad5-a4dd-fe4329a52f3b", "match": "all", "conditions": [ {} ] } ] } }'{ "template_thumbnail": "http://example.com", "email_config": { "from_name": "string", "from_email": "/entity/1", "reply_to": "/entity/1", "enable_to_name": true, "to_name": "string", "subject": "string", "preview_text": "string" }, "campaign_config": { "track_opens": true, "track_clicks": true, "track_ecommerce": true, "use_conversations": true, "public": true, "track_google_analytics": true, "google_analytics_tag": "string" }, "campaign_config_send": { "schedule_mailing": true, "schedule_mailing_date": "2019-08-24T14:15:22Z", "send_confirmation_email": true, "mailing_confirm_emails": [ "user@example.com" ] }, "campaign_stats": { "sent": 0, "delivered": 0, "clicks": 0, "unique_clicks": 0, "opens": 0, "unique_opens": 0, "complaints": 0, "soft_bounces": 0, "hard_bounces": 0, "unsubscriptions": 0, "delivered_rate": 0, "open_rate": 0, "click_rate": 0, "bounce_rate": 0, "complaint_rate": 0, "score": 0, "ctor": 0, "unsuscribe_rate": 0, "cleaned": 0, "to_send": 0, "revenue": 0, "orders": 0, "order_rate": 0 }, "test_config": { "type": "string", "test_size": 0, "winner_metric": "string", "delay_value": 0, "delay_unit": "string" }, "variants": [ { "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f", "subject": "string", "preview_text": "string", "from_name": "string", "from_email": "/entity/1", "template": "/entity/1", "template_thumbnail": "string", "sort": 0, "delivered": 0, "opens": 0, "clicks": 0, "open_rate": 0, "click_rate": 0, "winner": true } ], "template": "/entity/1", "id": 0, "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f", "title": "string", "status": "campaign.status.draft", "type": "campaign.regular", "channel": "email", "send_to": "string", "audience": "string", "list_segment": "/entity/1", "groups": [ "string" ], "hash": "string", "created_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z", "started_at": "2019-08-24T14:15:22Z", "finished_at": "2019-08-24T14:15:22Z", "contact_targeting": { "kind": "segment", "contact_segment": "/entity/1", "contact_segment_name": "string", "contact_segment_deleted": true, "revision_status": "following_latest", "pinned_at": "2019-08-24T14:15:22Z", "error_code": "string", "filter": { "match": "all", "conditions": [ { "field": "string", "operator": "string", "value": null, "audience": "0ff0092a-9631-4ad5-a4dd-fe4329a52f3b", "match": "all", "conditions": [ {} ] } ] } }}