Create Email Template

post

/templates/email/create

Use the Template REST APIs to programmatically manage the email templates that you have stored on the Braze dashboard, on the Templates & Media page. Braze provides two endpoints for creating and updating your email templates.

Users’ email subscription status can be updated and retrieved via Braze using a RESTful API. You can use the API to set up bi-directional sync between Braze and other email systems or your own database. All API requests are made over HTTPS.

Use the endpoints below to create email templates on the Braze dashboard. These templates will be available on the Templates and Media page. The response from this endpoint will include a field for email_template_id, which can be used to update the template in subsequent API calls.

Request Body

1
2
Content-Type: application/json
Authorization: Bearer YOUR_REST_API_KEY
1
2
3
4
5
6
7
8
9
{
   "template_name": (required, string) the name of your email template,
   "subject": (required, string) the email template subject line,
   "body": (required, string) the email template body that may include HTML,
   "plaintext_body": (optional, string) a plaintext version of the email template body,
   "preheader": (optional, string) the email preheader used to generate previews in some clients,
   "tags": (optional, Array of Strings) Tags must already exist,
   "should_inline_css": (optional, Boolean) One of 'true' or 'false' is expected
 }

Request Parameters

Parameter Required Data Type Description
template_name Required String The name of your email template
subject Required String The email template subject line
body Required String The email template body that may include HTML
plaintext_body Optional String A plaintext version of the email template body
preheader Optional String The email preheader used to generate previews in some clients
tags Optional String Tags must already exist
should_inline_css Optional Boolean Enables or disables the ‘inline_css’ feature per template. If not provided, Braze will use the default setting for the AppGroup. One of ‘true’ or ‘false’ is expected

Example Request

1
2
3
4
5
6
7
8
9
10
11
12
curl --location --request POST 'https://rest.iad-01.braze.com/templates/email/create' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_REST_API_KEY' \
--data-raw '{
  "template_name": "email_template_name",
  "subject": "Welcome to my email template!",
  "body": "This is the text within my email body and https://www.braze.com/ here is a link to Braze.com.",
  "plaintext_body": "This is the text within my email body and here is a link to https://www.braze.com/.",
  "preheader": "My preheader is pretty cool.",
  "tags": ["Tag1", "Tag2"],
  "should_inline_css": false
}'

Possible Errors

  • Template Name is required

  • Tags must be an array.

  • All Tags must be Strings.

  • Some Tags could not be found. - A tag was specified which doesn’t exist in this environment.

  • Email must have valid content block names. - The email contains Content Blocks which do not exist in this environment.

  • "Invalid value for 'should_inline_css'. One of 'true' or 'false' was expected" - ‘should_inline_css’ accepts boolean characters only. The error likely is being shown as the value is being sent as a ‘string’.

WAS THIS PAGE HELPFUL?
New Stuff!