> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Email Template (V2)

> This API creates an email template in MoEngage. You can use this API to upload templates created outside the MoEngage ecosystem to MoEngage and use them for campaign creation. The uploaded templates can be edited in the Froala editor (custom HTML editor) on the MoEngage dashboard.


#### Rate Limit

The rate limit is 100 RPM. You can upload a maximum of 10000 templates per channel.


## OpenAPI

````yaml /api/email-templates-2/email-templates-2.yaml post /custom-templates/email
openapi: 3.1.0
info:
  title: Email Templates API V2
  version: v1.0
  description: >
    The Create Email Template API can be used to create an email template in
    MoEngage. This API helps you upload templates created outside the MoEngage
    ecosystem to MoEngage and use them for campaign creation. The uploaded
    templates can be edited in the Froala editor (custom HTML editor) on the
    MoEngage Dashboard.


    <Note>

    **Note**


    Templates created using this API cannot be used in the Drag and Drop Editor
    in the MoEngage Dashboard. They are supported only for the Custom HTML
    Editor (Froala Editor).

    </Note>
servers:
  - url: https://api-{dc}.moengage.com/v1.0
    description: MoEngage API Server
    variables:
      dc:
        default: '01'
        description: >-
          The ‘dc’ in the API Endpoint URL refers to the MoEngage Data Center
          (DC). MoEngage hosts each customer in a different DC. You can find
          your DC number and replace the value of ‘dc’ in the URL by referring
          to the DC and API endpoint mapping
          [here](/api/introduction#data-centers). Your MoEngage Data Center (DC)
          can be 01, 02, 03, 04, 05, 06, or 101.
security:
  - basicAuth: []
tags:
  - name: Email Templates
    description: Manage custom email templates.
paths:
  /custom-templates/email:
    post:
      tags:
        - Email Templates
      summary: Create Email Template (V2)
      description: >
        This API creates an email template in MoEngage. You can use this API to
        upload templates created outside the MoEngage ecosystem to MoEngage and
        use them for campaign creation. The uploaded templates can be edited in
        the Froala editor (custom HTML editor) on the MoEngage dashboard.
      operationId: createEmailTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - basic_details
                - meta_info
              properties:
                basic_details:
                  $ref: '#/components/schemas/BasicDetails'
                meta_info:
                  $ref: '#/components/schemas/MetaInfo'
            examples:
              Parent Template in a Template Group:
                summary: Parent Template in a Template Group
                value:
                  basic_details:
                    subject: Email_Subject
                    email_content: >-
                      <!DOCTYPE html><html><head><title>My Short
                      HTML</title></head><body><h1>Hello, World!</h1><p>This is
                      a simple HTML example.</p></body></html>
                    thumbnail_url: '{{template_thumbnail_thumbnail_url}}'
                    sender_name: Sender_Name
                    preview_text: Preview_text
                    attachments: []
                  meta_info:
                    created_by: john.doe@example.com
                    template_id: '{{template_id_1}}'
                    template_name: '{{template_name}}'
                    template_version: '{{template_version}}'
                    locale: '{{Locale_name}}'
                    variation: 1
              Associated Templates in the Same Template Group:
                summary: Associated Templates in the Same Template Group
                value:
                  basic_details:
                    subject: Email_Subject
                    email_content: >-
                      <!DOCTYPE html><html><head><title>My Short
                      HTML</title></head><body><h1>Hello, World!</h1><p>This is
                      a simple HTML example.</p></body></html>
                    thumbnail_url: '{{template_thumbnail_image_url}}'
                    sender_name: Sender_Name
                    preview_text: Preview_text
                    attachments: []
                  meta_info:
                    created_by: john.doe@example.com
                    template_id: '{{template_id_2}}'
                    template_name: '{{template_name}}'
                    template_version: '{{template_version}}'
                    locale: '{{Locale_name}}'
                    variation: 2
                    group_id: '{{external_template_id_of_parent_template}}'
      responses:
        '200':
          description: >-
            This response is returned when the request is processed
            successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  external_template_id:
                    type: string
                    description: >
                      This field contains the unique template id corresponding
                      to a successful template creation request and needs to be
                      stored by you. This template id would be used for
                      searching a specific template and updating it.

                      For a parent (default) template, the generated
                      "external_template_id" acts as its group ID.
              examples:
                success:
                  value:
                    external_template_id: d05a44f0-a7cf-471a-bcb6-63054800a367
        '400':
          description: >-
            This response is returned when the required parameters are missing
            from the request, or when the provided parameters are invalid, or
            when a template already exists with the same version, name, or id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_failure:
                  value:
                    error:
                      code: 400 Bad Request
                      message: Validation failed because of invalid request data
                      details:
                        - code: MissingValue
                          target: template_id
                          message: template_id value is too short
                      request_id: LMwPhRMB
                duplicate_request:
                  value:
                    error:
                      code: 400 Bad Request
                      message: Duplicate - template_id and template_version
                      details:
                        - code: InvalidValue
                          target: Duplicate - template_id and template_version
                          message: >-
                            template_id:EndOfSeasonSale template_version:10 is
                            already present.
                      request_id: cLCcgLQj
                limit_breach:
                  value:
                    error:
                      code: 400 Bad Request
                      message: Maximum Template limit exceeded
                      details:
                        - code: NotSupported
                          target: Maximum Template limit exceeded
                          message: >-
                            You have already created maximum allowed template
                            allowed for client
                      request_id: eLeZXIlW
        '401':
          description: >-
            This response is returned when the authorization parameters are
            missing in the HTTP Auth Header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                auth_fail:
                  value:
                    title: Authentication required
                    description: MOE-APPKEY missing in Authentication Header
        '415':
          description: >-
            This response is returned when the header Content-Type is not
            provided/is not supported.
          content:
            application/json:
              schema:
                type: object
                properties:
                  title:
                    type: string
                  description:
                    type: string
              examples:
                unsupported:
                  value:
                    title: Unsupported media type
                    description: Content type is not supported
        '429':
          description: >-
            This response is returned when the number of requests per minute has
            exceeded the rate limit, or the number of templates has exceeded the
            allowed quota per channel.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                rate_limit:
                  value:
                    response_id: OUUkHvcn
                    type: custom_template
                    error:
                      code: Too Many Requests
                      message: 'API rate limit breached. Current limit: n/m mins'
        '500':
          description: >-
            This response is returned when the system runs into an unexpected
            error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  title:
                    type: string
                  message:
                    type: string
              examples:
                server_error:
                  value:
                    title: Internal Server Error
                    message: >-
                      An unexpected error was encountered while processing this
                      request. Please contact MoEngage Team
components:
  schemas:
    BasicDetails:
      type: object
      description: >
        This field contains the email content. This is where you define the
        email template being created.
      required:
        - email_content
        - subject
        - thumbnail_url
        - sender_name
      properties:
        email_content:
          type: string
          description: This field contains the title of the message.
        subject:
          type: string
          description: |
            This field contains the subject of the email campaign.
            **Example**: "End of Season Sale!"
        attachments:
          type: array
          description: >
            This field contains the attachments to be included in the email.


            **Note**:

            * Only URLs can be added as part of Email attachments.

            * A maximum of ten attachments are allowed.

            * The URL should start with https and end with a valid extension.
            The following extensions are not allowed: .dmg, .exe, .xls, .ddl,
            .class, .obj, .int, .gnt, .o, .so, .lbr, and .net

            * Individual attachments should be less than 6 MB, and the total
            size of the attachments should be less than 20 MB.
          items:
            type: string
            format: uri
            example: https://app-cdn.moengage.com/assets/LogoThumbnail.jpg
        thumbnail_url:
          type: string
          description: >-
            This field contains the image URL used to generate a preview in the
            Imported API Templates section on the MoEngage dashboard.
        sender_name:
          type: string
          description: >
            This field contains the name that is displayed in the inboxes of
            your recipients. Sender names are one of the first things people see
            when you send them an email.

            **Example**: "sender_name": "Your Brand Name"
        preview_text:
          type: string
          description: >
            This field contains the preview text, the text that appears below
            the subject line in the inbox.

            Example: "preview_text": "Let Your Summer Look Shine"
    MetaInfo:
      type: object
      description: >
        This field contains information about the template being created, such
        as the name, version, and ID of the template and the creator's details.
      required:
        - template_id
        - template_name
        - template_version
        - created_by
      properties:
        template_id:
          type: string
          description: >-
            This field contains the ID for the template and is unique. This ID
            should be generated by you and will be used for updating or
            retrieving the template using the template APIs.
        template_name:
          type: string
          description: >-
            This field contains the name of the template. This value should be
            generated by you and would be used for identifying the template.
        template_version:
          type: string
          description: >-
            This field contains the version of the template and is unique. This
            value should be generated by you and would be used for tracking the
            template's version.
        created_by:
          type: string
          description: >-
            This field contains details about who created the template. This
            value should be generated by you. For example, you can pass the
            email id of the user creating the template here.
        locale:
          type: string
          description: >
            This field contains the locale to be associated with the template.

            These are the locales available in the MoEngage Dashboard at
            **Settings > Advanced settings > Locales**.
        variation:
          type: integer
          description: >-
            This field contains the variation of the template. You can add a
            maximum of five variations to each template.
        group_id:
          type: string
          description: >
            This field contains the group ID of the template.

            * Parent template: A parent template is the "default" template with
            which you can associate child templates. You need not pass a Group
            ID for a parent template. The "external_template_id" generated for
            the parent template acts as its group ID.

            * Child template: Pass the Group ID of the parent (default) template
            with which you want to associate the child template.
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                This field contains the error code that provides a brief
                explanation of the error and is a String. For example, 400 - Bad
                Request, 401- Authentication required, and so on.
            message:
              type: string
              description: This field describes why the request has failed and is a String.
            details:
              type: array
              description: This is a List of the error details objects.
              items:
                type: object
                properties:
                  code:
                    type: string
                    description: Descriptive Error Code
                  target:
                    type: string
                    description: >-
                      Denotes the field causing the issue or a brief description
                      of the error message in some cases
                  message:
                    type: string
                    description: Descriptive Error Message
            request_id:
              type: string
              description: This field contains the unique id pertaining to the request.
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >
        Authentication is done via Basic Auth. This requires a base64-encoded
        string of your credentials in the format 'username:password'.


        - **Username**: Use your MoEngage workspace ID (also known as the App
        ID). You can find it in the MoEngage dashboard at **Settings** >
        **Account** > **APIs** > **Workspace ID (earlier app id)**.

        - **Password**: Use your API Key, which you can find within the
        **Campaign report/Business events/Custom templates/Catalog API/Inform
        Report** tile.


        For more information on authentication and getting your credentials,
        refer
        [here](https://www.moengage.com/docs/api/introduction#getting-your-credentials).

````