Create an SMS template

Use this endpoint to create an SMS template.

API at a glance

Description: This API creates a new SMS/MMS template in your Blueshift account. You can specify the template content, message type (SMS/MMS), link shortening, 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: template (with name, resource, skip_user_on_external_fetch_error) and template_property (with skip flags) are required.
  • Message types: Choose sms for text messages or mms for multimedia messages.
  • MMS requirements: For MMS templates, media_url is required. subject is optional but recommended.
  • SMS requirements: For SMS templates, content is required.
  • Link shortening: Set shorten_links to true to enable link click tracking.
  • Recommendation schemes: Use account_algorithm_uuid to add recommendation schemes. Send null to remove existing schemes.
  • Tag data: Tags must already exist in your account. Format: folder_name:tag1,tag2,tag3.
  • Use case: Best for programmatically creating SMS/MMS templates, automating template setup, and bulk template creation.

Request parameters

Check out the request parameters

Body parameters

ParameterTypeRequiredDescription
templateobject✅ YesTemplate object. See structure below.
template_propertyobject✅ YesCampaign behavior properties. See structure below.
external_fetchesarray❌ NoArray of external fetch UUIDs to integrate external data sources.
transaction_mixinsarray❌ NoArray of transaction mixin UUIDs.

Template object

ParameterTypeRequiredDescription
namestring✅ YesSpecify the name of the template.
resourceobject✅ YesTemplate content object. See structure below.
skip_user_on_external_fetch_errorboolean✅ YesMessage is not sent if external fetch encounters an error. Default: true.
authorstring❌ NoSpecify the email address of the template's author.
tag_datastring❌ NoFolder and tags in format folder_name:tag1,tag2,tag3. Tags must exist in your account.

Resource object

ParameterTypeRequiredDescription
message_typestring❌ NoMessage type: sms or mms. Default: sms.
contentstring✅ Yes (for SMS)Content of the SMS template. Required for SMS messages.
media_urlstring✅ Yes (for MMS)URL for media in MMS message. Required for MMS messages.
subjectstring❌ NoSubject for MMS template.
shorten_linksboolean❌ NoEnable link shortening for click tracking. Default: true.

Template property 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 an SMS template

Request

curl --request POST \
     --url https://api.getblueshift.com/api/v1/sms_templates.json \
     --header 'accept: application/json' \
     --header 'authorization: Basic <YOUR_API_KEY>' \
     --header 'content-type: application/json' \
     --data '{
       "template": {
         "name": "John'\''s SMS template",
         "author": "[email protected]",
         "resource": {
           "message_type": "sms",
           "content": "Hello {{user.firstname}}, check out our latest deals!",
           "shorten_links": true
         },
         "tag_data": "Regions:USA,China,Brazil,Hong Kong,India,Sweden,Canada",
         "skip_user_on_external_fetch_error": true
       },
       "template_property": {
         "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"
         }
       ]
     }'

Response

{
  "name": "John's SMS template",
  "created_at": "2024-05-05T20:41:21.000Z",
  "updated_at": "2024-05-11T22:04:38.000Z",
  "uuid": "67b6ad85-461c-403f-b779-64eb4e7d401c",
  "archived": false,
  "is_destroy": true,
  "author": "John Doe"
}
Body Params

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

template
object
required

Specify the properties of the template.

template_property
object
required

Specify the campaign behavior properties for the template.

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.

transaction_mixins
Responses

400

The request was invalid or cannot be otherwise served. An accompanying error message will explain further.

404

Resource not found. This can happen due to resource conflicts. Retry with exponential backoff. If the issue persists, contact Blueshift.

409

Conflict error, please retry. The request could not be completed due to a conflict with the current state of the target resource. Re-try with exponential backoff.

429

Rate limit exceeded. Too many requests. Contact us on [email protected] for recommended throughput.

500

Internal server error. Contact Blueshift for more information.

502

Service unavailable, please retry. Bad gateway. Retry with exponential backoff.

503

Service unavailable, please retry. Service unavailable. Retry with exponential backoff.

504

Service unavailable, please retry. Gateway timeout. Retry with exponential backoff.

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