getTemplates method

This method is used to get the list of templates created both through the Selzy personal account and through the API.

To display the list of templates, you need to specify the time frame for the search and your API key. Additionally, you can specify the number of templates to display in one request, the position from which the list of templates will be displayed for this request, and the format for displaying returned data (json / html).

Principle of use

Syntax and URL to call the method
getTemplates ([string type, datetime date_from, datetime date_to, string format, int limit, int offset])
https://api.selzy.com/en/api/getTemplates?format=json&api_key=KEY
Arguments
api_key * API access key.
type The template type obtains the following values: system|user;system — system templates (their display does not depend on the template creation date and time, i.e. the date_from and date_to parameters);

user — user templates (default value).

date_from Template creation date and time, from which templates are to be displayed, in the "YYYY-MM-DD hh:mm:ss" format, time zone UTC.
date_to Template creation date and time, until which templates are to be displayed, in the "YYYY-MM-DD hh:mm:ss" format, time zone UTC.
format The display format of the returned result. It can obtain values of html | json, json is set by default (the html format is intended only for visual viewing of the result, the parser will not work in this format).
limit Number of records in the response to one request must be an integer in the range from 1 to 100, 50 records are set by default.
offset The parameter indicates from which position the selection is to be started. The value must be 0 or more (the position of the first record starts from 0), 0 is set by default.
Return value
JSON array, each array element is an object with the following fields. Description of fields is under the example.
Example of the return value:

{
 "result": [
 {
 "id": "943434",
 "sub_user_login": "",
 "title": "test",
 "description": "",
 "lang_code": "en",
 "subject": "test",
 "attachments": "",
 "screenshot_url": "https://api.selzy.com/en/v5/preview/template/57szc6e88kxw6osb7cuj5k11wwe",
 "created": "2020-10-06 14:54:23",
 "updated": "2020-04-17 16:31:51", 
 "message_format": "block",
 "type": "user",
 "body": "<html><head></head><body>Some code</body></html>",
 "raw_body": null, 
 "fullsize_screenshot_url":""
 },
 {},
 {}
 ]
}

Where:

id — identifier of the template in the system;
sub_user_login — either the login of the sub-user who created the template or NULL if the letter was created by the master user;
title — name of the template in the system;
description — text description of the template;
service_type — message type (email or sms);
active_version_id — there will be null if active, or there will be an identifier of the active letter if there are versions and this version of the letter is not final;
is_draft — return value shows whether the letter is a draft;
lang_code — two-letter language code to be automatically added to the letter with the unsubscribe form (for example, 'en', 'ru');
type — template type (system/user);
raw_body — system parameter containing the json structure of the block editor data (it returns for user template type only);
body — template body (it returns for user template type only);
subject — template subject;
screenshot_url — link to the template screenshot;
created — template creation date and time, UTC;
updated - template updation date and time, UTC;
message_format — returns the manner of creating a template: «block» — block editor, «raw_html» — html editor;
fullsize_screenshot_url — returns the link to the full-size image of the system template. The parameter will be returned if type = system.

Errors format:

{
   {"error":"VK151214-01 [ 'date_from' value is not a valid datetime "2015-12-14 12:5x"]"} 
   {"error":"VK151214-01 [ 'date_to' value is not a valid datetime "2015-12-14 22:0x"]"} 
   {"error":"VK151214-01 [ 'limit' value should be a valid number]"} 
   {"error":"VK151214-01 [ 'offset' value should be greater than or equal to 0]"}
}

Did we answer to your question?

0
0