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

# Create an email trigger

> Creates a trigger that starts a flow when a message arrives at the generated address. The response carries the draft and published addresses. Flow trigger nodes of type `email`, `mail` (Microsoft 365 mail automations) and `email-delivery` (delivery events for emails sent from templates) are configured on the flow itself, see the flows API.



## OpenAPI

````yaml /api-reference/endpoint/trigger/openapi.json post /trigger/email
openapi: 3.0.3
info:
  title: quiva.ai Triggers API
  description: >-
    Manages the triggers that start automation in response to events — create,
    retrieve and delete gateway triggers (custom API endpoints that kick off a
    flow) and stream triggers (real-time data flowing from a source into a
    target).
  contact:
    name: quiva.ai Support
  version: '1.0'
servers:
  - url: https://api.quiva.ai
    description: Production API server
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Triggers
    description: Gateway, stream and object store triggers
  - name: Email triggers
    description: Emails received by email triggers
paths:
  /trigger/email:
    post:
      tags:
        - Email Triggers
      summary: Create an email trigger
      description: >-
        Creates a trigger that starts a flow when a message arrives at the
        generated address. The response carries the draft and published
        addresses. Flow trigger nodes of type `email`, `mail` (Microsoft 365
        mail automations) and `email-delivery` (delivery events for emails sent
        from templates) are configured on the flow itself, see the flows API.
      operationId: createEmailTrigger
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailTriggerRequest'
      responses:
        '200':
          description: Trigger created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailTriggerResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    EmailTriggerRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Unique trigger name
        collection:
          type: string
        description:
          type: string
        flow_subject:
          type: string
          description: >-
            Subject of the flow the trigger starts. A draft subject is stored as
            its published subject.
    EmailTriggerResponse:
      type: object
      properties:
        body:
          type: object
          properties:
            body:
              type: object
              properties:
                name:
                  type: string
                collection:
                  type: string
                description:
                  type: string
                subject:
                  type: string
                trigger_type:
                  type: string
                  enum:
                    - email
                type:
                  type: string
                flow_subject:
                  type: string
                email_published:
                  type: string
                  description: Generated address that starts the published flow
                email_draft:
                  type: string
                  description: Generated address that starts the draft flow
        status_code:
          type: integer
    Error:
      type: object
      properties:
        error:
          type: string
          description: >-
            Detailed error message explaining what went wrong and potential
            solutions.
          example: 'Invalid request: Missing required field'
        status_code:
          type: integer
          description: HTTP status code indicating the specific error type.
          example: 400
  responses:
    BadRequest:
      description: >-
        Invalid request. Occurs when required parameters are missing, validation
        fails, or the request format is incorrect.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: >-
              Invalid request: Missing required field 'name' in trigger
              definition
            status_code: 400
    Unauthorized:
      description: >-
        Unauthorized access. Occurs when authentication is missing or invalid,
        or when the authenticated user lacks permission.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'Unauthorized: Invalid or missing authentication token'
            status_code: 401
    InternalServerError:
      description: >-
        Internal server error. Occurs when an unexpected condition prevents the
        server from fulfilling the request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'Internal server error: Unable to process request at this time'
            status_code: 500
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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