components:
  schemas:
    Attachment:
      properties:
        content:
          description: the attachment data, encoded in base64
          type: string
        filename:
          description: the name of the attachment file
          type: string
        type:
          description: the MIME type of the attachment
          type: string
      required:
      - content
      - filename
      type: object
    ContentItem:
      properties:
        template_type:
          description: The template type of the content
          enum:
          - mustache
          type: string
        type:
          description: The mime type of the content you are including in your email
          type: string
        value:
          description: The actual content of the specified mime type that you are
            including in the message
          type: string
      required:
      - type
      - value
      type: object
    EmailAddress:
      properties:
        email:
          type: string
        name:
          type: string
      required:
      - email
      type: object
    ErrorResponse:
      properties:
        errors:
          description: 'This is an array error objects that provide machine and human
            readable descriptions of the errors.

            '
          items:
            type: string
          type: array
      type: object
    MailSendBody:
      properties:
        attachments:
          items:
            $ref: '#/components/schemas/Attachment'
          maxItems: 1000
          type: array
        campaign_id:
          description: 'The campaign identifier. If specified, this ID will be included
            in all relevant webhooks. It can be up to 48 UTF-8 characters long and
            must not contain spaces.

            '
          type: string
        content:
          items:
            $ref: '#/components/schemas/ContentItem'
          type: array
        from:
          $ref: '#/components/schemas/EmailAddress'
        headers:
          additionalProperties:
            type: string
          description: "A JSON object containing key-value pairs, where both keys\
            \ (header names) and values must be strings.\nThese pairs represent custom\
            \ headers to be substituted. Please note the following restrictions and\
            \ behavior:\n- Reserved headers: The following headers cannot be modified:\n\
            \  - Authentication-Results\n  - BCC\n  - CC\n  - Content-Transfer-Encoding\n\
            \  - Content-Type\n  - DKIM-Signature\n  - From\n  - Message-ID\n  - Received\n\
            \  - Reply-To\n  - Subject\n  - To\n- Header precedence: If a header is\
            \ defined in both the personalizations object and the root headers,\n\
            the value from personalizations will be used.\n- Case sensitivity: Headers\
            \ are treated as case-insensitive. If multiple headers differ only by\
            \ case,\nonly one will be used, with no guarantee of which one.\n"
          type: object
        mailfrom:
          $ref: '#/components/schemas/EmailAddress'
        personalizations:
          items:
            $ref: '#/components/schemas/Personalization'
          maxItems: 1000
          type: array
        reply_to:
          $ref: '#/components/schemas/EmailAddress'
        subject:
          type: string
        tracking_settings:
          description: "Settings to adjust open and click tracking for the message.\
            \ Please note that \nenabling tracking for your messages requires a subscription\
            \ that supports open \nand click tracking.\n"
          properties:
            click_tracking:
              properties:
                enable:
                  default: false
                  description: 'Setting to enable or disable click tracking for the
                    message.

                    This feature allows you to track when a recipient clicks a link
                    in your email.

                    '
                  type: boolean
              type: object
            open_tracking:
              properties:
                enable:
                  default: false
                  description: 'Setting to enable or disable open tracking for the
                    message.

                    This feature allows you to track when a recipient opens your email.

                    Please note that some email clients may not support open tracking.

                    '
                  type: boolean
              type: object
          type: object
      required:
      - personalizations
      - from
      - subject
      - content
      type: object
    Message:
      properties:
        data:
          description: a string representation of a rendered message, one per personalization
            in the request
          items:
            type: string
          type: array
      type: object
    Personalization:
      properties:
        bcc:
          items:
            $ref: '#/components/schemas/EmailAddress'
          maxItems: 1000
          type: array
        cc:
          items:
            $ref: '#/components/schemas/EmailAddress'
          maxItems: 1000
          type: array
        dkim_domain:
          type: string
        dkim_private_key:
          description: 'Encoded in Base64.

            '
          type: string
        dkim_selector:
          type: string
        dynamic_template_data:
          description: "A JSON object containing key-value pairs of variables to set\
            \ for template rendering. \nKeys must be strings, and values can be one\
            \ of the following types:\n* string\n* boolean\n* number\n* list, whose\
            \ values are all of permitted types\n* map, whose keys must be strings,\
            \ and whose values are all of permitted types\n"
          type: object
        from:
          $ref: '#/components/schemas/EmailAddress'
        headers:
          additionalProperties:
            type: string
          description: "A JSON object containing key-value pairs, where both keys\
            \ (header names) and values must be strings.\nThese pairs represent custom\
            \ headers to be substituted. Please note the following restrictions and\
            \ behavior:\n- Reserved headers: The following headers cannot be modified:\n\
            \  - Authentication-Results\n  - BCC\n  - CC\n  - Content-Transfer-Encoding\n\
            \  - Content-Type\n  - DKIM-Signature\n  - From\n  - Message-ID\n  - Received\n\
            \  - Reply-To\n  - Subject\n  - To\n- Header precedence: If a header is\
            \ defined in both the personalizations object and the root headers,\n\
            the value from personalizations will be used.\n- Case sensitivity: Headers\
            \ are treated as case-insensitive. If multiple headers differ only by\
            \ case,\nonly one will be used, with no guarantee of which one.\n"
          type: object
        reply_to:
          $ref: '#/components/schemas/EmailAddress'
        subject:
          type: string
        to:
          items:
            $ref: '#/components/schemas/EmailAddress'
          maxItems: 1000
          minItems: 1
          type: array
      required:
      - to
    SendResult:
      properties:
        index:
          description: 'The index of the personalization in the request. Starts at
            0.

            '
          type: integer
        message_id:
          description: "The Message ID is a unique identifier generated by the service.\
            \ \nEach personalization has a distinct Message ID, which is also used\
            \ in the `Message-Id` header and included in webhooks.\n"
          type: string
        reason:
          description: A human-readable explanation of the status.
          type: string
        status:
          description: "The status of the message. \nNote that 'sent' is a temporary\
            \ status; the final status will be provided through webhooks, if configured.\n"
          enum:
          - sent
          - failed
          type: string
      type: object
    SendResults:
      properties:
        request_id:
          description: "The Request ID is a unique identifier generated by the service\
            \ to track the HTTP request. \nIt will also be included in all webhooks\
            \ for reference.\n"
          type: string
        results:
          description: 'A list of results for each message sent.

            '
          items:
            $ref: '#/components/schemas/SendResult'
          type: array
      type: object
    Webhook:
      properties:
        webhook:
          description: A customer's webhook that events will be sent to
          type: string
      required:
      - webhook
      type: object
