Skip to main content

messages

Creates, updates, deletes, gets or lists a messages resource.

Overview

Namemessages
TypeResource
Idazure.ai_agents.messages

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier, which can be referenced in API endpoints. Required.
assistant_idstringIf applicable, the ID of the agent that authored this message. Required.
run_idstringIf applicable, the ID of the run associated with the authoring of this message. Required.
thread_idstringThe ID of the thread that this message belongs to. Required.
attachmentsarrayA list of files attached to the message, and the tools they were added to. Required.
completed_atstring (date-time)The Unix timestamp (in seconds) for when the message was completed. Required.
contentarrayThe list of content items associated with the agent thread message. Required.
created_atstring (date-time)The Unix timestamp, in seconds, representing when this object was created. Required.
incomplete_atstring (date-time)The Unix timestamp (in seconds) for when the message was marked as incomplete. Required.
incomplete_detailsobjectOn an incomplete message, details about why the message is incomplete. Required.
metadataobjectA set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. Required.
objectstringThe object type, which is always 'thread.message'. Required. Default value is "thread.message".
rolestringThe role associated with the agent thread message. Required. Known values are: "user" and "assistant". (user, assistant)
statusstringThe status of the message. Required. Known values are: "in_progress", "incomplete", and "completed". (in_progress, incomplete, completed)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectthread_id, message_id, endpointRetrieves an existing message.
listselectthread_id, endpointrun_id, limit, order, after, beforeGets a list of messages that exist on a thread.
createinsertthread_id, endpointCreates a new message on a specified thread.
updateexecthread_id, message_id, endpointModifies an existing message on an existing thread.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
endpointstringThe service endpoint host (no scheme), e.g. myaccount.table.cosmos.azure.com:443 - value of the client endpoint parameter. (default: )
message_idstringIdentifier of the message. Required.
thread_idstringIdentifier of the thread. Required.
afterstring
beforestringA 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. Default value is None.
limitintegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Default value is None.
orderstringSort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Known values are: "asc" and "desc". Default value is None.
run_idstringFilter messages by the run ID that generated them. Default value is None.

SELECT examples

Retrieves an existing message.

SELECT
id,
assistant_id,
run_id,
thread_id,
attachments,
completed_at,
content,
created_at,
incomplete_at,
incomplete_details,
metadata,
object,
role,
status
FROM azure.ai_agents.messages
WHERE thread_id = '{{ thread_id }}' -- required
AND message_id = '{{ message_id }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

Creates a new message on a specified thread.

INSERT INTO azure.ai_agents.messages (
thread_id,
endpoint
)
SELECT
'{{ thread_id }}',
'{{ endpoint }}'
RETURNING
id,
assistant_id,
run_id,
thread_id,
attachments,
completed_at,
content,
created_at,
incomplete_at,
incomplete_details,
metadata,
object,
role,
status
;

Lifecycle Methods

Modifies an existing message on an existing thread.

EXEC azure.ai_agents.messages.update 
@thread_id='{{ thread_id }}' --required,
@message_id='{{ message_id }}' --required,
@endpoint='{{ endpoint }}' --required
;