Skip to main content

DeleteObjects

This operation 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 operation provides a suitable alternative to sending individual delete requests, reducing per-request overhead.

The request can contain 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, Astran S3 performs a delete operation 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, Astran S3 returns the result as deleted.

The operation supports two modes for the response: verbose and quiet. By default, the operation 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 operation encountered an error. For a successful deletion in a quiet mode, the operation does not return any information about the delete in the response body.

Permissions

ActionDescriptionResource
DeleteObjectGrants permission to delete an object from a bucketobject
DeleteObjectVersionGrants permission to delete a specific version of an object from a bucketobject
caution

Having the DeleteObject permission does not grant you DeleteObjectVersion permission, and vice versa. Each permission is independent of the other.

The following operations are related to DeleteObjects:

Request Syntax

POST /Bucket?delete HTTP/1.1
Host: <partition>.s3.astran.io
<?xml version="1.0" encoding="UTF-8"?>
<Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Object>
<Key>string</Key>
<VersionId>string</VersionId>
</Object>
...
<Quiet>boolean</Quiet>
</Delete>

URI Request Parameters

The request uses the following URI parameters.

Bucket

The bucket name containing the objects to delete.

Required: Yes

Request Body

The request accepts the following data in XML format.

Delete

Root level tag for the Delete parameters.

Required: Yes

Object

The object to delete.

Type: Array of ObjectIdentifier data types

Required: Yes

Quiet

Element to enable quiet mode for the request. When you add this element, you must set its value to true.

Type: Boolean

Required: No

Response Syntax

HTTP/1.1 200
<?xml version="1.0" encoding="UTF-8"?>
<DeleteResult>
<Deleted>
<DeleteMarker>boolean</DeleteMarker>
<DeleteMarkerVersionId>string</DeleteMarkerVersionId>
<Key>string</Key>
<VersionId>string</VersionId>
</Deleted>
...
<Error>
<Code>string</Code>
<Key>string</Key>
<Message>string</Message>
<VersionId>string</VersionId>
</Error>
...
</DeleteResult>

Response Elements

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

The response returns the following HTTP headers.

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

DeleteResult

Root level tag for the DeleteResult parameters.

Required: Yes

Deleted

Container element for a successful delete. It identifies the object that was successfully deleted.

Type: Array of DeletedObject data types

Error

Container for a failed delete action that describes the object that Astran S3 attempted to delete and the error it encountered.

Type: Array of Error data types

Examples

Multi-object delete resulting in mixed success/error response

This example illustrates a Multi-Object Delete request to delete objects that result in mixed success and errors response. The following request deletes two objects from a bucket (bucketname). In this example, the requester does not have permission to delete the sample2.txt object.


POST /Bucket?delete HTTP/1.1
Host: <partition>.s3.astran.io
Accept: */*
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee=
Content-Length: 125

<Delete>
<Object>
<Key>sample1.txt</Key>
</Object>
<Object>
<Key>sample2.txt</Key>
</Object>
</Delete>

Sample Response for general purpose buckets

The response includes a DeleteResult element that includes a Deleted element for the item that Astran S3 successfully deleted and an Error element that Astran S3 did not delete because you didn't have permission to delete the object.


HTTP/1.1 200 OK
x-amz-date: 20240925T090917Z
Content-Type: application/xml
Content-Length: 251

<?xml version="1.0" encoding="UTF-8"?>
<DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Deleted>
<Key>sample1.txt</Key>
</Deleted>
<Error>
<Key>sample2.txt</Key>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
</Error>
</DeleteResult>

Sample Request for general purpose buckets: Deleting an object from a versioned bucket

If you delete an item from a versioning enabled bucket, all versions of that object remain in the bucket; however, Astran S3 inserts a delete marker. For more information, see Object Versioning.

The following scenarios describe the behavior of a multi-object Delete request when versioning is enabled for your bucket.

Case 1 - Simple Delete: In the following sample request, the multi-object delete request specifies only one key.


POST /Bucket?delete HTTP/1.1
Host: <partition>.s3.astran.io
Accept: */*
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee=
Content-Length: 79

<Delete>
<Object>
<Key>SampleDocument.txt</Key>
</Object>
</Delete>

Case 1 - Simple Delete: Sample Response for general purpose buckets

