AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Container for the parameters to the DeleteObjects operation. This action enables you to delete multiple objects from a bucket using a single HTTP request. If you know the object keys that you want to delete, then this action provides a suitable alternative to sending individual delete requests, reducing per-request overhead.

The request contains a list of up to 1000 keys that you want to delete. In the XML, you provide the object key names, and optionally, version IDs if you want to delete a specific version of the object from a versioning-enabled bucket. For each key, Amazon S3 performs a delete action and returns the result of that delete, success, or failure, in the response. Note that if the object specified in the request is not found, Amazon S3 returns the result as deleted.

The action supports two modes for the response: verbose and quiet. By default, the action uses verbose mode in which the response includes the result of deletion of each key in your request. In quiet mode the response includes only keys where the delete action encountered an error. For a successful deletion, the action does not return any information about the delete in the response body.

When performing this action on an MFA Delete enabled bucket, that attempts to delete any versioned objects, you must include an MFA token. If you do not provide one, the entire request will fail, even if there are non-versioned objects you are trying to delete. If you provide an invalid token, whether there are versioned keys in the request or not, the entire Multi-Object Delete request will fail. For information about MFA Delete, see MFA Delete.

Finally, the Content-MD5 header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in transit.

The following operations are related to DeleteObjects:

Inheritance Hierarchy


Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z


public class DeleteObjectsRequest : AmazonWebServiceRequest

The DeleteObjectsRequest type exposes the following members


Public Method DeleteObjectsRequest()


Public Property BucketName System.String

Gets and sets the property BucketName.

The bucket name containing the objects to delete.

When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.

When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form When using this action using S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon S3 User Guide.

Public Property BypassGovernanceRetention System.Boolean

Gets and sets the property BypassGovernanceRetention.

Specifies whether you want to delete this object even if it has a Governance-type Object Lock in place. To use this header, you must have the s3:PutBucketPublicAccessBlock permission.

Public Property ExpectedBucketOwner System.String

Gets and sets the property ExpectedBucketOwner.

The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

Public Property MfaCodes Amazon.S3.Model.MfaCodes

The MfaCodes Tuple associates the Serial Number and the current Token/Code displayed on the Multi-Factor Authentication device associated with your AWS Account.

Public Property Objects System.Collections.Generic.List<Amazon.S3.Model.KeyVersion>

List of object keys to delete.

Public Property Quiet System.Boolean

Toggles between Quiet and Verbose mode for the operation. If set to true (Quiet mode), the response includes only those keys for objects on which the delete operation failed.

Public Property RequestPayer Amazon.S3.RequestPayer

Confirms that the requester knows that she or he will be charged for the request. Bucket owners need not specify this parameter in their requests.



Asynchronous operations (methods ending with Async) in the table below are for .NET 4.5 or higher. For .NET 3.5 the SDK follows the standard naming convention of BeginMethodName and EndMethodName to indicate asynchronous operations - these method pairs are not shown in the table below.

Public Method AddKey(string)

Add a key to the set of keys of objects to be deleted.

Public Method AddKey(string, string)

Add a key and a version to be deleted.


This example shows how to delete multiple objects in a single request.
Note that the call may not delete all objects. In that case, an exception will be thrown. This exception will contain the list of encountered delete errors.

DeleteObjects sample

// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a DeleteObject request
DeleteObjectsRequest request = new DeleteObjectsRequest
    BucketName = "SampleBucket",
    Objects = new List<KeyVersion>
        new KeyVersion() {Key = "Item1"},
        // Versioned item
        new KeyVersion() { Key = "Item2", VersionId = "Rej8CiBxcZKVK81cLr39j27Y5FVXghDK", },
        // Item in subdirectory
        new KeyVersion() { Key = "Logs/error.txt"}

    // Issue request
    DeleteObjectsResponse response = client.DeleteObjects(request);
catch (DeleteObjectsException doe)
    // Catch error and list error details
    DeleteObjectsResponse errorResponse = doe.Response;

    foreach (DeletedObject deletedObject in errorResponse.DeletedObjects)
        Console.WriteLine("Deleted item " + deletedObject.Key);
    foreach (DeleteError deleteError in errorResponse.DeleteErrors)
        Console.WriteLine("Error deleting item " + deleteError.Key);
        Console.WriteLine(" Code - " + deleteError.Code);
        Console.WriteLine(" Message - " + deleteError.Message);


Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5, 4.0, 3.5