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

# Register email domain

> Saves the from e-mail of the tenant, the sender of its dunning e-mails, and registers the domain of its address as the email domain of the tenant with the e-mail provider of Aira, with open tracking on and click tracking off. Returns the DNS records that the tenant adds to the DNS of the domain, so that the provider verifies it. The dunning e-mails go out from the default sender of Aira until the provider verifies the email domain for the first time, and from the from e-mail after that. After the first verification, the dunning e-mails wait while the email domain is not verified.

Requires the role `dunning:write`.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/email-domains/
openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
paths:
  /v1/email-domains/:
    post:
      tags:
        - Email Domains
      summary: Register email domain
      description: >-
        Saves the from e-mail of the tenant, the sender of its dunning e-mails,
        and registers the domain of its address as the email domain of the
        tenant with the e-mail provider of Aira, with open tracking on and click
        tracking off. Returns the DNS records that the tenant adds to the DNS of
        the domain, so that the provider verifies it. The dunning e-mails go out
        from the default sender of Aira until the provider verifies the email
        domain for the first time, and from the from e-mail after that. After
        the first verification, the dunning e-mails wait while the email domain
        is not verified.


        Requires the role `dunning:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                fromEmail:
                  type: string
                  minLength: 1
                  description: >-
                    The sender of the dunning e-mails of the tenant, as `Name
                    <address>` or a bare address. The domain of the address
                    becomes the email domain of the tenant, because the e-mail
                    provider of Aira sends only from the exact domain that it
                    verified.
                  example: Acme <financeiro@acme.com>
              required:
                - fromEmail
              additionalProperties: false
        required: true
        description: The from e-mail of the tenant.
      responses:
        '201':
          description: >-
            An email domain: a domain of the tenant, registered with the e-mail
            provider of Aira, that the invoice deliveries of the tenant go out
            from while the provider reports it verified or partially verified. A
            tenant has zero or one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the email domain in our system.
                  domain:
                    type: string
                    description: >-
                      The domain. The from e-mail of the tenant is an address on
                      exactly this domain.
                    example: acme.com
                  status:
                    type: string
                    enum:
                      - not_started
                      - pending
                      - verified
                      - failed
                      - temporary_failure
                      - partially_verified
                      - partially_failed
                      - unrecognized
                    description: >-
                      The verification status that the e-mail provider of Aira
                      last reported. The invoice deliveries go out from the from
                      e-mail of the tenant only while the email domain is
                      `verified` or `partially_verified`.
                  dnsRecords:
                    type: array
                    items:
                      type: object
                      description: >-
                        A DNS record that the tenant adds to the DNS of its
                        domain, so that the e-mail provider of Aira verifies the
                        domain.
                      properties:
                        record:
                          type: string
                          description: What the record is for, such as DKIM or SPF.
                          example: DKIM
                        type:
                          type: string
                          description: The DNS record type, such as TXT, MX or CNAME.
                          example: TXT
                        name:
                          type: string
                          description: The host name of the record.
                          example: mail._domainkey
                        value:
                          type: string
                          description: The value of the record.
                          example: p=dkim-public-key
                        ttl:
                          type: string
                          description: The time to live of the record.
                          example: Auto
                        priority:
                          type:
                            - 'null'
                            - integer
                          description: >-
                            The priority of an MX record, or null for any other
                            record type.
                        status:
                          type: string
                          enum:
                            - not_started
                            - pending
                            - verified
                            - failed
                            - temporary_failure
                            - partially_verified
                            - partially_failed
                            - unrecognized
                          description: >-
                            Whether the e-mail provider of Aira found the record
                            in the DNS of the tenant.
                      required:
                        - record
                        - type
                        - name
                        - value
                        - ttl
                        - priority
                        - status
                      additionalProperties: false
                    description: >-
                      The DNS records that the tenant adds to the DNS of the
                      domain, so that the e-mail provider of Aira verifies it.
                  createdAt:
                    type: string
                    format: date-time
                    description: When the tenant registered the email domain.
                  updatedAt:
                    type: string
                    format: date-time
                    description: >-
                      When Aira last stored a change of the email domain, such
                      as a status that the e-mail provider of Aira reported.
                required:
                  - id
                  - domain
                  - status
                  - dnsRecords
                  - createdAt
                  - updatedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `from_email_invalid`: the `fromEmail` has no e-mail address, or
            its address is on the domain of Aira.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - from_email_invalid
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''fromEmail'' is required'
                    code: json_schema_validation_error
                from_email_invalid:
                  value:
                    message: from e-mail "{fromEmail}" {reason}
                    code: from_email_invalid
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the tenant does not allow the IP of the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '409':
          description: >-
            Other data blocks the action.


            - `email_domain_already_registered`: the tenant already has the
            domain of the `fromEmail` as its email domain.

            - `email_domain_limit_reached`: the tenant already has an email
            domain, and the `fromEmail` is on another domain.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - email_domain_already_registered
                      - email_domain_limit_reached
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                email_domain_already_registered:
                  value:
                    message: >-
                      email domain {domain} is already registered for this
                      tenant
                    code: email_domain_already_registered
                email_domain_limit_reached:
                  value:
                    message: >-
                      the tenant already has the email domain {domain}; delete
                      it before registering {domain}
                    code: email_domain_limit_reached
        '502':
          description: >-
            An outside service failed during the request.


            - `resend_domain_request_failed`: the e-mail provider of Aira
            refuses a request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resend_domain_request_failed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resend_domain_request_failed:
                  value:
                    message: 'resend refused to {refusedAction}: {message}'
                    code: resend_domain_request_failed
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````

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