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

# Get thread by ID

> Retrieve a complete email thread (conversation) with all messages.

**What You Get:**
- Thread metadata (subject, participants, timestamps)
- All messages in the thread (both inbound and outbound)
- Messages sorted chronologically by thread position

**Message Types:**
- `inbound` - Emails you received
- `outbound` - Emails you sent (includes delivery status)




## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/inbound/openapi.documented.yml get /api/e2/mail/threads/{id}
openapi: 3.1.0
info:
  title: Inbound Email API
  description: >+

    # Inbound API


    The Inbound API allows you to manage email infrastructure programmatically -
    domains, email addresses, webhooks, and more.


    ## Authentication


    All API requests require a Bearer token in the Authorization header:


    ```bash

    curl -H "Authorization: Bearer YOUR_API_KEY" \
      https://inbound.new/api/e2/domains
    ```


    ## Base URL


    ```

    https://inbound.new/api/e2

    ```


    ## Quick Start


    1. **Create a domain** - Register your domain with Inbound

    2. **Configure DNS** - Add the provided DNS records to your domain

    3. **Create an email address** - Set up addresses to receive emails

    4. **Create an endpoint** - Configure where emails are delivered (webhook,
    forwarding, etc.)

  version: 2.0.0
servers:
  - url: https://inbound.new
    description: Production API server
security:
  - bearerAuth: []
tags:
  - name: Webhooks
    description: Webhooks sent by Inbound to your configured endpoints when events occur.
  - name: Emails
    description: >-
      Send, list, and manage emails. Supports immediate sending, scheduling,
      replies, and retry functionality.
  - name: Mail
    description: >-
      Inbox and thread views for received emails. Filter by domain, address, or
      search.
  - name: Domains
    description: >-
      Manage domains for sending and receiving emails. Domains must be verified
      via DNS before use.
  - name: Endpoints
    description: >-
      Configure where incoming emails are delivered - webhooks, email
      forwarding, or custom handlers.
  - name: Email Addresses
    description: Create and manage email addresses on your verified domains.
  - name: Attachments
    description: Download email attachments using authenticated requests.