info:
  contact:
    email: support@mailchannels.com
    name: MailChannels Corporation
  description: 'This is the API reference for Email API. Here, you''ll find more detailed
    information on every endpoint, including parameters, response formats, and error
    codes.

    '
  title: Email API
  version: 0.2.0
openapi: 3.0.0
paths:
  /send:
    post:
      description: "click-tracking notes:\n  * if the URL of the 'a' tag is empty\
        \ within the HTML body or\n    doesn't start with http/https, or has a clicktracking\
        \ attribute\n    with a value of 'off', it will be ignored.\n"
      parameters:
      - description: 'When present and set to true, the message will not be sent.
          Instead, the fully rendered

          message is returned. This can be useful for testing.

          '
        in: query
        name: dry-run
        required: false
        schema:
          type: boolean
      - in: header
        name: X-Api-Key
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MailSendBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
          description: Success. Returned if dry-run is present in the query
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendResults'
          description: Success
        '400':
          description: Bad Request
        '403':
          description: User does not have access to this feature
        '413':
          description: 'Payload too large - The total message size should not exceed
            20MB.

            This includes the message itself, headers, and the combined size of any
            attachments.

            '
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Gateway
      summary: Send a message over MailChannels Email API
  /webhook:
    delete:
      parameters:
      - in: header
        name: X-Api-Key
        required: true
        schema:
          type: string
      responses:
        '204':
          description: Successfully removed webhook endpoint(s)
        '500':
          description: Internal Server Error
      summary: Delete all webhook endpoints for a customer.
    get:
      parameters:
      - in: header
        name: X-Api-Key
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/Webhook'
                type: array
          description: Successfully returning customer's webhooks
        '500':
          description: Internal Server Error
      summary: Fetch customer's webhooks.
    post:
      parameters:
      - description: the URL to which the webhook should be sent
        in: query
        name: endpoint
        required: true
        schema:
          maxLength: 8000
          type: string
      - in: header
        name: X-Api-Key
        required: true
        schema:
          type: string
      responses:
        '201':
          description: Successfully enrolled customer to receive webhooks
        '400':
          description: Bad Request
        '409':
          description: There's already a webhook endpoint for this customer
        '500':
          description: Internal Server Error
      summary: Enroll a customer for event webhooks.
servers:
- url: https://api.mailchannels.net/tx/v1
