Templates
Templates are used when creating a new activity with correspondence.
The following variables are replaced:
{{subject}}
– replaced with the email subject (only for typeemail
){{content}}
- replaced with the content of the correspondence
Template types
The following template types are supported thus far:
- letter
All templates
GET /templates
Query string parameters
type
string - Filter for template type (see above)campaign
boolean - Filter for campaign templates.- Supports Pagination
Response
Status code 200
{
"data": [
{
"id": 1,
"type": "letter",
"company_id": "1",
"title": "Letter template",
"user_id": "1",
"team_id": null,
"group_id": null,
"campaign": false,
"margin_top": 15,
"margin_left": 20,
"margin_right": 20,
"margin_bottom": 5
},
{
"id": 2,
"type": "email",
"company_id": "1",
"title": "Email template",
"user_id": "1",
"team_id": null,
"group_id": null,
"campaign": false
},
{
"id": 3,
"type": "letter",
"company_id": "1",
"title": "Test template",
"user_id": "1",
"team_id": null,
"group_id": null,
"campaign": false,
"margin_top": 15,
"margin_left": 20,
"margin_right": 20,
"margin_bottom": 5
}
],
"pagination": {
"total": 3,
"page": 1,
"per_page": 15,
"urls": {
"previous": null,
"next": null
}
}
}
Find template
GET /templates/:template_id
Response
Status code 200
Type: Email
{
"id": 2,
"type": "email",
"company_id": "1",
"title": "Email template",
"user_id": "1",
"team_id": null,
"group_id": null,
"campaign": false,
"content": "<html><body><p>Dear customer</p><p>{{content}}</p><p>Best regards,<br><i>John</i></p></html></body>"
}
Type: Letter
{
"id": 1,
"type": "letter",
"company_id": 1,
"title": "Letter template",
"user_id": 1,
"team_id": null,
"group_id": null,
"campaign": false,
"margin_top": null,
"margin_left": null,
"margin_right": null,
"margin_bottom": null,
"content": "<p>Dear customer</p><p>content</p><p>Best regards,<br><i>Murray</i></p>"
}
Create template
POST /templates
Parameters
type
string- Can be one of
email
orletter
- Can be one of
margin_top
integer - Millimeters- Only works if type is
letter
- Only works if type is
margin_right
integer - Millimeters- Only works if type is
letter
- Only works if type is
margin_bottom
integer - Millimeters- Only works if type is
letter
- Only works if type is
margin_left
integer - Millimeters- Only works if type is
letter
- Only works if type is
Payload
{
"type": "email",
"title": "Test template 2",
"content": "<html><head><title>{{subject}}</title></head><body>{{content}}</body></html>"
}
Response
Status code 201
{
"id": 4,
"company_id": "1",
"type": "email",
"title": "Test template 2",
"user_id": "1",
"content": "<html><head><title>{{subject}}</title></head><body>{{content}}</body></html>"
}
Update template
PUT /templates/:template_id
Parameters
- Uses same parameters as Create template.
Payload
{
"type": "email",
"title": "Test template 2",
"content": "<html><head><title>{{subject}}</title></head><body>{{content}}<br>Best regards,<br>John</body></html>"
}
Response
Status code 200
{
"id": 4,
"company_id": "1",
"type": "email",
"title": "Test template 2",
"user_id": "1",
"content": "<html><head><title>{{subject}}</title></head><body>{{content}}<br>Best regards,<br>John</body></html>"
}
Delete template
DELETE /templates/:template_id
Deletes a template with no pending communications.
Query string parameters
force
boolean - If set to true, this will delete the template even if it has pending communications.
Response
Status code 204
Preview template
POST /templates/preview/:template_type
Depending on the template type, it generates a PDF (letter) or HTML preview (email) with content from in the request and returns a link to the preview.
Parameters
content
string- Required
template_type
string - Can be one of types Template types.template_id
intshow_placeholders
boolean - If set to true, placeholders will be shown instead of an empty string.
Payload
{
"template_id": 8743,
"contact_id": "263006cf-958c-3725-8e4e-4194805c3565",
"account_id": "2f215f8b-b98d-3c62-b812-68c89dc26ff3",
"products": [
{
"name": "Washing Machine",
"quantity": 230,
"type": "pieces",
"price": 15000
},
{
"name": "Dryer",
"quantity": 305,
"type": "pieces",
"price": 9999.95
}
],
"product_ids": [
"feb6afb0-5312-34c6-ab10-23900efc544b",
"52ac9d94-1c05-3221-adac-cbd6860165f8"
],
"task": {
"start_at": "2015-09-01 15:00:00",
"end_at": "2015-09-01 15:30:00",
"type": "meeting"
},
"content": "You have ordered the following products: {{product_details.name}}.\nThey can be picked up at {{task.start_at_date}} {{task.start_at_time}}"
}
Response
Status code 200
{
"download_url": "http://example.com/url-to-preview"
}