DeleteMessage - Amazon Simple Queue Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


Deletes the specified message from the specified queue. To select the message to delete, use the ReceiptHandle of the message (not the MessageId which you receive when you send the message). Amazon SQS can delete a message from a queue even if a visibility timeout setting causes the message to be locked by another consumer. Amazon SQS automatically deletes messages left in a queue longer than the retention period configured for the queue.


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. When you use the DeleteMessage action, you must provide the most recently received ReceiptHandle for the message (otherwise, the request succeeds, but the message will 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. The copy remains on the server and might be returned to you during a subsequent receive request. You should ensure that your application is idempotent, so that receiving a message more than once does not cause issues.

Request Syntax

{ "QueueUrl": "string", "ReceiptHandle": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.


The URL of the Amazon SQS queue from which messages are deleted.

Queue URLs and names are case-sensitive.

Type: String

Required: Yes


The receipt handle associated with the message to delete.

Type: String

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.


For information about the errors that are common to all actions, see Common Errors.


The specified receipt handle isn't valid for the current version.

HTTP Status Code: 400


The specified receipt handle isn't valid.

HTTP Status Code: 400


The following example query request deletes a message from the queue named MyQueue. The structure of AUTHPARAMS depends on the signature of the API request. For more information, see Examples of Signed Signature Version 4 Requests in the Amazon General Reference.


Using Amazon query protocol

Sample Request

POST /177715257436/MyQueue/ HTTP/1.1 Host: Content-Type: application/x-www-form-urlencoded X-Amz-Date: <Date> Authorization: <AuthParams> Content-Length: <PayloadSizeBytes> Connection: Keep-Alive Action=DeleteMessage &ReceiptHandle=AQEBMeG2RcZZrIcgBkDFb6lHqL9B9tbbEHNh+4uxMIG+CPupPjqJtRswDlOr6hOTzgcq105i0iZNci5GS5RTnHTkD2zipM9gHfSP2tWPhY7HHsU5GCTZ+egzS5HiEvmGZ71g71Lucdk7mes1/WGXnmU27K26Koo9GGrB0AKTv16dync1ezCMNyrBHEMUyIWS2lUTbrSj7fw93dgZSg2eWTk+thSVUB/ibOwpmj+wBN99nKQQklsZHtZd4exT1V3JHwP4kqz+D3C2RGn7js3nNdFpH41lBH8rCTZDU8DQp9eQNHLIL6RUf1WrI8gv8L7NErGlIH4Y3wZbFEOMKilVHenfpP2G6ElMuxyM3y+qdlZq4m00VGIIZeMg9PPmVsLtB7u9mruLyNFraN5ihKMjzQoKgA==

Sample Response

HTTP/1.1 200 OK <?xml version="1.0"?> <DeleteMessageResponse xmlns=""> <ResponseMetadata> <RequestId>b5293cb5-d306-4a17-9048-b263635abe42</RequestId> </ResponseMetadata> </DeleteMessageResponse>

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: