DeleteMessageBatchCommand

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.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { SQSClient, DeleteMessageBatchCommand } from "@aws-sdk/client-sqs"; // ES Modules import
// const { SQSClient, DeleteMessageBatchCommand } = require("@aws-sdk/client-sqs"); // CommonJS import
const client = new SQSClient(config);
const input = { // DeleteMessageBatchRequest
  QueueUrl: "STRING_VALUE", // required
  Entries: [ // DeleteMessageBatchRequestEntryList // required
    { // DeleteMessageBatchRequestEntry
      Id: "STRING_VALUE", // required
      ReceiptHandle: "STRING_VALUE", // required
    },
  ],
};
const command = new DeleteMessageBatchCommand(input);
const response = await client.send(command);
// { // DeleteMessageBatchResult
//   Successful: [ // DeleteMessageBatchResultEntryList // required
//     { // DeleteMessageBatchResultEntry
//       Id: "STRING_VALUE", // required
//     },
//   ],
//   Failed: [ // BatchResultErrorEntryList // required
//     { // BatchResultErrorEntry
//       Id: "STRING_VALUE", // required
//       SenderFault: true || false, // required
//       Code: "STRING_VALUE", // required
//       Message: "STRING_VALUE",
//     },
//   ],
// };

DeleteMessageBatchCommand Input

See DeleteMessageBatchCommandInput for more details

Parameter
Type
Description
Entries
Required
DeleteMessageBatchRequestEntry[] | undefined

Lists the receipt handles for the messages to be deleted.

QueueUrl
Required
string | undefined

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

Queue URLs and names are case-sensitive.

DeleteMessageBatchCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
Failed
Required
BatchResultErrorEntry[] | undefined

A list of BatchResultErrorEntry items.

Successful
Required
DeleteMessageBatchResultEntry[] | undefined

A list of DeleteMessageBatchResultEntry items.

Throws

Name
Fault
Details
BatchEntryIdsNotDistinct
client

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

EmptyBatchRequest
client

The batch request doesn't contain any entries.

InvalidAddress
client

The specified ID is invalid.

InvalidBatchEntryId
client

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

InvalidSecurity
client

The request was not made over HTTPS or did not use SigV4 for signing.

QueueDoesNotExist
client

Ensure that the QueueUrl is correct and that the queue has not been deleted.

RequestThrottled
client

The request was denied due to request throttling.

  • Exceeds the permitted request rate for the queue or for the recipient of the request.

  • Ensure that the request rate is within the Amazon SQS limits for sending messages. For more information, see Amazon SQS quotas  in the Amazon SQS Developer Guide.

TooManyEntriesInBatchRequest
client

The batch request contains more entries than permissible. For Amazon SQS, the maximum number of entries you can include in a single SendMessageBatch , DeleteMessageBatch , or ChangeMessageVisibilityBatch  request is 10.

UnsupportedOperation
client

Error code 400. Unsupported operation.

SQSServiceException
Base exception class for all service exceptions from SQS service.