Because versioning is enabled on the bucket, Astran S3 does not delete the object. Instead, it adds a delete marker for this object. The following response indicates that a delete marker was added (the DeleteMarker element in the response as a value of true) and the version number of the delete marker it added.

            HTTP/1.1 200 OK
x-amz-date: 20240925T090917Z
Content-Type: application/xml
Content-Length: 276

<?xml version="1.0" encoding="UTF-8"?>
<DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Deleted>
<Key>SampleDocument.txt</Key>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>NeQt5xeFTfgPJD8B4CGWnkSLtluMr11s</DeleteMarkerVersionId>
</Deleted>
</DeleteResult>

Case 2 for general purpose buckets - Versioned Delete

The following request attempts to delete a specific version of an object.


POST /Bucket?delete HTTP/1.1
Host: <partition>.s3.astran.io
Accept: */*
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee=
Content-Length: 140

<Delete>
<Object>
<Key>SampleDocument.txt</Key>
<VersionId>OYcLXagmS.WaD..oyH4KRguB95_YhLs7</VersionId>
</Object>
</Delete>

Case 2 - Sample Response for general purpose buckets

In this case, Astran S3 deletes the specific object version from the bucket and returns the following response. In the response, Astran S3 returns the key and version ID of the object deleted.

            HTTP/1.1 200 OK
x-amz-date: 20240925T090917Z
Content-Type: application/xml
Content-Length: 219

<?xml version="1.0" encoding="UTF-8"?>
<DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Deleted>
<Key>SampleDocument.txt</Key>
<VersionId>OYcLXagmS.WaD..oyH4KRguB95_YhLs7</VersionId>
</Deleted>
</DeleteResult>

Case 3 for general purpose buckets - Versioned delete of a delete marker

In the preceding example, if the request refers to a delete marker (instead of an object), then Astran S3 deletes the delete marker. The effect of this action is to make your object reappear in your bucket. Astran S3 returns a response that indicates the delete marker it deleted (DeleteMarker element with value true) and the version ID of the delete marker.

            HTTP/1.1 200 OK
x-amz-date: 20240925T090917Z
Content-Type: application/xml
Content-Length: 331

<?xml version="1.0" encoding="UTF-8"?>
<DeleteResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Deleted>
<Key>SampleDocument.txt</Key>
<VersionId>NeQt5xeFTfgPJD8B4CGWnkSLtluMr11s</VersionId>
<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>NeQt5xeFTfgPJD8B4CGWnkSLtluMr11s</DeleteMarkerVersionId>
</Deleted>
</DeleteResult>

In general, when a multi-object Delete request results in Astran S3 either adding a delete marker or removing a delete marker, the response returns the following elements.


<DeleteMarker>true</DeleteMarker>
<DeleteMarkerVersionId>NeQt5xeFTfgPJD8B4CGWnkSLtluMr11s</DeleteMarkerVersionId>

Sample Request for general purpose buckets: Malformed XML in the request

This example shows how Astran S3 responds to a request that includes a malformed XML document. The following request sends a malformed XML document (missing the Delete end element).


POST /Bucket?delete HTTP/1.1
Host: <partition>.s3.astran.io
Accept: */*
Date: Mon, 25 Sep 2024 09:09:17 GMT
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee=
Content-Length: 104

<Delete>
<Object>
<Key>404.txt</Key>
</Object>
<Object>
<Key>a.txt</Key>
</Object>

Sample Response for general purpose buckets

The response returns the error messages that describe the error.


HTTP/1.1 200 OK
x-amz-date: 20240925T090917Z
Content-Type: application/xml
Content-Length: 207

<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>MalformedXML</Code>
<Message>The XML you provided was not well-formed or did not
validate against our published schema</Message>
<RequestId>264A17BF16E9E80A</RequestId>
<HostId>P3xqrhuhYxlrefdw3rEzmJh8z5KDtGzb+/FB7oiQaScI9Yaxd8olYXc7d1111ab+</HostId>
</Error>

Sample Request for general purpose buckets: DeleteObjects containing a carriage return

The following example illustrates the use of an XML entity code as a substitution for a carriage return. This DeleteObjects request deletes an object with the key parameter: /some/prefix/objectwith\rcarriagereturn(where the \r is the carriage return).

<Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Object>
<Key>/some/prefix/objectwith&#13;carriagereturn</Key>
</Object>
</Delete>

See Also

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