---
openapi: 3.0.3
info:
  title: Braze REST API – Create email template
  description: |
    ## Prerequisites

    To use this endpoint, you'll need an [API key]({{site.baseurl}}/api/basics/) with the `templates.email.create` permission.

    ## Rate limit

    We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits]({{site.baseurl}}/api/api_limits/).
  version: 1.0.0
  contact:
    name: Braze Support
    url: https://www.braze.com/docs/braze_support/
  license:
    name: Braze Documentation
    url: https://www.braze.com/docs/api/home/
servers:
  - url: https://rest.iad-01.braze.com
    description: US-01
  - url: https://rest.iad-02.braze.com
    description: US-02
  - url: https://rest.iad-03.braze.com
    description: US-03
  - url: https://rest.iad-04.braze.com
    description: US-04
  - url: https://rest.iad-05.braze.com
    description: US-05
  - url: https://rest.iad-06.braze.com
    description: US-06
  - url: https://rest.iad-07.braze.com
    description: US-07
  - url: https://rest.iad-08.braze.com
    description: US-08
  - url: https://rest.us-10.braze.com
    description: US-10
  - url: https://rest.fra-01.braze.eu
    description: EU-01
  - url: https://rest.fra-02.braze.eu
    description: EU-02
  - url: https://rest.au-01.braze.com
    description: AU-01
  - url: https://rest.id-01.braze.com
    description: ID-01
  - url: https://rest.jp-01.braze.com
    description: JP-01
  - url: https://rest.kr-01.braze.com
    description: KR-01
