---
title: "Retrieve a message."
url: "https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1/operations/getMessage"
---

> Full API specification: https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1.md

# Retrieve a message.

`GET` `/threads/{thread_id}/messages/{message_id}`

Operation ID: `getMessage`

## Path parameters

- `thread_id` (string, required) - The ID of the [thread](/docs/api-reference/threads) to which this message belongs.
- `message_id` (string, required) - The ID of the message to retrieve.

## Responses

- `200` - OK

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: OpenAI API
  version: 2.3.0
servers:
  - url: https://api.openai.com/v1
paths:
  /threads/{thread_id}/messages/{message_id}:
    get:
      operationId: getMessage
      tags:
        - Assistants
      summary: Retrieve a message.
      parameters:
        - in: path
          name: thread_id
          required: true
          schema:
            type: string
          description: The ID of the [thread](/docs/api-reference/threads) to which this
            message belongs.
        - in: path
          name: message_id
          required: true
          schema:
            type: string
          description: The ID of the message to retrieve.
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageObject"
      x-oaiMeta:
        name: Retrieve message
        group: threads
        beta: true
        returns: The [message](/docs/api-reference/messages/object) object matching the
          specified ID.
        examples:
          request:
            curl: |
              curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \
                -H "Content-Type: application/json" \
                -H "Authorization: Bearer $OPENAI_API_KEY" \
                -H "OpenAI-Beta: assistants=v2"
            python: |
              from openai import OpenAI
              client = OpenAI()

              message = client.beta.threads.messages.retrieve(
                message_id="msg_abc123",
                thread_id="thread_abc123",
              )
              print(message)
            node.js: |-
              import OpenAI from "openai";

              const openai = new OpenAI();

              async function main() {
                const message = await openai.beta.threads.messages.retrieve(
                  "thread_abc123",
                  "msg_abc123"
                );

                console.log(message);
              }

              main();
          response: |
            {
              "id": "msg_abc123",
              "object": "thread.message",
              "created_at": 1699017614,
              "assistant_id": null,
              "thread_id": "thread_abc123",
              "run_id": null,
              "role": "user",
              "content": [
                {
                  "type": "text",
                  "text": {
                    "value": "How does AI work? Explain it in simple terms.",
                    "annotations": []
                  }
                }
              ],
              "attachments": [],
              "metadata": {}
            }
security:
  - ApiKeyAuth: []
