> ## 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 In-app Template

> This API creates an In-app template in MoEngage. You can use this API to upload templates created outside the MoEngage ecosystem to MoEngage and use them for campaign creation.

<Note>
  **Information**

  Only self-handled and HTML template types are supported.
</Note>


## OpenAPI

````yaml /api/in-app-templates/in-app-templates.yaml post /custom-templates/inapp
openapi: 3.0.3
info:
  title: MoEngage In-app Template API
  version: '1.0'
  description: >-
    API for creating, updating, and searching In-app templates (Self-Handled and
    HTML) within the MoEngage platform.
servers:
  - url: https://api-{dc}.moengage.com/v1.0
    description: MoEngage Custom Templates 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: In-app Templates
    description: Operations to manage In-app templates.
paths:
  /custom-templates/inapp:
    post:
      tags:
        - In-app Templates
      summary: Create In-app Template
      description: >-
        This API creates an In-app template in MoEngage. You can use this API to
        upload templates created outside the MoEngage ecosystem to MoEngage and
        use them for campaign creation.
      requestBody:
        required: true
        description: The details of the In-app template to be created.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateInAppTemplateRequest'
            examples:
              self_handled:
                summary: Self-Handled Template
                value:
                  basic_details:
                    payload: '{''jsonKey'': ''jsonValue'', ''title'': ''hello world''}'
                    inapp_template_type: SELF_HANDLED
                  meta_info:
                    created_by: test@example.com
                    template_id: self_handled_123
                    template_name: My Self-Handled Template
                    template_version: '1'
              html:
                summary: HTML Template
                value:
                  basic_details:
                    payload: <html><body><h1>Hello World</h1></body></html>
                    inapp_template_type: INAPP_HTML
                  meta_info:
                    created_by: test@example.com
                    template_id: html_promo_456
                    template_name: My HTML Promo
                    template_version: '1'
      responses:
        '200':
          description: Template created successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  external_template_id:
                    type: string
                    format: uuid
                    description: >-
                      This field contains the unique ID corresponding to a
                      successful custom template creation. This template ID is
                      used as header input for update, search, or any kind of
                      template modifications in later stage.
                    example: 4a1afbc5-4c31-4f19-8c23-793e27af01aa
        '400':
          description: >-
            Bad Request. This response is returned when the required parameters
            are missing from the request, 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'
              example:
                error:
                  code: 400 Bad Request
                  message: Validation failed because of invalid request data
                  details:
                    - code: MissingValue
                      target: template_id
                      message: template_id value is required but value is passed empty.
                  request_id: NpiintyO
        '401':
          description: >-
            Authorization Failure. This response is returned when the
            authorization parameters are missing in the HTTP Auth Header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '415':
          description: >-
            Unsupported File Type. This response is returned when the header 
            Content-Type is not provided/is not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            Rate Limit Breach. 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'
        5XX:
          description: >-
            Internal Server Error. This response is returned when the system
            runs into an unexpected error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateInAppTemplateRequest:
      type: object
      required:
        - basic_details
        - meta_info
      properties:
        basic_details:
          type: object
          description: >-
            This field contains details about the template to be created,
            including its payload and template type.
          required:
            - payload
            - inapp_template_type
          properties:
            payload:
              type: string
              description: A stringified JSON or HTML content for the template.
            inapp_template_type:
              type: string
              enum:
                - SELF_HANDLED
                - INAPP_HTML
        meta_info:
          type: object
          description: >-
            This field contains information about the template being created,
            such as its name, version, and ID and the creator's details.
          required:
            - created_by
            - template_id
            - template_name
            - template_version
          properties:
            created_by:
              type: string
              description: Identifier for the creator of the template.
            template_id:
              type: string
              description: A unique ID for the template provided by you.
            template_name:
              type: string
              description: The name of the template.
            template_version:
              type: string
              description: The version of the template.
    ErrorResponse:
      type: object
      description: This field contains the reason for the request's failure.
      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. This field is
                present in the response only in the case of errors.
            message:
              type: string
              description: >-
                This field describes why the request has failed and is a String.
                For example, in the case of a duplicate request (400- Bad
                Request), the following message will be present: 'Duplicate -
                template_id and template_version'.
            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).

````