security:
- BearerAuth: []
paths:
  "/templates/email/create":
    post:
      summary: Create email template
      operationId: post_templates_email_create_post_create_email_template
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEmailTemplateRequest'
            examples:
              example_request:
                summary: Create an email template
                value:
                  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
      responses:
        "201":
          description: |
            The request succeeded and the email template was created. The response includes the `email_template_id`. No action needed.

            The following sample response shows an example of the response returned when you create email template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateEmailTemplateResponse'
              examples:
                success:
                  summary: Email template created
                  value:
                    email_template_id: 232b6d29-7e41-4106-a0ab-1c4fe915d701
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **The template is a drag-and-drop template, which can't be created by API:** Create drag-and-drop templates in the dashboard.
            - **The `template_name` is blank:** Include a non-empty `template_name`.
            - **The `template_name` isn't a string:** Pass `template_name` as a string.
            - **The `subject` is blank:** Include a non-empty `subject`.
            - **The `body` is blank:** Include a non-empty `body`.
            - **The `should_inline_css` value isn't a boolean:** Pass `should_inline_css` as `true` or `false`.
            - **The template references a Content Block that doesn't exist:** Reference only existing Content Blocks.
            - **The `tags` value isn't an array:** Pass `tags` as an array of strings.
            - **A value in `tags` isn't a string:** Make every entry in `tags` a string.
            - **One or more tags don't exist:** Create the tags first, or remove them from `tags`.
            - **The total template size is larger than 8 MB:** Reduce the total size of the template below 8 MB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                dnd_not_supported:
                  summary: Drag-and-drop template
                  value:
                    message: Drag-and-drop email templates cannot be created from the API.
                template_name_blank:
                  summary: The template_name is blank
                  value:
                    message: Template name cannot be blank.
                template_name_not_string:
                  summary: The template_name isn't a string
                  value:
                    message: Template name must be a String.
                subject_blank:
                  summary: The subject is blank
                  value:
                    message: Subject cannot be blank.
                body_blank:
                  summary: The body is blank
                  value:
                    message: Body cannot be blank.
                should_inline_css_invalid:
                  summary: The should_inline_css value isn't a boolean
                  value:
                    message: "Invalid value for 'should_inline_css'.  One of 'true' or 'false' was expected"
                invalid_content_blocks:
                  summary: Content Block doesn't exist
                  value:
                    message: Email must have valid content block names.
                tags_not_array:
                  summary: The tags value isn't an array
                  value:
                    message: Tags must be an array.
                tag_not_string:
                  summary: A value in tags isn't a string
                  value:
                    message: All Tags must be Strings.
                tags_not_found:
                  summary: One or more tags don't exist
                  value:
                    message: "The following Tags could not be found: ['Tag1', 'Tag2']."
                template_too_large:
                  summary: Template larger than 8 MB
                  value:
                    message: The total size of the template must be smaller than 8388608
        "401":
          description: |
            Unauthorized. The REST API key is missing, malformed, or sent to the wrong REST endpoint. Send the key as `Authorization: Bearer YOUR_REST_API_KEY` to the correct [REST endpoint]({{site.baseurl}}/api/basics/#endpoints). For more causes, see [Errors and responses]({{site.baseurl}}/api/errors/#fatal-errors).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_api_key:
                  summary: Invalid API key
                  value:
                    message: 'Invalid API key: YOUR_REST_API_KEY'
        "403":
          description: Access denied. The REST API key doesn't have the required permission. Use a REST API key that has the `templates.email.create` permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                access_denied:
                  summary: Missing permission
                  value:
                    message: Access Denied
        "429":
          description: |
            Rate limited. You exceeded the rate limit for this endpoint. Slow your request rate and retry with exponential backoff. See [API rate limits]({{site.baseurl}}/api/api_limits/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                over_rate_limit:
                  summary: Over rate limit
                  value:
                    message: You have exceeded your limit of 250000 requests per hour. Please contact your account executive to increase your limit. If you do not have their info, you may contact Braze directly at https://www.braze.com/contact/.
        5XX:
          description: |
            Internal server error. An unexpected error occurred on the Braze server. Retry with exponential backoff. If the error persists, contact [Support]({{site.baseurl}}/braze_support/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: REST API key
      description: |
        REST API keys are created in the Braze dashboard at **Settings → APIs and
        Identifiers → API Keys**. The key must include the `templates.email.create` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    CreateEmailTemplateRequest:
      title: Create email template request
      type: object
      required: [template_name, subject, body]
      properties:
        template_name:
          type: string
          description: The name of your email template.
          example: email_template_name
        subject:
          type: string
          description: The email template subject line.
          example: Welcome to my email template!
        body:
          type: string
          description: The email template body that may include HTML. Up to 400 KB.
          example: This is the text within my email body and https://www.braze.com/ here is a link to Braze.com.
        plaintext_body:
          type: string
          description: A plaintext version of the email template body.
          example: This is the text within my email body and here is a link to https://www.braze.com/.
        preheader:
          type: string
          description: The email preheader used to generate previews in some clients.
          example: My preheader is pretty cool.
        tags:
          type: array
          items:
            type: string
          description: '[Tags]({{site.baseurl}}/user_guide/messaging/governance/tags/) must already exist.'
          example:
            - Tag1
            - Tag2
        should_inline_css:
          type: boolean
          description: Enables or disables the `inline_css` feature per template. If not provided, Braze will use the default setting for the app group. One of `true` or `false` is expected. If `true`, the `inline_css` feature is used on this template.
          example: true
    CreateEmailTemplateResponse:
      title: Create email template response
      type: object
      properties:
        email_template_id:
          type: string
          description: Your email template's API identifier. Use it to update the template in subsequent API calls.
          example: 232b6d29-7e41-4106-a0ab-1c4fe915d701
        message:
          type: string
          description: Returns `success` when the request completes without errors.
          example: success
    ErrorResponse:
      title: Error
      type: object
      properties:
        message:
          type: string
          description: The error message describing why the request failed.
        errors:
          type: array
          description: Non-fatal errors encountered while processing the request. Data unaffected by these errors is still processed.
          items:
            type: object
            properties:
              type:
                type: string
                description: The error type.
