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 Name | Type | Description | Example | Required? |
---|---|---|---|---|
api-key | String | API key for authentication | 41a1de35948f915f64907ced9eed4f00 | Yes |
Request Body
All necessary parameters should be passed in the request body in JSON format.
Body Parameter | Data Type | Description | Required? |
---|---|---|---|
campaign_details | Array[Object] | Represent each campaign to be created. The channel for which you are trying to create the campaign for. | Yes |
channel | String | The channel for which the campaign is being created. | Yes |
campaign_name | String | A unique name for the campaign | Yes |
callback_details | Object | Specify callback information. | No |
body | Array(Object) | Details to be included in the callback body. | Yes |
header | Array(Object) | Headers to be included in the callback request. | Yes |
frequency_capping | Object | Specify frequency capping details. This includes enable_frequency_capping. The boolean value indicates if frequency capping is enabled. | No |
sender_details | Object | Specify sender details. this included sender_name and sender_email . | Yes |
sender_name | Name of the sender. | Yes | |
sender_email | Email of the sender. | Yes | |
audience_details | Object | Specify details of the audience to be included or excluded. This includes include_list , exclude_list , seg_ids , list_ids , and udt_id . | Yes |
exclude_list | Object | Contains segments or list to be excluded from the campaign. | No |
include_list | Object | Contains segments or lists to be included. | Yes |
limit | Integer | Specify to limit the number of audiece. | No |
content_details | Object | Specify the email content details. This includes: subject_line , template_id , and content_source_url . | Yes |
template_id | Integer | Specify the template ID used for the campaign content. | Yes Note: You can either opt for template_id or content_source_url. |
content_source_url | String | Specify the url where the content of the campaign is hosted. | Yes Note: You can either opt for template_id or content_source_url |
subject_line | String | Specify the subject line for your campaign. | Yes |
schedule_time | String | Specify 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 |
tags | Array(String) | Additional tags for tracking . | No |
campaign_state | String | Status 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 Code | Description |
---|---|
200 | Successful response. The campaign has been created. |
400 | Invalid request parameters. |
500 | An error occurred on the server side. |
600 | Campaign creation failed. Missing or invalid request. |
Updated about 1 month ago