DeleteMessageBatch - Amazon Simple Queue Service


Deletes up to ten messages from the specified queue. This is a batch version of DeleteMessage. The result of the action on each message is reported individually in the response.


Because the batch request can result in a combination of successful and unsuccessful actions, you should check for batch errors even when the call returns an HTTP status code of 200.

Request Syntax

{ "Entries": [ { "Id": "string", "ReceiptHandle": "string" } ], "QueueUrl": "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.


Lists the receipt handles for the messages to be deleted.

Type: Array of DeleteMessageBatchRequestEntry objects

Required: Yes


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

Queue URLs and names are case-sensitive.

Type: String

Required: Yes

Response Syntax

{ "Failed": [ { "Code": "string", "Id": "string", "Message": "string", "SenderFault": boolean } ], "Successful": [ { "Id": "string" } ] }

Response Elements

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

The following data is returned in JSON format by the service.


A list of BatchResultErrorEntry items.

Type: Array of BatchResultErrorEntry objects


A list of DeleteMessageBatchResultEntry items.

Type: Array of DeleteMessageBatchResultEntry objects


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


Two or more batch entries in the request have the same Id.

HTTP Status Code: 400


The batch request doesn't contain any entries.

HTTP Status Code: 400


The accountId is invalid.

HTTP Status Code: 400


The Id of a batch entry in a batch request doesn't abide by the specification.

HTTP Status Code: 400


When the request to a queue is not HTTPS and SigV4.

HTTP Status Code: 400


The specified queue doesn't exist.

HTTP Status Code: 400


The request was denied due to request throttling.

  • The rate of requests per second exceeds the AWS KMS request quota for an account and Region.

  • A burst or sustained high rate of requests to change the state of the same KMS key. This condition is often known as a "hot key."

  • Requests for operations on KMS keys in a AWS CloudHSM key store might be throttled at a lower-than-expected rate when the AWS CloudHSM cluster associated with the AWS CloudHSM key store is processing numerous commands, including those unrelated to the AWS CloudHSM key store.

HTTP Status Code: 400


The batch request contains more entries than permissible.

HTTP Status Code: 400


Error code 400. Unsupported operation.

HTTP Status Code: 400


The following examples show how a DeleteMessageBatch request deletes two messages. You must URL-encode the entire URL. However, in this example only the message body is URL-encoded to make the example easier to read. 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 AWS General Reference.


Using AWS JSON protocol (default)

Sample Request

POST / HTTP/1.1 Host: X-Amz-Target: AmazonSQS.DeleteMessageBatch X-Amz-Date: <Date> Content-Type: application/x-amz-json-1.0 Authorization: <AuthParams> Content-Length: <PayloadSizeBytes> Connection: Keep-Alive { "QueueUrl": "", "Entries": [ { "Id": "msg1", "ReceiptHandle": "AQEBaZ+j5qUoOAoxlmrCQPkBm9njMWXqemmIG6shMHCO6fV20JrQYg/AiZ8JELwLwOu5U61W+aIX5Qzu7GGofxJuvzymr4Ph53RiR0mudj4InLSgpSspYeTRDteBye5tV/txbZDdNZxsi+qqZA9xPnmMscKQqF6pGhnGIKrnkYGl45Nl6GPIZv62LrIRb6mSqOn1fn0yqrvmWuuY3w2UzQbaYunJWGxpzZze21EOBtywknU3Je/g7G9is+c6K9hGniddzhLkK1tHzZKjejOU4jokaiB4nmi0dF3JqLzDsQuPF0Gi8qffhEvw56nl8QCbluSJScFhJYvoagGnDbwOnd9z50L239qtFIgETdpKyirlWwl/NGjWJ45dqWpiW3d2Ws7q" }, { "Id": "msg2", "ReceiptHandle": "AQEB3LQoW7GQWgodQCEJXHjMvO/QkeCHiRldRfLC/E6RUggm+BjpthqxfoUOUn6Vs271qmrBaufFqEmnMKgk2n1EuUBne1pe+hZcrDE8IveUUPmqkUT54FGhAAjPX3oEIryz/XeQ/muKAuLclcZvt2Q+ZDPW8DvZqMa1RoHxOqSq+6kQ4PwgQxB+VqDYvIc/LpHOoL4PTROBXgLPjWrzz/knK6HTzKpqC4ESvFdJ/dkk2nvS0iqYOly5VQknK/lv/rTUOgEYevjJSrNLIPDgZGyvgcLwbm6+yo1cW/c9cPDiVm96gIhVkuiCZ1gtskoOtyroZVPcY71clDG2EPZJeY8akMd3u+sXEMWhiOPFs1cgWQs2ugsL+vdwMCbsZRkXbJv7" } ] }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: <requestId> Content-Length: <> Date: <Date> Content-Type: application/x-amz-json-1.0 { "Failed": [], "Successful": [ { "Id": "msg2" }, { "Id": "msg1" } ] }


Using AWS 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=DeleteMessageBatch &DeleteMessageBatchRequestEntry.1.Id=msg1 &DeleteMessageBatchRequestEntry.1.ReceiptHandle=gfk0T0R0waama4fVFffkjPQrrvzMrOg0fTFk2LxT33EuB8wR0ZCFgKWyXGWFoqqpCIiprQUEhir%2F5LeGPpYTLzjqLQxyQYaQALeSNHb0us3uE84uujxpBhsDkZUQkjFFkNqBXn48xlMcVhTcI3YLH%2Bd%2BIqetIOHgBCZAPx6r%2B09dWaBXei6nbK5Ygih21DCDdAwFV68Jo8DXhb3ErEfoDqx7vyvC5nCpdwqv%2BJhU%2FTNGjNN8t51v5c%2FAXvQsAzyZVNapxUrHIt4NxRhKJ72uICcxruyE8eRXlxIVNgeNP8ZEDcw7zZU1Zw%3D%3D &DeleteMessageBatchRequestEntry.2.Id=msg2 &DeleteMessageBatchRequestEntry.2.ReceiptHandle=gfk0T0R0waama4fVFffkjKzmhMCymjQvfTFk2LxT33G4ms5subrE0deLKWSscPU1oD3J9zgeS4PQQ3U30qOumIE6AdAv3w%2F%2Fa1IXW6AqaWhGsEPaLm3Vf6IiWqdM8u5imB%2BNTwj3tQRzOWdTOePjOjPcTpRxBtXix%2BEvwJOZUma9wabv%2BSw6ZHjwmNcVDx8dZXJhVp16Bksiox%2FGrUvrVTCJRTWTLc59oHLLF8sEkKzRmGNzTDGTiV%2BYjHfQj60FD3rVaXmzTsoNxRhKJ72uIHVMGVQiAGgB%2BqAbSqfKHDQtVOmJJgkHug%3D%3D

Sample Response

HTTP/1.1 200 OK <?xml version="1.0"?> <DeleteMessageBatchResponse xmlns=""> <DeleteMessageBatchResult> <DeleteMessageBatchResultEntry> <Id>msg1</Id> </DeleteMessageBatchResultEntry> <DeleteMessageBatchResultEntry> <Id>msg2</Id> </DeleteMessageBatchResultEntry> </DeleteMessageBatchResult> <ResponseMetadata> <RequestId>d6f86b7a-74d1-4439-b43f-196a1e29cd85</RequestId> </ResponseMetadata> </DeleteMessageBatchResponse>

See Also

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