> ## 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.

# Fetch email

> Fetches one email that Aira sent for the tenant, with its body in HTML, the file names of its attachments, the signals of the provider and the invoice that it delivered.

Requires the role `emails:read`.



## OpenAPI

````yaml /api-reference/openapi.yaml get /v1/emails/{id}
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/emails/{id}:
    get:
      tags:
        - Emails
      summary: Fetch email
      description: >-
        Fetches one email that Aira sent for the tenant, with its body in HTML,
        the file names of its attachments, the signals of the provider and the
        invoice that it delivered.


        Requires the role `emails:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the email in our system.
      responses:
        '200':
          description: >-
            Schema representing an email that Aira sent for the tenant, with its
            body, its attachments, the signals of the provider and the invoice
            that it delivered.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the email in our system.
                  status:
                    type: string
                    enum:
                      - sent
                      - delivered
                      - opened
                      - bounced
                      - failed
                    description: >-
                      The status of the email: `sent` once the provider accepted
                      it, `delivered` once it reached the server of a recipient,
                      `opened` once a recipient opened it, `bounced` once it
                      came back, and `failed` when the provider refused it.
                  subject:
                    type: string
                    description: The subject of the email.
                    example: Fatura 42 disponível
                  recipients:
                    type: array
                    items:
                      type: string
                    description: The email addresses that the email went to.
                  sentAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      accepted the email, or null if the provider refused it.
                  createdAt:
                    type: string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when Aira created the
                      email.
                  bounceType:
                    type:
                      - 'null'
                      - string
                    enum:
                      - hard
                      - soft
                      - null
                    description: >-
                      The kind of bounce that the provider reported, or null if
                      the email did not bounce or the provider did not classify
                      the bounce.
                  fromEmail:
                    type: string
                    description: The sender of the email, as the recipients see it.
                    example: Acme <billing+acme@useaira.com>
                  deliveredAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      reported that the email reached the server of a recipient,
                      or null.
                  openedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      reported that a recipient opened the email, or null.
                  bouncedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      reported that the email bounced, or null.
                  providerReason:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The reason that the provider gave, verbatim, for a bounce
                      or for a refusal, or null.
                    example: >-
                      550 5.1.1 The email account that you tried to reach does
                      not exist.
                  attachments:
                    type: array
                    items:
                      type: string
                    description: >-
                      The file names of the attachments of the email, in order.
                      Download each one by its index in this list.
                  html:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The body of the email in HTML, as Aira handed it to the
                      provider, or null if Aira cannot read the stored body.
                    example: >-
                      <html><body><p>A fatura PADAR-00042 da Padaria Central
                      está disponível.</p></body></html>
                  invoice:
                    type: object
                    nullable: true
                    description: >-
                      The invoice that the email delivered, or null for an email
                      of no invoice.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the invoice in our system.
                      customerId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the customer of the invoice
                          in our system.
                    required:
                      - id
                      - customerId
                    additionalProperties: false
                required:
                  - id
                  - status
                  - subject
                  - recipients
                  - sentAt
                  - createdAt
                  - bounceType
                  - fromEmail
                  - deliveredAt
                  - openedAt
                  - bouncedAt
                  - providerReason
                  - attachments
                  - html
                  - invoice
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          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
                  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: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '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 emails:read 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
        '404':
          description: >-
            A record that the request names does not exist in the tenant.


            - `email_not_found`: no e-mail of the tenant has the `id`, or the
            e-mail carries a one-time auth code.
          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_not_found
                  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_not_found:
                  value:
                    message: email not found
                    code: email_not_found
        '429':
          description: >-
            The tenant reached one of its limits of reads.


            - `too_many_reads_per_second`: the tenant already made 50 reads in
            this second.

            - `too_many_reads_in_flight`: the tenant already has 20 reads in
            flight.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          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:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  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:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: a tenant can make at most 50 reads per
                      second. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: a tenant can have at most 20
                      reads in flight. Retry after 1 second.
                    code: too_many_reads_in_flight
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.