Sends a message to a queue.


By default, only Alibaba Cloud accounts can call this operation. RAM users can call this operation only after these RAM users are granted related permissions. The following table describes the authorization information of this operation. For more information, see Permission policies and examples.

Item Value
API operation SendMessage
Action mns:SendMessage
Resource acs:mns:$region:$accountid:/queues/$queueName/messages


You can call this operation to send a message to a queue. A standard message can be immediately consumed after the message is sent to the queue. If you do not want the message to be immediately consumed, you can specify the DelaySeconds parameter when you send the message. If you set the DelaySeconds parameter to a value that is greater than 0, the initial status of the message is Delayed after the message is sent to a queue. The message cannot be consumed until the period specified by the DelaySeconds parameter ends and the message changes to the Active state.

Note If two values of the DelaySeconds parameter that is specified for the message and queue are different, the delay period specified for the message takes effect.


A request consists of the following parts:

  • Request line

    POST /queues/$queueName/messages HTTP/1.1

  • Operation-specific request headers


  • Request body

    The request body is in XML format. It contains the parameters of the message.

    Parameter Type Required Example Description
    MessageBody String Yes This is a test message The body of the message.
    DelaySeconds Integer No 60 The delay period after which the message sent to the queue can be consumed.

    Valid values: 0 to 604800. Unit: seconds.

    Default value: 0.

    Priority Integer No 1 The priority of the message. A message with a higher priority can be consumed earlier.

    Valid values: 1 to 16. A smaller value indicates a higher priority.

    Default value: 8.


A response consists of the following parts:

  • HTTP status code

    HTTP/1.1 201 Created

  • Operation-specific response headers


  • Response body

    The response body is in the XML format. The MessageId and MessageBodyMD5 parameters of the message are returned.

    Parameter Type Example Description
    MessageId String 5F290C926D472878-2-14D9529A8FA-20000**** The ID of the message. The message ID is unique in the queue.
    MessageBodyMD5 String C5DD56A39F5F7BB8B3337C6D11B6**** The MD5 hash of the message body.
    ReceiptHandle String 1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg== The receipt handle that was returned after the delayed message was received.


Sample requests

POST /queues/$queueName/messages HTTP/1.1
Host: $
Date: Wed, 18 Mar 2012 12:00:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEX****

<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns="">
    <MessageBody>This is a test message</MessageBody>

Sample success responses

HTTP/1.1 201 Created
x-mns-version: 2015-06-06

<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns="">

Error codes

Error code Error message HTTP status code Description
QueueNotExist The queue name you provided is not exist. 404 The error message returned because the specified queue does not exist. Create a queue.
MalformedXML The XML you provided was not well-formed. 400 The error message returned because the XML file you provided is malformed.
InvalidArgument The value of Element should between Low and High seconds/bytes. 400 The error message returned because the value of the parameter is invalid. You must specify a valid value as prompted.