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

# Create an email template

> Create an email template. With a `prompt`, AI generation starts asynchronously (`202` — poll the returned generation). Without one the template is created synchronously (`201`) — seeded from your `code` when provided, otherwise a blank scaffold branded from your workspace. Approve a template to let `POST /v1/emails` seed new emails from its HTML and default sender headers.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/email-templates
openapi: 3.1.0
info:
  title: Tented API
  version: 1.0.0
  description: >-
    The Tented public API: generate, publish, and manage AI-built web pages
    (tents), and run the email platform — contacts, reusable emails, one-time
    blasts, and triggered flows.


    ## Authentication

    Authenticate every request with a workspace API key: `Authorization: Bearer
    <api-key>`. Keys are created in **Workspace Settings → API Keys** and are
    scoped to a single workspace.


    ## Asynchronous work

    Tent generation, bulk creation, and email AI generation return `202
    Accepted` immediately. Poll the corresponding status endpoint (`GET
    /v1/tents/{tentId}`, `GET /v1/bulk-jobs/{bulkJobId}`, `GET
    /v1/emails/{emailId}/generations/{generationId}`) — no more than every 10
    seconds.


    ## Pagination

    Email listings use cursor pagination (`cursor`/`next_cursor`). Blast, flow,
    and member listings use page pagination (`page`/`limit` with a `pagination`
    object in the response).


    ## Conventions

    Request and response fields are snake_case, with two exceptions: analytics
    query parameters (`tentIdOrAlias`, `daysBack`) and segment rule trees
    (camelCase keys such as `listId` and `timeWindow`).
  contact:
    name: Tented Support
    email: support@tented.ai
servers:
  - url: https://api.tented.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Tents
    description: >-
      Create, edit, publish, and manage AI-generated pages, including asset
      uploads and bulk creation.
  - name: Analytics
    description: Traffic analytics for single tents and the whole workspace.
  - name: Contacts
    description: >-
      Batch create, update, and delete contacts. Up to 25 items per request with
      per-item results.
  - name: Emails
    description: >-
      Reusable email content: AI generation, direct HTML edits, plain-text
      control, and approval.
  - name: Email Blasts
    description: >-
      One-time sends to an audience: compose, schedule, track engagement, export
      recipients.
  - name: Triggered Flows
    description: >-
      Multi-step automations that enroll contacts on triggers and move them
      through a step graph.
  - name: Contact Imports
  - name: Contact Fields
  - name: Contact Lists
  - name: Email Templates
  - name: Tent Templates
    description: >-
      Reusable, AI-editable tent layouts. Create from HTML or an existing tent,
      iterate with AI, approve, and clone. Approved tent templates seed new
      tents.
