Templates
Copy Template
POST https://api.expresspigeon.com/templates/{id}/copy
This feature allow developers to create a copy of an email template and at the same time merge data into a new version. It makes it possible to have the following workflow:
- Create a blank template and add merge fields to it (using email editor)
- Make a new copy of this template, and merge specific data into it using this API
- Send or schedule a new campaign with the API
Steps 2 and 3 can be done remotely with the API, without having to log into the website. Combined with ability to create new lists on the fly, and upload contacts, it provides an opportunity to build powerful marketing solutions.
Request Parameters
id |
Yes |
Template id to be used as a source |
name |
Yes |
Name for a new template |
merge_fields |
No |
Values of merge fields |
Example Request
1
2
3
4
5
6
7
8
9
| curl -X POST -H "X-auth-key: 00000000-0000-0000-0000-000000000000" \
-H "Content-type: application/json" \
-d '{
"name": "My new template",
"merge_fields":{
"menu": "<table class='report'><tr><td>Burger:</td></tr><tr>$9.99<td></td></tr></table>"
}
}' \
'https://api.expresspigeon.com/templates/123/copy'
|
1
2
3
4
5
6
7
8
9
10
11
12
| import org.javalite.http.Http;
import static org.javalite.common.Collections.map;
import static org.javalite.common.JsonHelper.toJsonString;
import static org.javalite.common.JsonHelper.toMap;
String content = toJsonString(map("name", "My new template",
"merge_fields", map("menu","<table class='report'><tr><td>Burger:</td></tr><tr>$9.99<td></td></tr></table>")));
String response = Http.post("https://api.expresspigeon.com/templates/123/copy", content)
.header("X-auth-key", AUTH_KEY)
.header("Content-type", "application/json")
.text();
Map<String, Object> result = toMap(response);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| $data = array(
'name' => 'My new template',
'merge_fields' => array('menu' => '<table class=\'report\'><tr><td>Burger:</td></tr><tr>$9.99<td></td></tr></table>')
);
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode($data),
'header' => "Content-Type: application/json\r\n" .
"X-auth-key: 00000000-0000-0000-0000-000000000000\r\n"
)
);
$context = stream_context_create($options);
$result = file_get_contents('https://api.expresspigeon.com/templates/123/copy', false, $context);
$response = json_decode($result);
|
1
2
3
4
| require 'expresspigeon-ruby'
response = ExpressPigeon::API.templates.copy 34830, "new template",
:content => "Hello Template World!"
|
1
2
3
4
5
6
| from expresspigeon import ExpressPigeon
api = ExpressPigeon()
response = api.templates.copy(123, "My new template", merge_fields={
"menu": "<table class='report'><tr><td>Burger:</td></tr><tr>$9.99<td></td></tr></table>"
})
|
NOTE: It is important to use only single quotes in injected HTML
Example Response
1
2
3
4
5
6
| {
"status": "success",
"code": 200,
"message": "template copied successfully",
"template_id": 124
}
|
The template_id
in the response document above is an ID of a newly created template template which already contains all data merged.
Delete Template
DELETE https://api.expresspigeon.com/templates/{id}
Delete single template by id
Request parameters
id |
Yes |
Template id to be deleted |
Example Request
1
2
| curl -X DELETE -H "X-auth-key: 00000000-0000-0000-0000-000000000000" \
'https://api.expresspigeon.com/templates/123'
|
1
2
3
4
5
6
7
| import org.javalite.http.Http;
import static org.javalite.common.JsonHelper.toMap;
String response = Http.delete("https://api.expresspigeon.com/templates/123")
.header("X-auth-key", AUTH_KEY)
.text();
Map<String, Object> result = toMap(response);
|
1
2
3
4
5
6
7
8
9
| $options = array(
'http' => array(
'method' => 'DELETE',
'header' => "X-auth-key: 00000000-0000-0000-0000-000000000000\r\n"
)
);
$context = stream_context_create($options);
$result = file_get_contents('https://api.expresspigeon.com/templates/123', false, $context);
$response = json_decode($result);
|
1
2
3
| require 'expresspigeon-ruby'
response = ExpressPigeon::API.templates.delete template_id
|
1
2
3
4
| from expresspigeon import ExpressPigeon
api = ExpressPigeon()
response = api.templates.delete(123)
|
Example Response
1
2
3
4
5
| {
"status": "success",
"code": 200,
"message": "template deleted successfully"
}
|