Chat Thread - Send Chat Message

Sends a message to a thread.

POST {endpoint}/chat/threads/{chatThreadId}/messages?api-version=2024-03-07

URI Parameters

Name In Required Type Description
chatThreadId
path True

string

The thread id to send the message to.

endpoint
path True

string

The endpoint of the Azure Communication resource.

api-version
query True

string

Version of API to invoke.

Request Header

Name Required Type Description
Authorization True

string

An ACS (Azure Communication Services) user access token.

Request Body

Name Required Type Description
content True

string

Chat message content.

metadata

object

Message metadata.

senderDisplayName

string

The display name of the chat message sender. This property is used to populate sender name for push notifications.

type

ChatMessageType

The chat message type.

Responses

Name Type Description
201 Created

SendChatMessageResult

Message sent, the Location header contains the URL for the newly sent message.

401 Unauthorized

CommunicationErrorResponse

Unauthorized.

403 Forbidden

CommunicationErrorResponse

Forbidden.

429 Too Many Requests

CommunicationErrorResponse

Too many requests.

Other Status Codes

CommunicationErrorResponse

Service unavailable.

Security

Authorization

An ACS (Azure Communication Services) user access token.

Type: apiKey
In: header

Examples

Send Message

Sample Request

POST https://contoso.westus.communications.azure.com/chat/threads/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/messages?api-version=2024-03-07

{
  "content": "Let's head out for lunch in 15 minutes.",
  "senderDisplayName": "Jane",
  "metadata": {
    "someKey1": "someValue1",
    "someKey2": "someValue2"
  }
}

Sample Response

Location: https://contoso.westus.communications.azure.com/chat/threads/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/messages/1593072104708
{
  "id": "1593072104708"
}
{
  "error": {
    "code": "Unauthorized",
    "message": "Request is not authorized."
  }
}
{
  "error": {
    "code": "Forbidden",
    "message": "User is not allowed to perform specified action."
  }
}
{
  "error": {
    "code": "TooManyRequests",
    "message": "Rate limit exceeded."
  }
}
{
  "error": {
    "code": "ServiceUnavailable",
    "message": "The server is currently unable to handle the request."
  }
}

Definitions

Name Description
ChatMessageType

The chat message type.

SendChatMessageRequest

Details of the message to send.

SendChatMessageResult

Result of the send message operation.

ChatMessageType

The chat message type.

Name Type Description
html

string

participantAdded

string

participantRemoved

string

text

string

topicUpdated

string

SendChatMessageRequest

Details of the message to send.

Name Type Description
content

string

Chat message content.

metadata

object

Message metadata.

senderDisplayName

string

The display name of the chat message sender. This property is used to populate sender name for push notifications.

type

ChatMessageType

The chat message type.

SendChatMessageResult

Result of the send message operation.

Name Type Description
id

string

A server-generated message id.