paths:
  /api/e2/mail/threads/{id}:
    get:
      tags:
        - Inbox
      summary: Get thread by ID
      description: |
        Retrieve a complete email thread (conversation) with all messages.

        **What You Get:**
        - Thread metadata (subject, participants, timestamps)
        - All messages in the thread (both inbound and outbound)
        - Messages sorted chronologically by thread position

        **Message Types:**
        - `inbound` - Emails you received
        - `outbound` - Emails you sent (includes delivery status)
      operationId: getApiE2MailThreadsById
      parameters:
        - name: id
          in: path
          required: true
          schema:
            description: The unique thread ID to retrieve
            type: string
      responses:
        '200':
          description: Response for status 200
          content:
            application/json:
              schema:
                type: object
                properties:
                  thread:
                    type: object
                    properties:
                      id:
                        description: Unique identifier for the thread
                        type: string
                      root_message_id:
                        description: RFC 2822 Message-ID of the first message in the thread
                        type: string
                      normalized_subject:
                        nullable: true
                        anyOf:
                          - description: >-
                              Normalized subject line (stripped of Re:, Fwd:,
                              etc.)
                            type: string
                          - type: 'null'
                      participant_emails:
                        description: >-
                          Array of all unique email addresses that have
                          participated in this thread
                        type: array
                        items:
                          type: string
                      participant_names:
                        description: >-
                          Array of formatted participant names in the format
                          'First Last <email@domain.com>' or just
                          'email@domain.com' if no name is available
                        type: array
                        items:
                          type: string
                      message_count:
                        description: Total number of messages in the thread
                        type: number
                      last_message_at:
                        description: ISO 8601 timestamp of the most recent message
                        type: string
                      created_at:
                        description: ISO 8601 timestamp when the thread was created
                        type: string
                      updated_at:
                        description: ISO 8601 timestamp when the thread was last updated
                        type: string
                    required:
                      - id
                      - root_message_id
                      - participant_emails
                      - participant_names
                      - message_count
                      - last_message_at
                      - created_at
                      - updated_at
                  messages:
                    description: >-
                      Array of all messages in the thread, sorted by thread
                      position (chronological)
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          description: Unique identifier for the message
                          type: string
                        message_id:
                          nullable: true
                          anyOf:
                            - description: RFC 2822 Message-ID header value
                              type: string
                            - type: 'null'
                        type:
                          type: string
                          enum:
                            - inbound
                            - outbound
                        thread_position:
                          description: >-
                            Position of the message in the thread (0 = first
                            message)
                          type: number
                        subject:
                          nullable: true
                          anyOf:
                            - description: Subject line of the message
                              type: string
                            - type: 'null'
                        text_body:
                          nullable: true
                          anyOf:
                            - description: Plain text body of the message
                              type: string
                            - type: 'null'
                        html_body:
                          nullable: true
                          anyOf:
                            - description: HTML body of the message
                              type: string
                            - type: 'null'
                        from:
                          description: Formatted sender (display name and email)
                          type: string
                        from_name:
                          nullable: true
                          anyOf:
                            - description: Sender display name if available
                              type: string
                            - type: 'null'
                        from_address:
                          nullable: true
                          anyOf:
                            - description: Sender email address
                              type: string
                            - type: 'null'
                        to:
                          description: Array of recipient email addresses
                          type: array
                          items:
                            type: string
                        cc:
                          description: Array of CC recipient email addresses
                          type: array
                          items:
                            type: string
                        bcc:
                          description: Array of BCC recipient email addresses
                          type: array
                          items:
                            type: string
                        date:
                          nullable: true
                          anyOf:
                            - description: ISO 8601 timestamp from the Date header
                              type: string
                            - type: 'null'
                        received_at:
                          nullable: true
                          anyOf:
                            - description: >-
                                ISO 8601 timestamp when the message was received
                                (inbound only)
                              type: string
                            - type: 'null'
                        sent_at:
                          nullable: true
                          anyOf:
                            - description: >-
                                ISO 8601 timestamp when the message was sent
                                (outbound only)
                              type: string
                            - type: 'null'
                        is_read:
                          description: >-
                            Whether the message has been read (always true for
                            outbound)
                          type: boolean
                        read_at:
                          nullable: true
                          anyOf:
                            - description: >-
                                ISO 8601 timestamp when the message was marked
                                as read
                              type: string
                            - type: 'null'
                        has_attachments:
                          description: Whether the message has any attachments
                          type: boolean
                        attachments:
                          description: Array of attachment metadata
                          type: array
                          items:
                            type: object
                            properties:
                              filename:
                                description: Original filename of the attachment
                                type: string
                              contentType:
                                description: MIME type of the attachment
                                type: string
                              size:
                                description: Size of the attachment in bytes
                                type: number
                              contentId:
                                nullable: true
                                anyOf:
                                  - description: Content-ID for inline attachments
                                    type: string
                                  - type: 'null'
                              content:
                                description: Base64-encoded content (if included)
                                type: string
                        in_reply_to:
                          nullable: true
                          anyOf:
                            - description: RFC 2822 In-Reply-To header value
                              type: string
                            - type: 'null'
                        references:
                          description: Array of Message-IDs from the References header
                          type: array
                          items:
                            type: string
                        headers:
                          x-stainless-any: true
                          description: Raw email headers as key-value pairs
                        tags:
                          description: >-
                            Array of tags attached to the message (outbound
                            only)
                          type: array
                          items:
                            type: object
                            properties:
                              name:
                                description: Tag name
                                type: string
                              value:
                                description: Tag value
                                type: string
                            required:
                              - name
                              - value
                        status:
                          description: >-
                            Delivery status for outbound messages (pending,
                            sent, failed, bounced)
                          type: string
                        failure_reason:
                          nullable: true
                          anyOf:
                            - description: >-
                                Error message if the outbound message failed to
                                send
                              type: string
                            - type: 'null'
                      required:
                        - id
                        - type
                        - thread_position
                        - from
                        - to
                        - cc
                        - bcc
                        - is_read
                        - has_attachments
                        - attachments
                        - references
                        - headers
                        - tags
                  total_count:
                    description: Total number of messages returned
                    type: number
                required:
                  - thread
                  - messages
                  - total_count
        '400':
          description: Response for status 400
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    description: Error message describing what went wrong
                    type: string
                required:
                  - error
        '401':
          description: Response for status 401
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    description: Error message describing what went wrong
                    type: string
                required:
                  - error
        '404':
          description: Response for status 404
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    description: Error message describing what went wrong
                    type: string
                required:
                  - error
        '500':
          description: Response for status 500
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    description: Error message describing what went wrong
                    type: string
                required:
                  - error
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const mail = await client.mail.retrieve('id');

            console.log(mail.messages);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Your Inbound API key. Include it in the Authorization header as: Bearer
        <your-api-key>

````