Share via


Messages - List Messages

Gets a list of messages that exist on a thread.

GET {endpoint}/threads/{threadId}/messages?api-version=v1
GET {endpoint}/threads/{threadId}/messages?run_id={run_id}&api-version=v1&limit={limit}&order={order}&after={after}&before={before}

URI Parameters

Name In Required Type Description
endpoint
path True

string (uri)

Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>

threadId
path True

string

Identifier of the thread.

api-version
query True

string

minLength: 1

The API version to use for this operation.

after
query

string

A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

before
query

string

A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

limit
query

integer (int32)

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

order
query

ListSortOrder

Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

run_id
query

string

Filter messages by the run ID that generated them.

Responses

Name Type Description
200 OK

The requested list of messages.

Security

OAuth2Auth

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

Scopes

Name Description
https://ai.azure.com/.default

Examples

Messages_ListMessages_MaximumSet
Messages_ListMessages_MinimumSet

Messages_ListMessages_MaximumSet

Sample request

GET {endpoint}/threads/xfspsclbezumtyhgjiilvfgivopb/messages?run_id=iyf&api-version=v1&limit=9&order=asc&after=crhyvmyq&before=rmgkbncyohvmwjddfpdomeyxah

Sample response

{
  "data": [
    {
      "id": "ohzuqfhaw",
      "object": "thread.message",
      "created_at": 11,
      "thread_id": "hcxrpklwbljjfhkywtctg",
      "status": "in_progress",
      "incomplete_details": {
        "reason": "content_filter"
      },
      "completed_at": 8,
      "incomplete_at": 18,
      "role": "user",
      "content": [
        {
          "type": "MessageContent"
        }
      ],
      "assistant_id": "zpujvcgjicl",
      "run_id": "uwsiihbsvcwwncfprmwjzzixsd",
      "attachments": [
        {
          "file_id": "xidx",
          "data_source": {
            "uri": "jtookuzhwojyylbips",
            "type": "uri_asset"
          },
          "tools": [
            null
          ]
        }
      ],
      "metadata": {
        "key9075": "lsmd"
      }
    }
  ],
  "last_id": "vrutbusfuh",
  "has_more": true
}

Messages_ListMessages_MinimumSet

Sample request

GET {endpoint}/threads/rgkgrspjnbpmf/messages?api-version=v1

Sample response

{
  "data": [
    {
      "id": "ohzuqfhaw",
      "object": "thread.message",
      "created_at": 11,
      "thread_id": "hcxrpklwbljjfhkywtctg",
      "status": "in_progress",
      "incomplete_details": {
        "reason": "content_filter"
      },
      "completed_at": 8,
      "incomplete_at": 18,
      "role": "user",
      "content": [
        {
          "type": "MessageContent"
        }
      ],
      "assistant_id": "zpujvcgjicl",
      "run_id": "uwsiihbsvcwwncfprmwjzzixsd",
      "attachments": [
        {
          "tools": [
            null
          ]
        }
      ],
      "metadata": {}
    }
  ],
  "has_more": true
}

Definitions

ListSortOrder

The available sorting options when requesting a list of response objects.

Value Description
asc

Specifies an ascending sort order.

desc

Specifies a descending sort order.