Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages

createEmailTemplate method

Вы здесь:

It is a method to create an email template for a mass campaign. To edit an existing template, you can use the updateEmailTemplate method.

Principle of use

Syntax and URL to call the method
createEmailTemplate (string title, string sender_name, string sender_email,
string subject, string body, int list_id, string tag, int segment_id, string lang,
string message_format, string text_body, string raw_body, string description)
https://api.unisender.com/en/api/createEmailTemplate?format=json&api_key=KEY&title=TITLE&sender_name=
FROMNAME&sender_email=FROMMAIL&subject=SUBJECT&body=
HTMLBODY&list_id=X&tag=TAG&segment_id=X&lang=
LANG&message_format=FORMAT&text_body=TEXTBODY&raw_body=
RAW&description=DESCRIPTION
Arguments
api_key * API access key.
title * Template name.
sender_name * Sender’s name. It is an optional string that does not match the email address (the sender_email argument).
sender_email * Sender’s email address. This email must be checked (to do this, you need to manually create at least one email with this return address via the web interface, then click on the “send the confirmation request” link and follow the link from the email).
subject * String with the letter subject. It may include substitution fields.
body * Text of the letter template in the HTML format with the possibility to add substitution fields.If you transfer the entire HTML text, test such letters additionally as headers outside the body may be modified. In addition, in order to reduce a difference in the display in various mail applications, we automatically add additional markup to each letter (a table with invisible borders, which also sets a default font and left alignment of the text). You may request to turn it off for your letters by contacting our technical support service.
description A text description of the template, which can be obtained later on when calling this template.
list_id Code of the list for which the template is being created by default. Codes of all lists can be obtained by calling getLists.
text_body Text version of the letter template.
segment_id Code of the segment for which the template is being created.
tag Tag. If it is set, the letter from the template will not be sent to the entire list, but only to those recipients to which the tag is assigned.
lang Two-letter language code for the string with the unsubscribe link that is added to each letter automatically.

If it is not specified, the language code from the API URL is used.

In addition to the string with the unsubscribe link, this language also affects the interface of the unsubscribe page. Languages ru, it, ua and en are fully supported, and in case of some other languages (da, de, es, fr, nl, pl, pt, tr), the string with a link will be translated, and the control interface will be in English.

message_format It defines the way of creating a template: «block» — block editor, «raw_html»— html editor, text — text.

  • If you transfer the «text», value in this parameter, then if both the body and text_body parameters are filled in, the body parameter will be ignored and the template will be created based on the data transferred in the text_body parameter.
  • If you transfer the «block»value in this parameter but do not specify raw_body, the template will be saved as raw_html.
  • If you transfer the «block» value in this parameter, the body and body и raw_body parameters must be transferred for the message to be saved in the block editor format.
raw_body It is intended to save the json structure of the block editor data structure (if the value is message_format = block) The parameter obtains only the JSON structure, otherwise it will not be transferred.
Return value
JSON object with the following fields:template_id — identifier of the created template;

warnings — array containing warning fields (if any).

Example of the return value in case the template has been created successfully:

{
  "result":{
    "template_id": 1234567890
  },
  "warnings":[
    {"warning":"some warning text, if applicable"}
  ]
}

При ошибке:

{"error":"error message", "code":"error code"}