Campaign Templates API
- Table of Contents
- Overview
- Campaign Template Attributes
- Get a List of Campaign Templates
- Get Campaign Template Details
- Create a New Campaign Template
- Update an Existing Campaign Template
Overview
This API provides a way to manage your Campaign Templates.
Campaign Template Attributes
id
integer /read-only |
An automatically generated unique identifier for this template. |
||||||||||||||||||||||||||||||||||||||||||||||
name
string |
The name of the campaign template. |
||||||||||||||||||||||||||||||||||||||||||||||
mailing_list_id
integer |
The id of the mailing list to which this template belongs. |
||||||||||||||||||||||||||||||||||||||||||||||
mailing_list_name
string |
The name of the mailing list to which this template belongs. |
||||||||||||||||||||||||||||||||||||||||||||||
content_subject
string |
Deprecated: The subject of the email.
|
||||||||||||||||||||||||||||||||||||||||||||||
email_format
string |
Deprecated: Email format to use when delivering a campaign from this template.
|
||||||||||||||||||||||||||||||||||||||||||||||
content_html
string |
Deprecated: If format is
|
||||||||||||||||||||||||||||||||||||||||||||||
content_text
string |
Deprecated: If format is
|
||||||||||||||||||||||||||||||||||||||||||||||
segmentation_criteria_id
integer |
The id of the segment to use when delivering a campaign from this template. |
||||||||||||||||||||||||||||||||||||||||||||||
segmentation_criteria_name
string |
The name of the segment, if it is a stored segment. |
||||||||||||||||||||||||||||||||||||||||||||||
segmentation_criteria_remote_sql
string |
The SQL to use when querying the remote database for a campaign from this template. This only applies to Remote Lists. |
||||||||||||||||||||||||||||||||||||||||||||||
contents
array of hashes
|
|||||||||||||||||||||||||||||||||||||||||||||||
dispatch_attributes
array of hashes Inline object containing delivery settings of the Template; Comes from the server only if delivery settings of the Template are defined. This key is named
|
Get a List of Campaign Templates
Campaign Templates on a mailing list:
GET /ga/api/v2/mailing_lists/:mailing_list_id/templates
Campaign Templates on the current user’s organization:
GET /ga/api/v2/templates
Response
The response will be a JSON array where each element contains the following keys.
id
integer /read-only |
An automatically generated unique identifier for this template. |
name
string |
The name of the Campaign |
mailing_list_id
integer |
The id of the mailing list to which this template belongs. |
mailing_list_name
string |
The name of the mailing list to which this template belongs. |
Example
GET /ga/api/v2/mailing_lists/9/templates
HTTP/1.1 200 OK
{
"success": true,
"data": [
{
"id": 40,
"mailing_list_id": 9,
"name": "Daily Update Template",
"organization_id": 8,
"segmentation_criteria_id": null,
"mailing_list_name": "Monthly Subscribers"
},
{
"id": 41,
"mailing_list_id": 9,
"name": "Monthly Update Template",
"organization_id": 8,
"segmentation_criteria_id": null,
"mailing_list_name": "Monthly Subscribers"
},
{
"id": 42,
"mailing_list_id": 9,
"name": "Random Update Template",
"organization_id": 8,
"segmentation_criteria_id": null,
"mailing_list_name": "Monthly Subscribers"
}
],
"error_code": null,
"error_message": null
}
Get Campaign Template Details
GET /ga/api/v2/templates/:template_id
Response
The response will contain details defined in the Campaign Template Attributes section of this document.
Example
GET /ga/api/v2/templates/46
HTTP/1.1 200 OK
{
"success": true,
"data": {
"archived": false,
"content_determined": false,
"created_at": "2017-05-09T19:21:23Z",
"custom_dynamic_template_id": null,
"id": 46,
"mailing_list_id": 10,
"name": "Daily Update Template",
"organization_id": 9,
"segmentation_criteria_id": null,
"template": true,
"updated_at": "2017-05-09T19:21:23Z",
"mailing_list_name": "Monthly Subscribers",
"organization_name": "News Co",
"stat_summary": null,
"content_stats": [
],
"automatic_winner_selection": null,
"campaign_contents": [
]
},
"error_code": null,
"error_message": null
}
Create a New Campaign Template
POST /ga/api/v2/mailing_lists/:mailing_list_id/templates
Payload
The POST request should have a JSON document in its payload with at least keys that marked with bold in the following list:
campaign
hash /required |
The content of this hash is described in the Campaign Template Attributes section of this page. The data may contain a mixture of required and optional fields. Do not specify read-only fields. |
Response
A successful response will return the template record using the format described in the Campaign Template Attributes section of the API.
Example
POST /ga/api/v2/mailing_lists/11/templates
{
"campaign": {
"name": "New Template"
}
}
HTTP/1.1 200 OK
{
"success": true,
"data": {
"archived": false,
"content_determined": false,
"created_at": "2017-05-09T19:21:23Z",
"custom_dynamic_template_id": null,
"id": 55,
"mailing_list_id": 11,
"name": "New Template",
"organization_id": 10,
"segmentation_criteria_id": null,
"template": true,
"updated_at": "2017-05-09T19:21:23Z",
"mailing_list_name": "Monthly Subscribers",
"organization_name": "News Co",
"stat_summary": null,
"content_stats": [
],
"automatic_winner_selection": null,
"campaign_contents": [
]
},
"error_code": null,
"error_message": null
}
Update an Existing Campaign Template
PUT /ga/api/v2/templates/:template_id
Payload
campaign
hash /required |
The content of this hash is described in the Campaign Template Attributes section of this page. The data may contain a mixture of required and optional fields. Do not specify read-only fields. |
Response
A successful response will return the template record using the format described in the Campaign Template Attributes section of the API.
Example
PUT /ga/api/v2/templates/59
{
"campaign": {
"name": "Updated Template",
"dispatch_attributes": {
"speed": 150,
"bounce_email_id": "5012@59912",
"virtual_mta_id": 0,
"url_domain_id": 1,
"from_name": "From Example",
"from_email": "[email protected]"
}
}
}
HTTP/1.1 200 OK
{
"success": true,
"data": {
"archived": false,
"content_determined": false,
"created_at": "2017-05-09T19:21:23Z",
"custom_dynamic_template_id": null,
"id": 59,
"mailing_list_id": 12,
"name": "Updated Template",
"organization_id": 11,
"segmentation_criteria_id": null,
"template": true,
"updated_at": "2017-05-09T19:21:23Z",
"mailing_list_name": "Monthly Subscribers",
"organization_name": "News Co",
"stat_summary": null,
"content_stats": [
],
"automatic_winner_selection": null,
"dispatch": {
"autowinner_delay_amount": null,
"autowinner_delay_unit": "minutes",
"autowinner_enabled": false,
"autowinner_metric": null,
"autowinner_percentage": null,
"begins_at": null,
"finished_at": null,
"from_email": "[email protected]",
"from_name": "From Example",
"paused": false,
"reply_to": null,
"sender_email": null,
"speed": 150,
"started_at": null,
"state": "idle",
"track_links": true,
"track_opens": true,
"url_domain_id": 1,
"virtual_mta_id": 0,
"state_description": "Step 1: Pending",
"virtual_mta_name": "System Default Route",
"virtual_mta_type": "default_route",
"bounce_email_user_id": 5012,
"bounce_email_domain_id": 59912,
"bounce_email_email": "[email protected]",
"url_domain_domain": "example.com",
"seed_lists": [
],
"special_sending_rule_id": null,
"special_sending_rule_name": null,
"seed_list_id": null,
"seed_list_name": null
},
"campaign_contents": [
]
},
"error_code": null,
"error_message": null
}