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

# Create a template

> Create a new email template. Templates allow you to reuse email content and sender settings across transactional emails and campaigns.



## OpenAPI

````yaml POST /templates
openapi: 3.1.0
info:
  title: SendKit API
  description: The SendKit API allows you to send transactional emails programmatically.
  version: 1.0.0
servers:
  - url: https://api.sendkit.dev
security:
  - bearerAuth: []
paths:
  /templates:
    post:
      tags:
        - Templates
      summary: Create a template
      description: >-
        Create a new email template. Templates allow you to reuse email content
        and sender settings across transactional emails and campaigns.
      operationId: createTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTemplateRequest'
      responses:
        '201':
          description: Template created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Template'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    CreateTemplateRequest:
      type: object
      required:
        - name
        - sender_id
        - subject
      properties:
        name:
          type: string
          maxLength: 255
          description: The name of the template.
          example: Welcome Email
        folder_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Optional folder ID to organize the template.
        sender_id:
          type: string
          format: uuid
          description: >-
            The ID of the sender to use for this template. Must belong to your
            account.
          example: 550e8400-e29b-41d4-a716-446655440000
        subject:
          type: string
          maxLength: 255
          description: The email subject line. Supports {{VARIABLE}} placeholders.
          example: Welcome to {{COMPANY}}
        html_content:
          type:
            - string
            - 'null'
          description: >-
            The HTML content of the template. Supports {{VARIABLE}}
            placeholders.
          example: <h1>Welcome, {{FIRST_NAME}}!</h1>
        text_content:
          type:
            - string
            - 'null'
          description: >-
            The plain text content of the template. Supports {{VARIABLE}}
            placeholders.
          example: Welcome, {{FIRST_NAME}}!
        reply_to:
          type:
            - string
            - 'null'
          format: email
          maxLength: 255
          description: The reply-to email address.
          example: support@yourdomain.com
        status:
          type: string
          enum:
            - published
            - draft
          description: The template status. Defaults to published.
          default: published
          example: published
        variables:
          type:
            - array
            - 'null'
          items:
            type: object
            required:
              - key
              - type
            properties:
              key:
                type: string
                description: The variable key.
                example: FIRST_NAME
              type:
                type: string
                description: The data type of the variable.
                example: string
              fallback_value:
                type:
                  - string
                  - 'null'
                description: Default value used when the variable is not provided.
                example: there
          description: Template variables configuration.
    Template:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier.
          example: 550e8400-e29b-41d4-a716-446655440000
        folder_id:
          type:
            - string
            - 'null'
          format: uuid
          description: The folder this template belongs to. Null if unassigned.
          example: null
        name:
          type: string
          description: The name of the template.
          example: Welcome Email
        subject:
          type: string
          description: The email subject line.
          example: Welcome to {{COMPANY}}
        html_content:
          type:
            - string
            - 'null'
          description: The HTML content of the template.
          example: <h1>Welcome, {{FIRST_NAME}}!</h1><p>Thanks for joining.</p>
        text_content:
          type:
            - string
            - 'null'
          description: The plain text content of the template.
          example: Welcome, {{FIRST_NAME}}! Thanks for joining.
        reply_to:
          type:
            - string
            - 'null'
          format: email
          description: The reply-to email address for emails sent with this template.
          example: support@yourdomain.com
        status:
          type: string
          enum:
            - published
            - draft
          description: >-
            The template status. Only published templates can be used for
            sending.
          example: published
        sender:
          $ref: '#/components/schemas/SenderSummary'
          description: The sender associated with this template.
        variables:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              key:
                type: string
                description: The variable key used in {{KEY}} placeholders.
                example: FIRST_NAME
              type:
                type: string
                description: The data type of the variable.
                example: string
              fallback_value:
                type:
                  - string
                  - 'null'
                description: Default value used when the variable is not provided.
                example: there
          description: The template variables and their configuration.
        created_at:
          type: string
          format: date-time
          description: When the template was created.
          example: '2026-03-03 10:00:00'
        updated_at:
          type: string
          format: date-time
          description: When the template was last updated.
          example: '2026-03-03 10:00:00'
    SenderSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier.
          example: 550e8400-e29b-41d4-a716-446655440000
        name:
          type: string
          description: The sender display name.
          example: John Doe
        username:
          type: string
          description: The username part of the sender email address.
          example: john
        email:
          type: string
          format: email
          description: The full sender email address (computed from username and domain).
          example: john@yourdomain.com
        reply_to:
          type:
            - string
            - 'null'
          format: email
          description: The reply-to email address.
          example: reply@yourdomain.com
        created_at:
          type: string
          format: date-time
          description: When the sender was created.
          example: '2026-03-03 10:00:00'
        updated_at:
          type: string
          format: date-time
          description: When the sender was last updated.
          example: '2026-03-03 10:00:00'
    ErrorResponse:
      type: object
      properties:
        name:
          type: string
          description: Error type identifier.
          example: validation_error
        message:
          type: string
          description: Human-readable error message.
          example: The from address domain is not verified.
  responses:
    Unauthorized:
      description: Unauthorized — missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            message: Invalid API key.
    ValidationError:
      description: Validation error — invalid or missing parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            message: The email field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key from your SendKit dashboard. Pass it as a Bearer token in the
        Authorization header.

````