Templates

This endpoint allows a user to manage templates of various types, add embedded values and provide better marketing automation.

The following fields relate to the Templates endpoint.

EmailTextPhoneDirect Mail LetterDirect Mail Postcard
FieldLimitsRequired?Writeable?
id
NoNo

The ID of the template folder

user_id
Automatically set as the submitter's id
NoNo

The owning user ID of the template

template_folder_id
YesYes

The template folder ID containing the template

body
NoYes

The main contents of the template

subject
1000 characters
NoYes
description
200 characters
NoYes

An internal facing description of the template, this is not sent with the correspondence.

file_id
NoYes

The ID of an attachment file if one has been added to this template.

created_at
NoNo

The date and time at which the template was created

modified_at
NoNo

The date and time at which the template was last edited

template_type
YesYes

The medium by which the template is sent

Possible values:

Submit one Template

To submit one template:

POST https://api-v2.liondesk.com//templates headers: { Authorization: "Bearer [access token]", Content-Type: "application/json" }

The request object should have this form:{ "template_folder_id": 1, "body": "How's your home search progressing? Is there anything we can help with?", "subject": "I'm here to help", "description": "Email #12", "file_id": 1, "template_type": "Email" }

Update one Template

To update some attributes on one template:

PATCH https://api-v2.liondesk.com//templates/10 headers: { Authorization: "Bearer [access token]", Content-Type: "application/json" }

data: {
template_folder_id: "1",
body: "How's your home search progressing? Is there anything we can help with?"
}

Get One Template

To get one template:

GET https://api-v2.liondesk.com//templates/1 headers: { Authorization: "Bearer [access token]", Content-Type: "application/json" }

The response object will have this form:{ "id": 1, "user_id": 1, "template_folder_id": 1, "body": "How's your home search progressing? Is there anything we can help with?", "subject": "I'm here to help", "description": "Email #12", "file_id": 1, "created_at": "2017-07-08T11:11:11.000Z", "modified_at": "2018-01-16T12:12:12.000Z", "template_type": "Email" }

Find All Templates

You find/search templates by issuing a GET request to the base endpoint:

GET https://api-v2.liondesk.com//templates headers: { Authorization: "Bearer [access token]", Content-Type: "application/json" }

The response will contain an array of template objects, like so:

{ "total": 2, "limit": 10, "skip": 0, "data": [ { "id": 1, "user_id": 1, "template_folder_id": 1, "body": "How's your home search progressing? Is there anything we can help with?", "subject": "I'm here to help", "description": "Email #12", "file_id": 1, "created_at": "2017-07-08T11:11:11.000Z", "modified_at": "2018-01-16T12:12:12.000Z", "template_type": "Email" }, { "id": 3, "user_id": 1, "template_folder_id": 2, "body": "Hello, How is your day going? This is a simple note to remind you that I'm here to help, even if you are not ready to list. I've always been about building relationships and I wanted to let you know that I look forward to keeping in touch. Thanks!", "subject": "Your agent checking in.", "description": "Text #1", "file_id": 3, "created_at": "2017-12-16T08:08:08.000Z", "modified_at": "2018-12-01T07:07:07.000Z", "template_type": "Text" } ] }

Filtering Templates

The following filtering operators may be mixed and matched as desired.

Equality

You may query template fields directly by specifying equality parameters in the request URI:GET /templates?template_type=Text&template_folder_id=1

You may wish to exclude results having some value with $ne:GET /templates?template_type[$ne]=Phone

Dates & Times

Unless otherwise stated all dates and times should be in ISO8601 format. Examples: 2012-09-27, 2012-09-27T09:15:00Z (UTC), 2012-09-27T09:15:00-07:00 (PDT)

Limiting and Pagination

$limit will return only the number of results you specify: GET /templates?$limit=2

$skip will skip the specified number of results, useful for paginating:GET /templates?template_type=Phone&$limit=2&$skip=2

Sorting

$sort will order results based on the field given.

Use 1 for ascending order, and -1 for descending order:GET /templates?$limit=10&$sort[template_folder_id]=-1

Inclusion / Exclusion

Find all records where the property values are ($in) some set:GET /templates?template_folder_id[$in]=1&template_folder_id[$in]=2If the column matches any of the given values, the resource shall be returned.

Similarly, you may exclude certain values with ($nin):GET /templates?template_folder_id[$nin]=1&template_folder_id[$nin]=2

Comparisons

You may use the less-than $lt and less-than-or-equal $lte operators to filter your queries: GET /templates?template_folder_id[$lt]=1

Similarly, you may use greater-than $gt and greater-than-or-equal $gte operators to filter your queries: GET /templates?template_folder_id[$gte]=2

You may also combine these operators to query for a range of values: GET /templates?template_folder_id[$gte]=1&template_folder_id[$lte]=20

Remove

Templates can be removed with a delete request.

DELETE https://api-v2.liondesk.com//templates/295 headers: { Authorization: "Bearer [access token]", Content-Type: "application/json" }