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

# Create an email template

> Create a new email template. Use when managing reusable email templates from code.



## OpenAPI

````yaml post /email-templates
openapi: 3.1.0
info:
  title: OpenCX API
  description: >

    OpenCX is an AI-powered, all-in-one platform for customer support and
    outbound communications.


    Use this API to manage your OpenCX organization's AI agents, actions,
    conversations, contacts, and more.


    To get started, generate a new API key from the dashboard.


    ## Authentication

    All API endpoints require authentication using a Bearer token. You can
    generate an API key from your OpenCX dashboard.


    ## Rate Limiting

    API requests are rate limited to ensure fair usage. The current limits are:

    - 100 requests per minute for standard endpoints

    - 1000 requests per minute for streaming endpoints


    ## Error Handling

    The API uses standard HTTP status codes and returns detailed error messages
    in the response body.
  version: 1.0-beta
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: http://localhost:8080
    description: Development
  - url: https://api.open.cx
    description: Production
security:
  - bearerAuth: []
paths:
  /email-templates:
    post:
      summary: Create an email template
      description: >-
        Create a new email template. Use {{variable}} syntax in subject and
        body; variables are extracted into a JSON schema on save.
      operationId: createEmailTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEmailTemplatePublicInput'
      responses:
        '201':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailTemplateDto'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
components:
  schemas:
    CreateEmailTemplatePublicInput:
      $ref: '#/components/schemas/CreateEmailTemplateBodyDto'
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/CreateEmailTemplatePublicInputInput'
    EmailTemplateDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/EmailTemplateDto'
      type: object
      properties:
        id:
          type: string
        actor_id:
          type: number
        body:
          type: string
        created_at:
          type: string
          format: date-time
        name:
          type: string
        org_id:
          type: string
        subject:
          type: string
        updated_at:
          type: string
          format: date-time
        payload:
          type: object
          properties:
            $schema:
              type: string
            $id:
              type: string
            title:
              type: string
            description:
              type: string
            type:
              type: string
            definitions:
              type: object
              propertyNames:
                type: string
              additionalProperties:
                type: object
                properties:
                  type:
                    type: string
                  properties:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties:
                      type: object
                      properties:
                        type:
                          type: string
                        description:
                          type: string
                        title:
                          type: string
                        additionalProperties:
                          type: boolean
                      required:
                        - type
                      additionalProperties: false
                  required:
                    type: array
                    items:
                      type: string
                  description:
                    type: string
                  title:
                    type: string
                  additionalProperties:
                    type: boolean
                required:
                  - type
                  - properties
                  - required
                additionalProperties: false
            properties:
              type: object
              propertyNames:
                type: string
              additionalProperties:
                type: object
                properties:
                  type:
                    type: string
                  description:
                    type: string
                  title:
                    type: string
                  additionalProperties:
                    type: boolean
                required:
                  - type
                additionalProperties: false
            required:
              type: array
              items:
                type: string
            additionalProperties:
              type: boolean
          required:
            - definitions
            - properties
          additionalProperties: {}
        language:
          type:
            - string
            - 'null'
        variable_defaults:
          anyOf:
            - type: object
              propertyNames:
                type: string
              additionalProperties:
                type: string
            - type: 'null'
      required:
        - id
        - actor_id
        - body
        - created_at
        - name
        - org_id
        - subject
        - updated_at
        - payload
        - language
        - variable_defaults
      additionalProperties: false
    ErrorDto:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
        error:
          type: string
    CreateEmailTemplateBodyDto:
      $schema: https://json-schema.org/draft/2020-12/schema
      $id: '#/components/schemas/CreateEmailTemplateBodyDtoInput'
      type: object
      properties:
        body:
          type: string
        name:
          type: string
        subject:
          type: string
        variable_defaults:
          anyOf:
            - type: object
              propertyNames:
                type: string
              additionalProperties:
                type: string
            - type: 'null'
      required:
        - body
        - name
        - subject
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.