Create email template

Use this endpoint to create an email template.

API at a glance

Description: This API creates a new email template in your Blueshift account. You can specify the template content, subject line, preheader, recommendation schemes, external fetches, and other campaign behavior properties.

Authentication & testing

Testing the API on this page

How to try it here

  • Use your User API Key as the Username (leave Password blank).
  • Select the appropriate API endpoint based on your Blueshift region.
  • API - Select Region
  • Enter the necessary parameters and click Try It to run the request.
Authentication using Base64 encoding

Note for developers

API requests require authentication using HTTP Basic Authentication with an API key. The API key serves as the username, while the password field should be left empty. The format to encode is: your_api_key: (note the trailing colon).

This string must be Base64-encoded and included in the request's Authorization header as follows:

Authorization: Basic encoded_value

You can generate the encoded value using a trusted Base64 encoder.


Postman collection

Try it with Postman: Explore the API using Blueshift's Postman collection.


Things to know before you start

  • Required fields: name, resource (with subject and content), skip_user_on_external_fetch_error, and template_properties are required.
  • HTML content: The content field should contain the complete HTML body of the email template.
  • Recommendation schemes: Use account_algorithm_uuid to add recommendation schemes. Send null to remove existing schemes.
  • External fetches: Add external fetch UUIDs to integrate external data sources into the template.
  • Transaction mixins: Multiple transaction mixins use OR logic - results include transactions matching ANY of the criteria.
  • Tag data: Tags must already exist in your account. Format: folder_name:tag1,tag2,tag3.
  • Use case: Best for programmatically creating email templates, automating template setup, and bulk template creation.

Request parameters

Check out the request parameters

Body parameters

ParameterTypeRequiredDescription
namestring✅ YesSpecify the name for the template.
resourceobject✅ YesTemplate content object. See structure below.
skip_user_on_external_fetch_errorboolean✅ YesMessage is not sent to user if external fetch encounters an error or returns no data. Default: true.
template_propertiesarray✅ YesCampaign behavior properties (max 1 item). See structure below.
authorstring❌ NoSpecify the email address of the template's author.
external_fetchesarray❌ NoArray of external fetch UUIDs to integrate external data sources.
transaction_mixinsarray❌ NoArray of transaction mixin UUIDs. Multiple mixins use OR logic.
tag_datastring❌ NoFolder and tags in format folder_name:tag1,tag2,tag3. Tags must exist in your account.

Resource object

ParameterTypeRequiredDescription
subjectstring✅ YesSpecify the subject line of the template.
contentstring✅ YesSpecify the HTML body of the template.
preheaderstring❌ NoSpecify the preheader line of the template.

Template properties object

ParameterTypeRequiredDescription
skip_user_on_blank_productsboolean✅ YesSkip user if products are blank. Default: true.
skip_user_on_blank_event_productsboolean✅ YesSkip user if event products are blank. Default: true.
account_algorithm_uuidstring❌ NoRecommendation scheme UUID. Leave blank for no change, send null to remove existing scheme.

Example requests & responses

Create a basic email template

Request

curl --request POST \
     --url https://api.getblueshift.com/api/v1/email_templates.json \
     --header 'accept: application/json' \
     --header 'authorization: Basic <YOUR_API_KEY>' \
     --header 'content-type: application/json' \
     --data '{
       "name": "My API Template",
       "author": "[email protected]",
       "resource": {
         "subject": "Hey, {{user.firstname}}!",
         "preheader": "Here are few deals you don'\''t want to miss!",
         "content": "<!DOCTYPE html>\n<html>\n<body>\nHello\n</body></html>"
       },
       "skip_user_on_external_fetch_error": true,
       "template_properties": [
         {
           "skip_user_on_blank_products": true,
           "skip_user_on_blank_event_products": true,
           "account_algorithm_uuid": "2879b1a3-ee84-4e13-b63c-ad83674c0ca1"
         }
       ],
       "external_fetches": [
         {
           "uuid": "e789705f-3eb3-4e2a-a666-648dedae6g86"
         }
       ],
       "tag_data": "Regions:USA,China,Brazil,Hong Kong,India,Sweden,Canada"
     }'

Response

{
  "status": "OK",
  "uuid": "94d45bc8-3488-2002-cd9b-d6314445c545"
}
Body Params

Takes the template details returns a JSON that provides the UUID of the created template.

string
required

Specify the name for the template.

string

Specify the email address of the template's author.

resource
object
required
boolean
required
Defaults to true

Message is not sent to user if the external fetch encounters an error or does not return any data)

template_properties
array of objects
required
length ≤ 1

Specify the campaign behavior properties for the template.

template_properties*
external_fetches
array of objects

Specify the external fetches for the template.

external_fetches
transaction_mixins
array of objects

Specify the transaction mixins for the template. Note that when you add multiple transaction mixins, the resultant transactions are the OR result of all the queries related to the transactions mixins. For example, the resultant JSON response will contain any transaction that meets EITHER the transaction_mixin1 criteria OR the transaction_mixin2 criteria (or both).

transaction_mixins
string

Specify a folder and then tags under the folder in the format folder_name: tag1, tag2, tag3. For example, Regions:USA,China,Brazil,Hong Kong,India,Sweden,Canada.

📘 Tag data should exist in your account.

Responses
200

OK

Language
Credentials
Basic
base64
:
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json