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

# Send Email

> Send one generated email to a single recipient, audience, segment, or tag. Provide emailId to send a specific email from a conversation or series. conversationId remains supported for single-email conversations. All sends are queued for background delivery and return immediately with status queued. Single-recipient sends are transactional by default; batch sends default to marketing. Requires API key with email:send.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sending
openapi: 3.1.0
info:
  title: Migma.ai API (v1)
  description: >-
    API for managing brands, contacts, email generation, sending, and
    integrations.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.migma.ai
    description: Production
security:
  - apiKeyAuth: []
tags:
  - name: Projects/Brands
    description: Manage projects (brands) and import from websites
  - name: Contacts
    description: Manage your contacts, segments, tags, and topics
  - name: Segments
    description: Create and manage dynamic contact segments
  - name: Tags
    description: Organize contacts with tags
  - name: Topics
    description: Manage subscription topics and preferences
  - name: Emails
    description: Generate, send, and export emails
  - name: Email Validation
    description: Validate email content for compatibility and deliverability
  - name: Email Previews
    description: Preview emails across devices and email clients
  - name: Domains
    description: Manage sending domains and verification
  - name: Webhooks
    description: Manage webhook endpoints for real-time event notifications
  - name: Integrations
    description: Third-party platform integrations
  - name: Campaigns
    description: Create, schedule, send, and manage email campaigns
  - name: Project Editing
    description: Edit project assets, logos, images, and knowledge base entries
paths:
  /v1/sending:
    post:
      tags:
        - Emails
      summary: Send Email
      description: >-
        Send one generated email to a single recipient, audience, segment, or
        tag. Provide emailId to send a specific email from a conversation or
        series. conversationId remains supported for single-email conversations.
        All sends are queued for background delivery and return immediately with
        status queued. Single-recipient sends are transactional by default;
        batch sends default to marketing. Requires API key with email:send.
      operationId: SendEmail
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendEmailRequest'
      responses:
        '200':
          description: Email sent or batch queued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponseSendEmail'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
      x-codeSamples:
        - lang: javascript
          label: Node.js SDK
          source: |-
            import Migma from 'migma';

            const migma = new Migma('YOUR_API_KEY');

            const { data, error } = await migma.sending.send({
              recipientType: 'email',
              recipientEmail: 'recipient@example.com',
              from: 'hello@yourbrand.migma.email',
              fromName: 'Your Brand',
              subject: 'Hello!',
              emailId: 'EMAIL_ID'
            });
        - lang: javascript
          label: Batch Transactional
          source: |-
            import Migma from 'migma';

            const migma = new Migma('YOUR_API_KEY');

            const { data, error } = await migma.sending.send({
              recipientType: 'tag',
              recipientId: 'TAG_ID',
              from: 'noreply@yourbrand.migma.email',
              fromName: 'Your Brand',
              subject: 'Your subscription renews tomorrow',
              emailId: 'EMAIL_ID',
              transactional: true
            });
components:
  schemas:
    SendEmailRequest:
      type: object
      properties:
        recipientType:
          type: string
          enum:
            - email
            - audience
            - segment
            - tag
          description: >-
            Type of recipient. 'email' for single send, 'audience' or 'segment'
            for segment-based batch sends, 'tag' for tag-based batch sends.
        recipientId:
          type: string
          description: Required for audience/segment/tag sends. The segment or tag ID.
        recipientEmail:
          type: string
          format: email
          description: Required for single email sends.
        from:
          type: string
          format: email
          description: Sender email address (must be from a verified domain)
        fromName:
          type: string
          description: Sender display name
        replyTo:
          type: string
          format: email
        subject:
          type: string
        variables:
          type: object
          additionalProperties: true
          description: Template variables for personalization
        providerType:
          type: string
          description: >-
            Email service provider to send through. Defaults to Migma's built-in
            sending. To use an external provider, connect it first in Settings →
            Integrations → Email Providers.
          enum:
            - ses
            - resend
            - sendgrid
            - mailgun
            - migma
          default: migma
        projectId:
          type: string
          description: >-
            Project ID. Optional when emailId or conversationId resolves the
            project automatically.
        conversationId:
          type: string
          description: >-
            Conversation ID from a generated email. Works for single-email
            conversations. For series, use emailId.
        transactional:
          type: boolean
          description: >-
            Controls whether the email is treated as transactional (order
            confirmations, password resets) or marketing. Defaults to true for
            single sends (recipientType 'email') and false for batch sends
            (recipientType 'audience', 'segment', 'tag'). Transactional emails
            bypass subscription status and topic preference filters, and omit
            List-Unsubscribe headers. Bounced and invalid addresses are always
            excluded. Set explicitly to override the default.
        emailId:
          type: string
          description: >-
            Generated email ID from result.emails[].emailId. Recommended for all
            generated emails and required for series slots.
      required:
        - recipientType
        - from
        - fromName
        - subject
    ApiResponseSendEmail:
      allOf:
        - $ref: '#/components/schemas/ApiResponse'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/SendEmailResult'
    ApiResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          nullable: true
        error:
          type: string
          nullable: true
      required:
        - success
    SendEmailResult:
      type: object
      properties:
        id:
          type: string
          description: Message ID (for single sends) or batch ID (for batch sends)
        provider:
          type: string
        status:
          type: string
          description: sent, queued, or processing
        sentCount:
          type: integer
        message:
          type: string
    ApiError:
      type: object
      properties:
        success:
          type: boolean
          default: false
        error:
          type: string
      required:
        - success
        - error
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Forbidden:
      description: Forbidden - Missing required permissions or access denied
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Use 'Authorization: Bearer YOUR_API_KEY' where
        YOUR_API_KEY is obtained from the Migma dashboard under Settings → API
        Integration.

````