components:
  schemas:
    MessageObject:
      type: object
      title: The message object
      description: Represents a message within a [thread](/docs/api-reference/threads).
      properties:
        id:
          description: The identifier, which can be referenced in API endpoints.
          type: string
        object:
          description: The object type, which is always `thread.message`.
          type: string
          enum:
            - thread.message
          x-stainless-const: true
        created_at:
          description: The Unix timestamp (in seconds) for when the message was created.
          type: integer
        thread_id:
          description: The [thread](/docs/api-reference/threads) ID that this message
            belongs to.
          type: string
        status:
          description: The status of the message, which can be either `in_progress`,
            `incomplete`, or `completed`.
          type: string
          enum:
            - in_progress
            - incomplete
            - completed
        incomplete_details:
          description: On an incomplete message, details about why the message is
            incomplete.
          type: object
          properties:
            reason:
              type: string
              description: The reason the message is incomplete.
              enum:
                - content_filter
                - max_tokens
                - run_cancelled
                - run_expired
                - run_failed
          nullable: true
          required:
            - reason
        completed_at:
          description: The Unix timestamp (in seconds) for when the message was completed.
          type: integer
          nullable: true
        incomplete_at:
          description: The Unix timestamp (in seconds) for when the message was marked as
            incomplete.
          type: integer
          nullable: true
        role:
          description: The entity that produced the message. One of `user` or `assistant`.
          type: string
          enum:
            - user
            - assistant
        content:
          description: The content of the message in array of text and/or images.
          type: array
          items:
            oneOf:
              - $ref: "#/components/schemas/MessageContentImageFileObject"
              - $ref: "#/components/schemas/MessageContentImageUrlObject"
              - $ref: "#/components/schemas/MessageContentTextObject"
              - $ref: "#/components/schemas/MessageContentRefusalObject"
            x-oaiExpandable: true
        assistant_id:
          description: If applicable, the ID of the
            [assistant](/docs/api-reference/assistants) that authored this
            message.
          type: string
          nullable: true
        run_id:
          description: The ID of the [run](/docs/api-reference/runs) associated with the
            creation of this message. Value is `null` when messages are created
            manually using the create message or create thread endpoints.
          type: string
          nullable: true
        attachments:
          type: array
          items:
            type: object
            properties:
              file_id:
                type: string
                description: The ID of the file to attach to the message.
              tools:
                description: The tools to add this file to.
                type: array
                items:
                  oneOf:
                    - $ref: "#/components/schemas/AssistantToolsCode"
                    - $ref: "#/components/schemas/AssistantToolsFileSearchTypeOnly"
                  x-oaiExpandable: true
          description: A list of files attached to the message, and the tools they were
            added to.
          nullable: true
        metadata:
          $ref: "#/components/schemas/Metadata"
      required:
        - id
        - object
        - created_at
        - thread_id
        - status
        - incomplete_details
        - completed_at
        - incomplete_at
        - role
        - content
        - assistant_id
        - run_id
        - attachments
        - metadata
      x-oaiMeta:
        name: The message object
        beta: true
        example: |
          {
            "id": "msg_abc123",
            "object": "thread.message",
            "created_at": 1698983503,
            "thread_id": "thread_abc123",
            "role": "assistant",
            "content": [
              {
                "type": "text",
                "text": {
                  "value": "Hi! How can I help you today?",
                  "annotations": []
                }
              }
            ],
            "assistant_id": "asst_abc123",
            "run_id": "run_abc123",
            "attachments": [],
            "metadata": {}
          }
    MessageContentImageFileObject:
      title: Image file
      type: object
      description: References an image [File](/docs/api-reference/files) in the
        content of a message.
      properties:
        type:
          description: Always `image_file`.
          type: string
          enum:
            - image_file
          x-stainless-const: true
        image_file:
          type: object
          properties:
            file_id:
              description: The [File](/docs/api-reference/files) ID of the image in the
                message content. Set `purpose="vision"` when uploading the File
                if you need to later display the file content.
              type: string
            detail:
              type: string
              description: Specifies the detail level of the image if specified by the user.
                `low` uses fewer tokens, you can opt in to high resolution using
                `high`.
              enum:
                - auto
                - low
                - high
              default: auto
          required:
            - file_id
      required:
        - type
        - image_file
    MessageContentImageUrlObject:
      title: Image URL
      type: object
      description: References an image URL in the content of a message.
      properties:
        type:
          type: string
          enum:
            - image_url
          description: The type of the content part.
          x-stainless-const: true
        image_url:
          type: object
          properties:
            url:
              type: string
              description: "The external URL of the image, must be a supported image types:
                jpeg, jpg, png, gif, webp."
              format: uri
            detail:
              type: string
              description: Specifies the detail level of the image. `low` uses fewer tokens,
                you can opt in to high resolution using `high`. Default value is
                `auto`
              enum:
                - auto
                - low
                - high
              default: auto
          required:
            - url
      required:
        - type
        - image_url
    MessageContentTextObject:
      title: Text
      type: object
      description: The text content that is part of a message.
      properties:
        type:
          description: Always `text`.
          type: string
          enum:
            - text
          x-stainless-const: true
        text:
          type: object
          properties:
            value:
              description: The data that makes up the text.
              type: string
            annotations:
              type: array
              items:
                oneOf:
                  - $ref: "#/components/schemas/MessageContentTextAnnotationsFileCitationObject"
                  - $ref: "#/components/schemas/MessageContentTextAnnotationsFilePathObject"
                x-oaiExpandable: true
          required:
            - value
            - annotations
      required:
        - type
        - text
    MessageContentRefusalObject:
      title: Refusal
      type: object
      description: The refusal content generated by the assistant.
      properties:
        type:
          description: Always `refusal`.
          type: string
          enum:
            - refusal
          x-stainless-const: true
        refusal:
          type: string
          nullable: false
      required:
        - type
        - refusal
    AssistantToolsCode:
      type: object
      title: Code interpreter tool
      properties:
        type:
          type: string
          description: "The type of tool being defined: `code_interpreter`"
          enum:
            - code_interpreter
          x-stainless-const: true
      required:
        - type
    AssistantToolsFileSearchTypeOnly:
      type: object
      title: FileSearch tool
      properties:
        type:
          type: string
          description: "The type of tool being defined: `file_search`"
          enum:
            - file_search
          x-stainless-const: true
      required:
        - type
    Metadata:
      type: object
      description: >
        Set of 16 key-value pairs that can be attached to an object. This can be

        useful for storing additional information about the object in a
        structured

        format, and querying for objects via API or the dashboard. 


        Keys are strings with a maximum length of 64 characters. Values are
        strings

        with a maximum length of 512 characters.
      additionalProperties:
        type: string
      x-oaiTypeLabel: map
      nullable: true
    MessageContentTextAnnotationsFileCitationObject:
      title: File citation
      type: object
      description: A citation within the message that points to a specific quote from
        a specific File associated with the assistant or the message. Generated
        when the assistant uses the "file_search" tool to search files.
      properties:
        type:
          description: Always `file_citation`.
          type: string
          enum:
            - file_citation
          x-stainless-const: true
        text:
          description: The text in the message content that needs to be replaced.
          type: string
        file_citation:
          type: object
          properties:
            file_id:
              description: The ID of the specific File the citation is from.
              type: string
          required:
            - file_id
        start_index:
          type: integer
          minimum: 0
        end_index:
          type: integer
          minimum: 0
      required:
        - type
        - text
        - file_citation
        - start_index
        - end_index
    MessageContentTextAnnotationsFilePathObject:
      title: File path
      type: object
      description: A URL for the file that's generated when the assistant used the
        `code_interpreter` tool to generate a file.
      properties:
        type:
          description: Always `file_path`.
          type: string
          enum:
            - file_path
          x-stainless-const: true
        text:
          description: The text in the message content that needs to be replaced.
          type: string
        file_path:
          type: object
          properties:
            file_id:
              description: The ID of the file that was generated.
              type: string
          required:
            - file_id
        start_index:
          type: integer
          minimum: 0
        end_index:
          type: integer
          minimum: 0
      required:
        - type
        - text
        - file_path
        - start_index
        - end_index
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
```
