S3 delete multiple objects
Deletes multiple objects from a bucket in a single request. Each object entry can include optional metadata fields to perform conditional deletes.
Syntax
Conditional delete
When deleting multiple objects, you can include optional metadata for each object to ensure that deletion occurs only if conditions are met.
- ETag
- Deletes the object only if the current ETag matches the specified value.
- LastModifiedTime
- Deletes the object only if the last modified time matches the specified timestamp.
- Size
- Deletes the object only if the size matches the specified size in bytes.
Note: If any condition fails, that object entry is skipped, and the response includes the error for that object. Other objects in the batch are still processed.
Examples
Example 1: Delete multiple objects. Deletes three objects in one request.
aws s3api delete-objects \
--bucket my-batch-bucket \
--delete '{
"Objects": [
{"Key": "images/photo1.jpg"},
{"Key": "images/photo2.jpg"},
{"Key": "images/photo3.jpg"}
],
"Quiet": false
}'
Example 2: Conditional delete of multiple objects using ETag, LastModifiedTime, and Size Deletes each object only if the specified metadata matches.
aws s3api delete-objects \
--bucket my-dir-bucket-usw2-az1-x-s3 \
--delete '{
"Objects": [
{
"Key": "logs/2025/january.log",
"ETag": "b1946ac92492d2347c6235b4d2611184",
"LastModifiedTime": "2025-09-22T14:12:00Z",
"Size": 4096
},
{
"Key": "logs/2025/february.log",
"ETag": "5d41402abc4b2a76b9719d911017c592"
}
],
"Quiet": false
}'