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

# Create a transactional email

> Create a new transactional email and its draft email message, ready for editing, previewing, and publishing through the Loops API.

This endpoint creates a transactional email and an empty draft email message in one step.

Use the returned `draftEmailMessageId` and `draftEmailMessageContentRevisionId` when calling the [Update email message](/docs/api-reference/update-email-message) endpoint to set subject, sender, preview text, and LMX content

Call [Publish transactional email draft](/docs/api-reference/publish-transactional-email) to publish.


## OpenAPI

````yaml /openapi.json post /v1/transactional-emails
openapi: 3.1.0
info:
  title: Loops OpenAPI Spec
  description: This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
  version: 1.21.0
servers:
  - url: https://app.loops.so/api
security: []
tags:
  - name: API key
  - name: Audience segments
    description: View audience segments
  - name: Campaigns
    description: Create and manage email campaigns
  - name: Campaign groups
    description: Organize campaigns into groups
  - name: Components
    description: View email components
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - name: Email messages
    description: Manage email message content for campaigns
  - name: Events
    description: Trigger workflows with events
  - name: Event patterns
    description: View workflow event patterns
  - name: Mailing lists
    description: View mailing lists
  - name: Themes
    description: View email themes
  - name: Transactional emails
    description: Create, manage, and send transactional emails
  - name: Transactional groups
    description: Organize transactional emails into groups
  - name: Uploads
    description: Upload image assets
  - name: Workflows
    description: View and mutate workflow graphs
  - name: Workflow nodes
    description: View and mutate workflow nodes
paths:
  /v1/transactional-emails:
    post:
      tags:
        - Transactional emails
      summary: Create a transactional email
      description: >-
        Create a new transactional email. An empty draft email message is
        created automatically and its `draftEmailMessageId` is returned. Use the
        `POST /v1/email-messages/{emailMessageId}` endpoint along with the
        returned `draftEmailMessageContentRevisionId` to set subject, sender,
        preview text, and LMX content, then call `POST
        /v1/transactional-emails/{transactionalId}/publish` to publish the
        draft.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTransactionalRequest'
      responses:
        '201':
          description: Transactional email created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionalDraftResponse'
        '400':
          description: Invalid request body or no sending domain configured.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionalFailureResponse'
        '401':
          description: Invalid API key or content API not enabled for this team.
        '405':
          description: Wrong HTTP request method.
      security:
        - apiKey: []
components:
  schemas:
    CreateTransactionalRequest:
      type: object
      properties:
        name:
          type: string
          description: The name of the transactional email.
          examples:
            - Welcome email
        transactionalGroupId:
          type: string
          description: >-
            The ID of the group to add this transactional email to. Defaults to
            the team's default group when omitted.
      required:
        - name
      additionalProperties: false
    TransactionalDraftResponse:
      type: object
      properties:
        id:
          type: string
          description: The ID of the transactional email.
        name:
          type: string
          description: The name of the transactional email.
        draftEmailMessageId:
          type:
            - string
            - 'null'
          description: The ID of the draft email message.
        draftEmailMessageContentRevisionId:
          type:
            - string
            - 'null'
          description: >-
            The `contentRevisionId` of the draft email message. Pass this as
            `expectedRevisionId` on your first update via `POST
            /v1/email-messages/{emailMessageId}`.
        publishedEmailMessageId:
          type:
            - string
            - 'null'
          description: >-
            The ID of the published email message. `null` if there is no
            published version.
        transactionalGroupId:
          type:
            - string
            - 'null'
          description: >-
            The ID of the group this transactional email belongs to. Returned
            when creating a transactional email.
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp for when the transactional email was created.
        updatedAt:
          type: string
          format: date-time
          description: >-
            ISO 8601 timestamp for when the transactional email was last
            updated.
        dataVariables:
          type: array
          description: >-
            Data variable names used by the published email. Empty for
            unpublished transactional emails.
          items:
            type: string
      required:
        - id
        - name
        - draftEmailMessageId
        - draftEmailMessageContentRevisionId
        - publishedEmailMessageId
        - createdAt
        - updatedAt
        - dataVariables
    TransactionalFailureResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

## Related topics

- [Transactional email API examples](/docs/api-reference/examples/transactional-emails.md)
- [Auth.js](/docs/integrations/authjs.md)
- [Transactional email](/docs/transactional.md)
- [API Introduction](/docs/api-reference/intro.md)
- [Send emails from Bolt.new](/docs/guides/bolt-emails.md)
