Method for deleting messages from a queue. To select the message to delete, use the ReceiptHandle of the message. A message can be deleted even if it is received and being processed by another consumer. Message Queue automatically deletes messages if the value specified for the RetentionPeriod parameter is reached.

The ReceiptHandle is associated with a specific instance of receiving a message. If you receive a message more than once, the ReceiptHandle is different each time you receive a message. To delete a message, provide the most recently received ReceiptHandle for the message. Otherwise, the request will be successful but the message might not be deleted.

For standard queues, it is possible to receive a message even after you delete it. This might happen on rare occasions if one of the servers which stores a copy of the message is unavailable when you send the request to delete the message. Make sure that your application is idempotent, so that receiving a message more than once does not cause issues.


Request parameters

Parameter Type Required parameter Description
QueueUrl string Yes URL of the queue where the message is placed.
ReceiptHandle string Yes ReceiptHandle from the ReceiveMessage request.


Successful response fields

The response does not contain any fields.

DeleteMessage errors

For the list of possible responses, see Common errors.

HTTP code Error ID Description
400 InvalidIdFormat The specifiedReceiptHandle isn't valid for the current version.
400 ReceiptHandleIsInvalid The specified ReceiptHandle isn't valid.

Sample request


For more information about forming requests, see General API request format.

Response example