> For the complete documentation index, see [llms.txt](https://docs.petabox.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.petabox.io/http-api-compatible-with-amazon-s3/api-reference/deleteobjects.md).

# DeleteObjects

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, Petabox 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, Petabox 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.

MFA Deletes are not supported for the moment.

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

## Request Syntax <a href="#api_deleteobjects_requestsyntax" id="api_deleteobjects_requestsyntax"></a>

```http
POST /?delete HTTP/1.1
Host: Bucket.s3.petabox.io
x-amz-request-payer: RequestPayer
x-amz-bypass-governance-retention: BypassGovernanceRetention
x-amz-expected-bucket-owner: ExpectedBucketOwner
<?xml version="1.0" encoding="UTF-8"?>
<Delete xmlns="http://s3.petabox.io/doc/2006-03-01/">
   <Object>
      <Key>string</Key>
      <VersionId>string</VersionId>
   </Object>
   ...
   <Quiet>boolean</Quiet>
</Delete>
```

## URI Request Parameters <a href="#api_deleteobjects_requestparameters" id="api_deleteobjects_requestparameters"></a>

The request uses the following URI parameters.

#### Bucket

The bucket name containing the objects to delete.

Required: Yes

#### x-amz-bypass-governance-retention

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:BypassGovernanceRetention` permission.

#### x-amz-expected-bucket-owner

The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with the HTTP status code `403 Forbidden` (access denied).

#### x-amz-request-payer

Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests.&#x20;

Valid Values: `requester`

#### x-amz-sdk-checksum-algorithm

Not supported at the moment.

## Request Body <a href="#api_deleteobjects_requestbody" id="api_deleteobjects_requestbody"></a>

The request accepts the following data in XML format.

#### Delete

Root level tag for the Delete parameters.

Required: Yes

#### Object

The objects 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 <a href="#api_deleteobjects_responsesyntax" id="api_deleteobjects_responsesyntax"></a>

```http
POST /?delete HTTP/1.1
Host: Bucket.s3.petabox.io
x-amz-request-payer: RequestPayer
x-amz-bypass-governance-retention: BypassGovernanceRetention
x-amz-expected-bucket-owner: ExpectedBucketOwner
<?xml version="1.0" encoding="UTF-8"?>
<Delete xmlns="http://s3.petabox.io/doc/2006-03-01/">
   <Object>
      <Key>string</Key>
      <VersionId>string</VersionId>
   </Object>
   ...
   <Quiet>boolean</Quiet>
</Delete>
```

## Response Elements <a href="#api_deleteobjects_responseelements" id="api_deleteobjects_responseelements"></a>

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

The response returns the following HTTP headers.

#### x-amz-request-charged

If present, indicates that the requester was successfully charged for the request.

Valid Values: `requester`

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 Petabox attempted to delete and the error it encountered.

Type: Array of Error data types

## Examples <a href="#api_deleteobjects_examples" id="api_deleteobjects_examples"></a>

### Sample Request: Multi-object delete resulting in mixed success/error response <a href="#api_deleteobjects_example_1" id="api_deleteobjects_example_1"></a>

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.

```http
POST /?delete HTTP/1.1
Host: bucketname.s3.<Region>.petabox.io
Accept: */*
x-amz-date: Wed, 30 Nov 2011 03:39:05 GMT
Content-MD5: p5/WA/oEr30qrEEl21PAqw==
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee==
Content-Length: 125
Connection: Keep-Alive

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

### Sample Response <a href="#api_deleteobjects_example_2" id="api_deleteobjects_example_2"></a>

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

```http
HTTP/1.1 200 OK
x-amz-id-2: 5h4FxSNCUS7wP5z92eGCWDshNpMnRuXvETa4HH3LvvH6VAIr0jU7tH9kM7X+njXx
x-amz-request-id: A437B3B641629AEE
Date: Fri, 02 Dec 2011 01:53:42 GMT
Content-Type: application/xml
Server: Petabox
Content-Length: 251

<?xml version="1.0" encoding="UTF-8"?>
<DeleteResult xmlns="http://s3.petabox.io/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: Deleting an object from a versioned bucket <a href="#api_deleteobjects_example_3" id="api_deleteobjects_example_3"></a>

If you delete an item from a versioning enabled bucket, all versions of that object remain in the bucket; however, Petabox inserts a delete marker.&#x20;

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.

```http
POST /?delete HTTP/1.1
Host: bucketname.s3.<Region>.petabox.io
Accept: */*
x-amz-date: Wed, 30 Nov 2011 03:39:05 GMT
Content-MD5: p5/WA/oEr30qrEEl21PAqw==
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee=
Content-Length: 79
Connection: Keep-Alive

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

### Sample Response <a href="#api_deleteobjects_example_4" id="api_deleteobjects_example_4"></a>

Because versioning is enabled on the bucket, Petabox 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
HTTP/1.1 200 OK
x-amz-id-2: P3xqrhuhYxlrefdw3rEzmJh8z5KDtGzb+/FB7oiQaScI9Yaxd8olYXc7d1111ab+
x-amz-request-id: 264A17BF16E9E80A
Date: Wed, 30 Nov 2011 03:39:32 GMT
Content-Type: application/xml
Server: Petabox
Content-Length: 276

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

#### Case 2 - Versioned Delete <a href="#api_deleteobjects_example_5" id="api_deleteobjects_example_5"></a>

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

```http
POST /?delete HTTP/1.1
Host: bucketname.s3.<Region>.petabox.io
Accept: */*
x-amz-date: Wed, 30 Nov 2011 03:39:05 GMT
Content-MD5: p5/WA/oEr30qrEEl21PAqw==
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIxx=
Content-Length: 140
Connection: Keep-Alive

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

### Sample Response <a href="#api_deleteobjects_example_6" id="api_deleteobjects_example_6"></a>

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

```http
HTTP/1.1 400 Bad Request
x-amz-id-2: P3xqrhuhYxlrefdw3rEzmJh8z5KDtGzb+/FB7oiQaScI9Yaxd8olYXc7d1111xx+
x-amz-request-id: 264A17BF16E9E80A
Date: Wed, 30 Nov 2011 03:39:32 GMT
Content-Type: application/xml
Server: Petabox
Content-Length: 219

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

#### Case 3 - Versioned delete of a delete marker <a href="#api_deleteobjects_example_7" id="api_deleteobjects_example_7"></a>

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

```http
HTTP/1.1 200 OK
x-amz-id-2: IIPUZrtolxDEmWsKOae9JlSZe6yWfTye3HQ3T2iAe0ZE4XHa6NKvAJcPp51zZaBr
x-amz-request-id: D6B284CEC9B05E4E
Date: Wed, 30 Nov 2011 03:43:25 GMT
Content-Type: application/xml
Server: Petabox
Content-Length: 331

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

### Sample Response <a href="#api_deleteobjects_example_8" id="api_deleteobjects_example_8"></a>

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

```xml
<DeleteMarker>true</DeleteMarker>  
<DeleteMarkerVersionId>NeQt5xeFTfgPJD8B4CGWnkSLtluMr
```

### Sample Request: Malformed XML in the request <a href="#api_deleteobjects_example_9" id="api_deleteobjects_example_9"></a>

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

```http
POST /?delete HTTP/1.1
Host: bucketname.s3.<Region>.petabox.io
Accept: */*
x-amz-date: Wed, 30 Nov 2011 03:39:05 GMT
Content-MD5: p5/WA/oEr30qrEEl21PAqw==
Authorization: AWS AKIAIOSFODNN7EXAMPLE:W0qPYCLe6JwkZAD1ei6hp9XZIee=
Content-Length: 104
Connection: Keep-Alive

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

### Sample Response <a href="#api_deleteobjects_example_10" id="api_deleteobjects_example_10"></a>

The response returns the error messages that describe the error.

```http
HTTP/1.1 200 OK
x-amz-id-2: P3xqrhuhYxlrefdw3rEzmJh8z5KDtGzb+/FB7oiQaScI9Yaxd8olYXc7d1111ab+
x-amz-request-id: 264A17BF16E9E80A
Date: Wed, 30 Nov 2011 03:39:32 GMT
Content-Type: application/xml
Server: Petabox
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 to DeleteObjects containing a carriage return <a href="#api_deleteobjects_example_11" id="api_deleteobjects_example_11"></a>

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).

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.petabox.io/http-api-compatible-with-amazon-s3/api-reference/deleteobjects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
