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

# Get Message

> Returns the complete message by its ID, including raw content and parsed content structure.


Returns a message by its ID.

The main difference between the response of this API and the response of the
[List Messages API](/api-reference/messages/get-messages) is that this API returns
a single message including the original, raw email `content` (if available),
while the message objects returned in the List Messages API do not include
the email `content`.


## OpenAPI

````yaml openapi.yaml GET /v2/accounts/{account_id}/messages/{message_id}
openapi: 3.1.0
info:
  title: AhaSend API v2
  description: >
    The AhaSend API v2 allows you to send transactional emails, manage domains,
    webhooks, routes, API keys, and view statistics.


    ## Authentication

    All API requests must be authenticated using a Bearer token in the
    Authorization header:

    ```

    Authorization: Bearer aha-sk-64-CHARACTER-RANDOM-STRING

    ```


    ## Scopes

    API keys have specific scopes that control access to different resources and
    actions:


    ### Message Scopes

    - `messages:send:all` - Send messages from any domain in the account

    - `messages:send:{domain}` - Send messages from a specific domain

    - `messages:cancel:all` - Cancel messages from any domain

    - `messages:cancel:{domain}` - Cancel messages from a specific domain

    - `messages:read:all` - Read messages from any domain

    - `messages:read:{domain}` - Read messages from a specific domain


    ### Domain Scopes

    - `domains:read` - Read all domains

    - `domains:write` - Create and update domains

    - `domains:delete:all` - Delete any domain

    - `domains:delete:{domain}` - Delete a specific domain


    ### Account Scopes

    - `accounts:read` - Read account information

    - `accounts:write` - Update account settings

    - `accounts:billing` - Access billing information

    - `accounts:members:read` - Read account members

    - `accounts:members:add` - Add account members

    - `accounts:members:update` - Update account members

    - `accounts:members:remove` - Remove account members


    ### Webhook Scopes

    - `webhooks:read:all` - Read all webhooks

    - `webhooks:read:{domain}` - Read webhooks for a specific domain

    - `webhooks:write:all` - Create and update webhooks

    - `webhooks:write:{domain}` - Create and update webhooks for a specific
    domain

    - `webhooks:delete:all` - Delete any webhook

    - `webhooks:delete:{domain}` - Delete webhooks for a specific domain


    ### Route Scopes

    - `routes:read:all` - Read all routes

    - `routes:read:{domain}` - Read routes for a specific domain

    - `routes:write:all` - Create and update routes

    - `routes:write:{domain}` - Create and update routes for a specific domain

    - `routes:delete:all` - Delete any route

    - `routes:delete:{domain}` - Delete routes for a specific domain


    ### Suppression Scopes

    - `suppressions:read` - Read suppressions

    - `suppressions:write` - Create suppressions

    - `suppressions:delete` - Delete suppressions

    - `suppressions:wipe` - Delete all suppressions (dangerous)


    ### SMTP Credentials Scopes

    - `smtp-credentials:read:all` - Read all SMTP credentials

    - `smtp-credentials:read:{domain}` - Read SMTP credentials for a specific
    domain

    - `smtp-credentials:write:all` - Create SMTP credentials

    - `smtp-credentials:write:{domain}` - Create SMTP credentials for a specific
    domain

    - `smtp-credentials:delete:all` - Delete any SMTP credentials

    - `smtp-credentials:delete:{domain}` - Delete SMTP credentials for a
    specific domain


    ### Statistics Scopes

    - `statistics-transactional:read:all` - Read all transactional statistics

    - `statistics-transactional:read:{domain}` - Read transactional statistics
    for a specific domain


    ### API Key Scopes

    - `api-keys:read` - Read API keys

    - `api-keys:write` - Create and update API keys

    - `api-keys:delete` - Delete API keys


    ### Sub-Account Scopes

    - `sub-accounts:read` - List and read sub accounts under the parent

    - `sub-accounts:write` - Create and update sub accounts

    - `sub-accounts:delete` - Soft-delete sub accounts

    - `sub-accounts:suspend` - Suspend and unsuspend sub accounts

    - `sub-accounts:usage` - Read per-sub-account usage and allocated cost

    - `sub-account-api-keys:read` - List and read API keys owned by sub accounts

    - `sub-account-api-keys:write` - Create and update API keys owned by sub
    accounts

    - `sub-account-api-keys:delete` - Delete API keys owned by sub accounts


    ## Rate Limiting

    - General API endpoints: 100 requests per second, 200 burst

    - Statistics endpoints: 1 request per second, 1 burst


    ## Pagination

    List endpoints use cursor-based pagination with the following parameters:

    - `limit`: Maximum number of items to return (default: 100, max: 100)

    - `cursor`: Pagination cursor for the next page


    ## Time Formats

    All timestamps must be in RFC3339 format, e.g., `2023-12-25T10:30:00Z`


    ## Idempotency

    POST requests support idempotency through the optional `Idempotency-Key`
    header. When provided:

    - The same request can be safely retried multiple times

    - Duplicate requests return the same response with `Idempotent-Replayed:
    true`

    - In-progress requests return HTTP 409 with `Idempotent-Replayed: false` and
    a `Retry-After` header

    - Completed outcomes (2xx and 4xx) are stored and replayed; server errors
    (5xx) are not stored, so retrying with the same key re-executes the request

    - Reusing a key with a different request payload, or against a different
    endpoint or resource, returns HTTP 422

    - Idempotency keys for non-secret responses expire after 24 hours

    - API-key create endpoints return a one-time `secret_key`; their encrypted
    idempotency replay responses expire after 5 minutes and replay the same
    `secret_key` during that window


    ## IP Allow Lists

    Each API key can carry an `ip_allow_list`: a set of source IPs that restrict
    where the key may authenticate from.

    - Entries are CIDR blocks (e.g. `203.0.113.0/24`) or bare IPv4/IPv6
    addresses (stored as a `/32` or `/128`). They are canonicalized and
    de-duplicated; the allow-all prefixes `0.0.0.0/0` and `::/0` are rejected,
    and at most 100 entries are allowed after de-duplication (a longer list is
    rejected with HTTP 400).

    - An empty list (the default) places no restriction.

    - When the list is non-empty, any authenticated request whose client IP is
    not covered by an entry is rejected with HTTP 403 on every v2 endpoint,
    regardless of the key's scopes.

    - Manage the list with the `ip_allow_list` field on the API-key create and
    update endpoints (including the sub-account API-key endpoints).

    - When a key updates its own `ip_allow_list` to a value that excludes the
    caller's current IP, the update is rejected with HTTP 409 to prevent
    self-lockout. Updating a sub-account key from a parent key has no such
    guard.
  version: 2.0.0
  contact:
    email: support@ahasend.com
  license:
    name: MIT
    identifier: MIT
