All Products
Search
Document Center

Simple Message Queue (formerly MNS):PublishMessage

Last Updated:Mar 11, 2026

Publishes a message to a topic. After the message is published, Simple Message Queue (formerly MNS) pushes it to the specified endpoints.

Request syntax

POST /topics/$TopicName/messages HTTP/1.1

Replace $TopicName with the name of the target topic.

Request headers

This operation uses common request headers only. For more information, see Common parameters.

Request body

The request body is an XML message with the following elements.

ParameterTypeRequiredDescription
MessageBodyStringYesThe message content.
MessageTagStringNoThe message tag.
MessageAttributesObjectYesThe push endpoint type. Valid values: HTTP (HTTP gateway) and Queue (push to an SMQ queue).
Note

The XML namespace must be http://mns.aliyuncs.com/doc/v1/. Requests that omit or use an incorrect namespace return an error.

Response parameters

ParameterTypeExampleDescription
MessageIdStringD273CD6A89564E54-1-15180395A19-20000\*\*\*\*A unique identifier for the message within the topic.
MessageBodyMD5String3AC6DD36D2D6B7283F2F490A0975\*\*\*\*The MD5 hash of the message body. Compare this value against a locally computed hash to verify message integrity.

Sample success response

Sample success response

HTTP/1.1 201 Created
Content-Length:120
Content-Type:text/xml;charset=utf-8
x-mns-request-id:56667514B2B71C9C1600****
x-mns-version:2015-06-06

<?xml version="1.0" encoding="utf-8"?>
<Message xmlns="http://mns.aliyuncs.com/doc/v1/">
    <MessageId>D273CD6A89564E54-1-15180395A19-20000****</MessageId>
    <MessageBodyMD5>3AC6DD36D2D6B7283F2F490A0975****</MessageBodyMD5>
</Message>

Error codes

For errors common to all operations, see Common parameters.

The following table lists the error codes specific to the PublishMessage operation.

HTTP status codeError codeError messageDescription
404TopicNotExistThe topic you provided does not exist.The topic name in the request URI does not match any existing topic. Verify the topic name.