See api-docs Menu

Create Message Template

Early Preview

This API is in early preview and may be subject to change. Please contact your account manager if you are interested in trying the Branding API.

Use this API to create a new message template for a brand.

Templates can be created in multiple languages and are used for customizing the content in Email and SMS notifications.

See below for a list of possible message template types.

Note: Message templates must be associated with a brand id. You can locate a given brand’s id by calling the List Brands endpoint, or use master instead of the brand id to associate the template with your primary brand.



Resource URL

https://<subdomain>/api/2/branding/brands/:brand_id/templates

Header Parameters

Authorization

required

string

Set to bearer <access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using any one of the following scopes: Manage All.

In order to use the Branding API your API Credentials must be created after 21st October 2020.

Content-Type

required

string

Set to application/json.

Request Parameters

type

required

string

Template type that describes the source (sms, voice, email) and purpose (registration, invite, etc

Must be one of:

  • email_forgot_password
  • email_code_registration
  • email_code_login_verification
  • email_code_app_verification
  • email_code_pw_reset_verification
  • email_magiclink_registration
  • email_magiclink_login_verification
  • email_magiclink_app_verification
  • email_magiclink_pw_reset_verification
  • sms_registration
  • sms_login_verification
  • sms_app_verification
  • sms_pw_reset_verification

locale

required

string

The 2 character language locale for the template.

e.g. en = English, es = Spanish

template

required

string

The content body for the message. The template parameters vary based on the type of template. Templates can also contain placeholder values that will be substituted at the time of sending a message.

Email

  • subject - required - The email subject
  • html - required - The HTML body of the email
  • plain - required - The plain text body of the email

Placeholder values include url for magiclink or forgot password types, and otp_code for templates that have the code type.

SMS

  • message - required - The body of the SMS message. Max length 160 characters.

Placeholder values include otp_code for the OTP code and otp_expiry for the time until the code expires.

Request Body

Email Messages

{
    "locale": "en",
    "type": "email_code_app_verification",
    "template": {
        "subject": "Email MFA App Verification Code",
        "html": "<html><head></head><body><p>Here is the code: {{otp_code}}</p></body></html>",
        "plain": "Here is the code: {{otp_code}}"
    }
}

SMS Messages

{
    "locale": "en",
    "type": "sms_registration",
    "template": {
        "message": "Here is the code: {{otp_code}}"
    }
}

Sample Responses

{
    "id": 544880,
    "account_id": 118462,
    "locale": "en",
    "type": "email_code_app_verification",
    "template_class": "email_template",
    "template": {
        "subject": "Email MFA App Verification Code",
        "html": "<html><head></head><body><p>Here is the code: {{otp_code}}</p></body></html>",
        "plain": "Here is the code: {{otp_code}}"
    },
    "updated_at": "2021-11-24T21:25:29.480Z",
    "brand_id": 5
}
{
    "name": "UnauthorizedError",
    "message": "The request requires user authentication."
}
{
    "name": "UnprocessableEntityError",
    "message": "A template already exists with the give Brand ID, Template Type, and locale.",
    "statusCode": 422
}

Postman Collection

Replace sample variables indicated by {{ }} with your actual values.

Download for the Branding API

Sample Code

cURL

Replace sample values indicated by < > with your actual values.

Create Account Brand

curl 'https://<subdomain>/api/2/branding/templates' \
-X POST \
-H "Authorization: bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
    "locale": "en",
    "type": "email_code_app_verification",
    "template_class": "email_template",
    "template": {
        "subject": "Email MFA App Verification Code",
        "html": "<html><head></head><body><p>Here is the code: {{otp_code}}</p></body></html>",
        "plain": "Here is the code: {{otp_code}}"
    }
}'

Have a Question?

Found a problem or a bug? Submit a support ticket.

Looking for walkthroughs or how-to guides on OneLogin's user and admin features? Check out the documentation in our Knowledge Base.

Have a product idea or request? Share it with us in our Ideas Portal.