--- title: "S3 Conditional Deletes" slug: "s3-conditional-deletes" tags: ["5.4"] updated: 2026-10-28T01:54:03Z published: 2026-10-28T01:54:03Z canonical: "docs.vastdata.com/s3-conditional-deletes" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.vastdata.com/llms.txt > Use this file to discover all available pages before exploring further. # S3 Conditional Deletes With [S3 conditional deletes](https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-deletes.html), conditions in `DeleteObject` or `DeleteObjects` requests let you check, prior to the deletion, if the intended object still exists or if it has been overwritten. Conditional deletes are also supported for versioned objects. If an object in a versioned bucket has a delete marker, a simple DELETE request (the one that does not specify a particular version) against such an object is handled as though the object does not exist. - To check if the object still exists: - For `DeleteObject` : Include the HTTP `If-Match` header with a value of `*`, for example: ```plaintext DELETE /myobject HTTP/1.1 If-Match: * ``` For a versioned bucket: ```plaintext DELETE /myobject?versionId=5 HTTP/1.1 If-Match: * ``` - For `DeleteObjects`: Set the object's ETag element in the XML request body to `*`, for example: ```plaintext POST /?delete HTTP/1.1        myobject      *   ``` For a versioned bucket: ```plaintext POST /?delete HTTP/1.1        myobject1      *      5          myobject2      *      5   ``` This operation requires `s3:DeleteObject` permissions. If the object exists, the operation succeeds and the object gets deleted. Otherwise, error code 404 is returned. - To check if the object has been overwritten: - For `DeleteObject`: Include the the HTTP `If-Match` header with a value that represents the ETag of the object to be deleted. For example: ```plaintext DELETE /myobject HTTP/1.1 If-Match: "7f138a09169b250e9dcb378140907378" ``` For a versioned bucket: ```plaintext DELETE /myobject?versionId=5 HTTP/1.1 If-Match: "7f138a09169b250e9dcb378140907378" ``` - For `DeleteObjects`: Set the object's ETag element in the XML request body to the ETag of the object to be deleted. For example: ```plaintext POST /?delete HTTP/1.1        myobject1      "9b2cf535f27731c974343645a3985328"          myobject2      "5d41402abc4b2a76b9719d911017c592"   ``` For a versioned bucket: ```plaintext POST /?delete HTTP/1.1        myobject1      "9b2cf535f27731c974343645a3985328"      5          myobject2      "5d41402abc4b2a76b9719d911017c592"      5   ``` This operation requires `s3:DeleteObject` and `s3:GetObject` permissions. If the object's ETag matches the ETag in the delete request, the operation succeeds and the object gets deleted. Otherwise, error code 412 is returned. ## Controlling Conditional Deletes with a Bucket Policy You can configure a bucket policy to only accept a `DeleteObject` or `DeleteObjects` request when the request is conditional and includes an ETag, which can be a specific ETag value or the asterisk wildcard (`*`) for any value. This forces clients to use the `If-Match` HTTP header in their delete requests.