All Products
Search
Document Center

Simple Message Queue (formerly MNS):DeleteMessage

Last Updated:Mar 11, 2026

Deletes a consumed message from a queue using its receipt handle.

PropertyValue
APIDeleteMessage
Actionmns:DeleteMessage
Resourceacs:mns:$region:$accountid:/queues/$queueName/messages

Description

DeleteMessage removes a message from a queue after the message has been consumed. To identify the message, provide the receipt handle returned by the most recent ReceiveMessage call.

The receipt handle is valid only until the time specified by NextVisibleTime. After that time, the message returns to the Active state and the receipt handle expires. To delete the message after the handle expires, consume the message again to get a new receipt handle.

Important

Each consume operation returns a different receipt handle. Always use the receipt handle from the most recent receive operation. Earlier handles are no longer valid for deletion.

Request

Request line

DELETE /queues/$queueName/messages? ReceiptHandle=<receiptHandle> HTTP/1.1

URI parameters

ParameterTypeRequiredDescription
ReceiptHandleStringYesThe receipt handle returned when the message was last consumed. For more information, see ReceiveMessage.

Request headers

No operation-specific request headers.

Request body

None.

Response

Success response

HTTP/1.1 204 No Content

Response headers

No operation-specific response headers.

Response body

None.

Examples

Sample request

DELETE /queues/$queueName/messages? ReceiptHandle=MbZj6wDWli+QEauMZc8ZRv37sIW2iJKq3M9Mx/KSbkJ0 HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXA****

Sample response

HTTP/1.1 204 No Content
x-mns-request-id: 512B2A634403E52B1956****
x-mns-version: 2015-06-06

Error codes

Error codeHTTP status codeError messageDescription
QueueNotExist404The queue name you provided does not exist.The specified queue does not exist. Verify the queue name in the request URI.
InvalidArgument400The value of Element should between Low and High seconds/bytes.A parameter value is out of the valid range. Check the request parameters against the allowed value ranges.
ReceiptHandleError400The receipt handle you provided is not valid.The receipt handle has expired because NextVisibleTime has passed, or an outdated handle was used. Consume the message again to get a new receipt handle.