Send channel message
Send channel message
https://api.agora.io/dev/v2/project/<appid>/rtm/users/<user_id>/channel_messages
Sends a channel message from the server. You can send a message to a channel without joining it first.
Request
Path parameters
The App ID of your Agora project.
Signaling user ID to send a channel message. It must not exceed 64 characters in length or be an empty string. This parameter supports the following characters:
- All lowercase English letters:
a-z. - All uppercase English letters:
A-Z. - All numeric characters:
0-9. - The space character. (Not recommended): If the user ID contains a space, then the user ID cannot communicate with the Signaling SDK.
- Punctuation characters and other symbols, including:
!,#,$,%,&,(,),+,-,:,;,<,=,.,>,?,@,[,],^,_,{,},|,~,,,'
Since user_id is a URL parameter, the first character and the last characters must not be a space.
Request body
BODYrequired
- channel_name stringrequired
Signaling channel name to receive a channel message. It must not exceed 64 characters in length or be an empty string. This parameter supports the following characters:
- All lowercase English letters:
a-z. - All uppercase English letters:
A-Z. - All numeric characters:
0-9. - The space character. (Not recommended): If the channel name contains a space, then the API cannot communicate with the Signaling SDK.
- Punctuation characters and other symbols, including:
!,#,$,%,&,(,),+,-,:,;,<,=,.,>,?,@,[,],^,_,{,},|,~,,,'
- All lowercase English letters:
- enable_historical_messaging booleannullable
Default:
falseWhether to save as a historical message.
true: Save as a historical message. You can use the historical message RESTful API to query historical messages.false: Do not save as a historical message.
- payload stringrequired
Content of the channel message. It must not be an empty string or exceed 32 KB in length.
Response
- If the returned status code is
200, the request was successful. The response body contains the result of the request.
OK
- result string
Request result.
success: The request succeeds.failed: The request fails.
- request_id string
Unique ID to identify this request.
- code string
Message status.
message_sent: The message is sent.
- If the returned status code is not
200, the request failed. The response body includes the error code and description. Refer to status codes to understand the possible reasons for failure.