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

# Create Template

> API to create a new template in Mailercloud.

**Required Fields:**

- name:  Name of the template (required, max 100 characters, must be unique)

- html:  Specifies the HTML content (required) 

**Optional Fields:**

- categoryId:  Specifies the category ID of the template, you can get it from the **Get Template Categories** API. It would be 0 by default.

- plainText:  Specifies the plain text content



## OpenAPI

````yaml /openapi-v1.json post /templates/create
openapi: 3.1.0
info:
  title: Mailercloud Marketing API
  version: 1.0.0
  description: >-
    Campaigns, contacts, lists, segments, automations, and webhooks for the
    Mailercloud Marketing Platform.
servers:
  - url: https://cloudapi.mailercloud.com/v1
security:
  - apiKey: []
tags:
  - name: Campaigns
  - name: Contacts
  - name: Lists
  - name: Tags
  - name: Segments
  - name: Custom Properties
  - name: Senders
  - name: Templates
  - name: Automations
  - name: Webhooks
  - name: Webforms
  - name: Inbox Tracker
  - name: Account
paths:
  /templates/create:
    post:
      tags:
        - Templates
      summary: Create Template
      description: >-
        API to create a new template in Mailercloud.


        **Required Fields:**


        - name:  Name of the template (required, max 100 characters, must be
        unique)


        - html:  Specifies the HTML content (required) 


        **Optional Fields:**


        - categoryId:  Specifies the category ID of the template, you can get it
        from the **Get Template Categories** API. It would be 0 by default.


        - plainText:  Specifies the plain text content
      operationId: create-template
      parameters:
        - name: Content-Type
          in: header
          required: false
          description: Request body type
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                categoryId:
                  type: integer
                html:
                  type: string
                name:
                  type: string
                plainText:
                  type: string
              x-examples:
                Example 1:
                  categoryId: 0
                  html: <html><body> Sample HTML </body></html>
                  name: New Template
                  plainText: Sample HTML
            examples:
              Example-1:
                value:
                  categoryId: 0
                  html: <html><body> Sample HTML </body></html>
                  name: New Template
                  plainText: Sample HTML
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-examples:
                  Example 1: {}
              examples:
                Example-1:
                  value:
                    id: EyK
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                x-examples:
                  Example 1:
                    error: html is a required field
              examples:
                Example-1:
                  value:
                    error: html is a required field
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                        message:
                          type: string
                x-examples:
                  Example 1:
                    errors:
                      - field: ''
                        message: Authorization failed
              examples:
                Example-1:
                  value:
                    errors:
                      - field: ''
                        message: Authorization failed
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your Mailercloud API key (plain text, no Bearer prefix). Create keys in
        Settings → API.

````