Create Campaign API

Learn to create email campaigns with API

This API allows you to create and manage email campaigns. This API provides campaign configuration, allowing you to define sender information, content, and audience targeting. With flexible scheduling, you can set campaigns for optimal delivery times and implement frequency capping to avoid over-communicating with your audience. Additionally, the API supports callback integration, providing status updates on campaign creation.

HTTP Method

This API uses the POST method to create new email campaigns.

API Endpoint

The Create Campaign API is available across multiple regions; below are the base URLs for different regions:

Request Headers

Authentication details are required to access the API. Ensure you include the necessary tokens or credentials in your request headers.

Header NameTypeDescriptionExampleRequired?
api-keyStringAPI key for authentication41a1de35948f915f64907ced9eed4f00Yes

Request Body

All necessary parameters should be passed in the request body in JSON format.

Body ParameterData TypeDescriptionRequired?
campaign_detailsArray[Object]Represent each campaign to be created. The channel for which you are trying to create the campaign for.Yes
channelStringThe channel for which the campaign is being created.Yes
campaign_nameStringA unique name for the campaignYes
callback_detailsObjectSpecify callback information.No
bodyArray(Object)Details to be included in the callback body.Yes
headerArray(Object)Headers to be included in the callback request.Yes
frequency_cappingObjectSpecify frequency capping details. This includes enable_frequency_capping. The boolean value indicates if frequency capping is enabled.No
sender_detailsObjectSpecify sender details. this included sender_name and sender_email.Yes
sender_nameName of the sender.Yes
sender_emailEmail of the sender.Yes
audience_detailsObjectSpecify details of the audience to be included or excluded. This includes include_list, exclude_list, seg_ids, list_ids, and udt_id.Yes
exclude_listObjectContains segments or list to be excluded from the campaign.No
include_listObjectContains segments or lists to be included.Yes
limitIntegerSpecify to limit the number of audiece.No
content_detailsObjectSpecify the email content details. This includes: subject_line, template_id, and content_source_url.Yes
template_idIntegerSpecify the template ID used for the campaign content. Yes
Note: You can either opt for template_id or content_source_url.
content_source_urlStringSpecify the url where the content of the campaign is hosted.Yes
Note: You can either opt for template_id or content_source_url
subject_lineStringSpecify the subject line for your campaign.Yes
schedule_timeStringSpecify the time when the campaign should be sent. If scheduling is not required, this can be set to "now". The format should be YYYY-MM-DDTHH:MM:SSZ.Yes
tagsArray(String)Additional tags for tracking .No
campaign_stateStringStatus of the campaign. The available options are draft (campaign is still being configured and not ready to be sent.)and active(campaign is ready to be sent.).Yes

Example Request Body

{
  "campaign_details": [
    {
      "tags": [
        "Tag_Draft"
      ],
      "channel": "email",
      "campaign_name": "Email campaign Name",
      "schedule_time": "",
      "campaign_state": "draft",
      "sender_details": {
        "sender_name": "qa",
        "sender_email": "[email protected]"
      },
      "content_details": {
        "subject_line": "Email Campaign API on POD",
        "content_source_url": "https://colorlib.com/etc/email-template/1/index.html"
      },
      "audience_details": {
        "include_list": {
          "udt_id": 3
        }
      },
      "callback_details": {
        "body": [
          {
            "campaignName": "{{campaign_name}}"
          },
          {
            "campaignId": "{{campaign_id}}"
          },
          {
            "udtId": "{{udtId}}"
          },
          {
            "campaignState": "{{campaign_state}}"
          },
          {
            "campaignTime": "{{schedule_time}}"
          },
          {
            "accountId": "230310111072057"
          },
          {
            "id": "//the comsense segment id passed in the list segment api"
          }
        ],
        "header": [
          {
            "x-api-key": "6523a7e7095bb14"
          }
        ],
        "method": "POST",
        "endpoint": "https://pisense.comsensecloud.com/api/v1/segments/notify"
      },
      "frequency_capping": {
        "enable_frequency_capping": false
      }
    }
  ]
}

Example Response

{
  "data": {
    "id": 80,
    "status": "success",
    "request_id": "3cc4c6b0-13fb-3f51-42b1-5d44c713c4b6",
    "description": "Campaign created successfully with campaign id 80"
  },
  "message": "Campaign created successfully with campaign id 80",
  "statusCode": 200
}
{
  "data": {
    "id": 0,
    "status": "error",
    "request_id": "2a9fae2e-efa1-0626-ca1e-e4fabdea9cb8",
    "description": "Campaign creation failed. 'campaign_state' field is either missing or invalid. Allowed values are 'draft' or 'schedule'."
  },
  "message": "Campaign creation failed. 'campaign_state' field is either missing or invalid. Allowed values are 'draft' or 'schedule'.",
  "statusCode": 600
}

Error Codes

Error CodeDescription
200Successful response. The campaign has been created.
400Invalid request parameters.
500An error occurred on the server side.
600Campaign creation failed. Missing or invalid request.