servers:
  - url: https://api.ahasend.com
    description: Production server
security:
  - BearerAuth: []
tags:
  - name: Utility
    description: Utility endpoints for health checks and diagnostics
  - name: API Keys
    description: Manage API keys for authentication and access control
  - name: Domains
    description: Manage sending domains
  - name: Messages
    description: Send and manage transactional messages
  - name: Accounts
    description: Manage account settings and members
  - name: Suppressions
    description: Manage email suppressions
  - name: Routes
    description: Manage inbound email routing
  - name: Webhooks
    description: Manage webhook notifications
  - name: SMTP Credentials
    description: Manage SMTP authentication credentials
  - name: Statistics
    description: Access transactional email statistics
  - name: Message Events
    description: Webhooks for outbound message delivery events
  - name: Suppression Events
    description: Webhooks for suppression list changes
  - name: Domain Events
    description: Webhooks for domain configuration issues
  - name: Route Events
    description: Webhooks for inbound email routing
paths:
  /v2/accounts/{account_id}/messages/{message_id}:
    get:
      tags:
        - Messages
      summary: Get Message
      description: >
        Returns the complete message by its ID, including raw content and parsed
        content structure.
      operationId: getMessage
      parameters:
        - name: account_id
          in: path
          required: true
          description: Account ID
          schema:
            type: string
            format: uuid
        - name: message_id
          in: path
          required: true
          description: >-
            Message API ID. Accepts the generated Message-ID returned by [Create
            Message
            API](https://ahasend.com/docs/api-reference/messages/create-message),
            for example `<uuid@example.com>`, or the bare UUID portion.
          schema:
            type: string
      responses:
        '200':
          description: Message details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Message not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth:
            - messages:read:all
            - messages:read:{domain}
      x-code-samples:
        - lang: go
          label: AhaSend Go SDK
          source: |
            package main

            import (
              "context"
              "fmt"
              "log"

              "github.com/AhaSend/ahasend-go/api"
              "github.com/google/uuid"
            )

            func main() {
              // Create API client with authentication
              client := api.NewAPIClient(
                api.WithAPIKey("aha-sk-your-64-character-key"),
              )

              accountID := uuid.New()
              messageID := uuid.New()

              // Create context for the API call
              ctx := context.Background()

              // Fetch a single message by ID
              response, httpResp, err := client.MessagesAPI.GetMessage(ctx, accountID, messageID)
              if err != nil {
                log.Fatalf("Error getting message: %v", err)
              }

              if httpResp.StatusCode == 200 {
                fmt.Printf("✅ Message retrieved! Status: %d\n", httpResp.StatusCode)
                if response != nil {
                  fmt.Printf("Subject: %s\n", response.Subject)
                  fmt.Printf("Status: %s\n", response.Status)
                  fmt.Printf("Sender: %s\n", response.Sender)
                  fmt.Printf("Recipient: %s\n", response.Recipient)
                  fmt.Printf("Attempts: %d\n", response.NumAttempts)
                  fmt.Printf("Opens: %d\n", response.OpenCount)
                  fmt.Printf("Clicks: %d\n", response.ClickCount)
                }
              } else {
                fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
              }
            }
components:
  schemas:
    Message:
      allOf:
        - $ref: '#/components/schemas/MessageSummary'
        - type: object
          properties:
            content:
              type: string
              nullable: true
              description: >-
                Original, raw email content (RFC822 format) - may be null if the
                message content is not available.
            content_parsed:
              $ref: '#/components/schemas/MessageContentParsed'
              description: >-
                Parsed and structured message content including parts,
                attachments, and headers - may be null if the message content is
                not available.
    ErrorResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Error description
      example:
        message: Error message
    MessageSummary:
      type: object
      properties:
        object:
          type: string
          enum:
            - message
          description: Object type identifier
        created_at:
          type: string
          format: date-time
          description: When the message was created
        updated_at:
          type: string
          format: date-time
          description: When the message was last updated
        sent_at:
          type: string
          format: date-time
          nullable: true
          description: When the message was sent
        delivered_at:
          type: string
          format: date-time
          nullable: true
          description: When the message was delivered
        retain_until:
          type: string
          format: date-time
          description: When the message data will be purged
        direction:
          type: string
          enum:
            - inbound
            - outbound
          description: Message direction
        is_bounce_notification:
          type: boolean
          description: Whether this is a bounce notification
        bounce_classification:
          type: string
          description: Classification of bounce if applicable
        delivery_attempts:
          type: array
          items:
            $ref: '#/components/schemas/DeliveryEvent'
          description: List of delivery attempts for this message
        message_id:
          type: string
          description: Message-ID header value
        id:
          type: string
          format: uuid
          description: API-generated message ID
        subject:
          type: string
          description: Message subject
        tags:
          type: array
          items:
            type: string
          description: Tags associated with the message
        sender:
          type: string
          format: email
          description: Sender email address
        recipient:
          type: string
          format: email
          description: Recipient email address
        status:
          type: string
          description: Current message status
        num_attempts:
          type: integer
          description: Number of delivery attempts
        click_count:
          type: integer
          description: Number of clicks tracked for this message
        open_count:
          type: integer
          description: Number of opens tracked for this message
        reference_message_id:
          type: integer
          format: int64
          nullable: true
          description: ID of the original message (for bounce messages)
        domain_id:
          type: string
          format: uuid
          description: Domain ID this message was sent from
        account_id:
          type: string
          format: uuid
          description: Account ID this message belongs to
      required:
        - object
        - created_at
        - updated_at
        - retain_until
        - direction
        - is_bounce_notification
        - delivery_attempts
        - message_id
        - id
        - subject
        - tags
        - sender
        - recipient
        - status
        - num_attempts
        - click_count
        - open_count
        - domain_id
        - account_id
    MessageContentParsed:
      type: object
      properties:
        parts:
          type: array
          items:
            $ref: '#/components/schemas/MessageContentPart'
          description: Array of message content parts (text, HTML, etc.)
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/MessageAttachment'
          description: Array of message attachments
        headers:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: >-
            Email headers as key-value pairs (values are arrays to handle
            multiple headers with same name)
          example:
            Content-Type:
              - text/html; charset=utf-8
            X-Custom-Header:
              - value1
              - value2
      required:
        - parts
        - attachments
        - headers
    DeliveryEvent:
      type: object
      properties:
        time:
          type: string
          format: date-time
          description: Timestamp of the delivery event
        log:
          type: string
          description: Log message for the delivery event
        status:
          type: string
          description: Status of the delivery event
      required:
        - time
        - log
        - status
    MessageContentPart:
      type: object
      properties:
        content_type:
          type: string
          description: MIME content type (e.g., "text/plain", "text/html")
          example: text/html
        content:
          type: string
          description: The actual content for this part
      required:
        - content_type
        - content
    MessageAttachment:
      type: object
      properties:
        filename:
          type: string
          description: Original filename of the attachment
          example: document.pdf
        content:
          type: string
          description: Base64 encoded attachment content
        content_type:
          type: string
          description: MIME content type of the attachment
          example: application/pdf
        content_id:
          type: string
          description: Content-ID for inline attachments
          nullable: true
          example: image001@example.com
      required:
        - filename
        - content
        - content_type
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: aha-sk-64-CHARACTER-RANDOM-STRING
      description: API key for authentication

````