paths:
  /v1/email-templates:
    post:
      tags:
        - Email Templates
      summary: Create an email template
      description: >-
        Create an email template. With a `prompt`, AI generation starts
        asynchronously (`202` — poll the returned generation). Without one the
        template is created synchronously (`201`) — seeded from your `code` when
        provided, otherwise a blank scaffold branded from your workspace.
        Approve a template to let `POST /v1/emails` seed new emails from its
        HTML and default sender headers.
      operationId: create-email-template
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
          description: >-
            Optional idempotency key. Replaying a request with the same key
            returns the stored result of the first attempt. If the first attempt
            is still in flight, the replay fails with `409
            idempotency_in_progress`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: Internal name (never shown to recipients).
                code:
                  type: string
                  minLength: 1
                  description: >-
                    Template HTML (up to 2 MB) for a hand-authored template.
                    Mutually complementary with `prompt`: provide `code` to
                    upload HTML, `prompt` to generate it.
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 10000
                  description: AI brief describing the template to generate.
                default_subject:
                  type:
                    - string
                    - 'null'
                  maxLength: 998
                  description: >-
                    Default subject line copied onto emails seeded from this
                    template.
                default_preview_text:
                  type:
                    - string
                    - 'null'
                  maxLength: 200
                  description: Default preheader text for seeded emails.
                default_from_name:
                  type:
                    - string
                    - 'null'
                  maxLength: 120
                  description: Default sender display name for seeded emails.
                default_from_address:
                  type:
                    - string
                    - 'null'
                  description: >-
                    Default sender address for seeded emails. Sending still
                    requires a verified domain.
                default_reply_to_email:
                  type:
                    - string
                    - 'null'
                  description: Default reply-to address for seeded emails.
              required:
                - name
      responses:
        '201':
          description: Template created (no prompt supplied).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailTemplate'
        '202':
          description: >-
            AI generation started — poll `GET
            /v1/email-templates/{templateId}/generations/{generationId}`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailTemplateAsyncAccepted'
        '400':
          description: >-
            Bad request — invalid parameters or request body. Validation
            failures include `details.issues` with per-field messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized — missing, malformed, revoked, or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Conflict — see `error_code` for the specific reason.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    EmailTemplate:
      allOf:
        - $ref: '#/components/schemas/EmailTemplateListItem'
        - type: object
          properties:
            latest_generation_status:
              type: string
              enum:
                - generating
                - completed
                - failed
              description: Status of the most recent AI generation, when one exists.
            content_path:
              type: string
              description: >-
                API path to fetch the latest HTML, e.g.
                `/v1/email-templates/{templateId}/content`.
            plain_text_path:
              type: string
              description: API path to fetch the plain-text rendition.
      description: Full email template object.
    EmailTemplateAsyncAccepted:
      type: object
      properties:
        template_id:
          type: string
          format: uuid
          description: Email template ID.
        generation_id:
          type: string
          description: >-
            Generation to poll via `GET
            /v1/email-templates/{templateId}/generations/{generationId}`.
        message_id:
          type: string
          description: Chat message recorded for the prompt.
        status:
          type: string
          description: Always `generating` on acceptance.
      required:
        - template_id
        - generation_id
        - status
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
        error_code:
          type: string
          description: >-
            Stable machine-readable error code (present on email, blast, flow,
            and related endpoints, e.g. `campaign_not_ready`,
            `generation_in_progress`).
        message:
          type: string
          description: Additional human-readable context (present on some tent endpoints).
        code:
          type: string
          description: >-
            Machine-readable code used by tent creation errors (e.g.
            `INVALID_PROMPT_INTENT`).
        details:
          type: object
          additionalProperties: true
          description: >-
            Additional error context. Validation errors include `issues`: an
            array of `{ path, message }` objects.
        limit:
          type: integer
          description: Plan limit that was hit (present on `429` publish-limit errors).
        current:
          type: integer
          description: >-
            Current usage against the limit (present on `429` publish-limit
            errors).
      required:
        - error
      description: >-
        Error response. All errors include `error`; the other fields vary by
        endpoint group.
    EmailTemplateListItem:
      type: object
      properties:
        template_id:
          type: string
          format: uuid
          description: Email template ID.
        name:
          type: string
          description: Internal name (never shown to recipients).
        status:
          type: string
          enum:
            - draft
            - approved
          description: Lifecycle state.
        source_type:
          type: string
          enum:
            - upload
            - email
          description: >-
            How the template was created: `upload` for API- or hand-created
            templates, `email` for templates saved from an existing email.
        source_email_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Email the template was saved from, when `source_type` is `email`.
        default_subject:
          type:
            - string
            - 'null'
          description: Default subject line copied onto emails seeded from this template.
        default_preview_text:
          type:
            - string
            - 'null'
          description: Default preheader text for seeded emails.
        default_from_name:
          type:
            - string
            - 'null'
          description: Default sender display name for seeded emails.
        default_from_address:
          type:
            - string
            - 'null'
          description: >-
            Default sender address for seeded emails. Sending requires a
            verified domain.
        default_reply_to_email:
          type:
            - string
            - 'null'
          description: Default reply-to address for seeded emails.
        current_version:
          type: integer
          description: Latest content version number.
        approved_version:
          type:
            - integer
            - 'null'
          description: Version that is approved, or `null`.
        number_of_iterations:
          type: integer
          description: Number of content versions (equals `current_version`).
        plain_text_overridden:
          type: boolean
          description: Whether plain text has been manually overridden.
        plain_text_overridden_at:
          type:
            - string
            - 'null'
          format: date-time
          description: When the plain-text override was set.
        plain_text_stale_after_html_iteration:
          type: boolean
          description: >-
            True when HTML changed after a plain-text override, so the override
            may be stale.
        created_at:
          type: string
          format: date-time
          description: Creation time.
        updated_at:
          type: string
          format: date-time
          description: Last update.
        created_by_name:
          type: string
          description: Who created the template (API key name or user).
      required:
        - template_id
        - name
        - status
        - current_version
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Workspace API key, e.g. `Authorization: Bearer tented_...`. Create keys
        in Workspace Settings → API Keys.

````