Skip to content

S3Client.delete_object

rboto-s3==0.4.0 · Service index · Types

Model summary (excerpt): Removes an object from a bucket. The behavior depends on the bucket's versioning state: If bucket versioning is not enabled, the operation permanently deletes the object. If bucket versioning is enabled, the operation inserts a delete marker, which becomes the current version of the object. To permanently delete an object in a versioned bucket, you must include the object’s versionId in the...

Install and imports

python -m pip install "rboto[s3]==0.4.0"
from rboto import S3Client
from rboto_s3.types import (
    DeleteObjectOutput,
    RequestPayer,
)

Signature

async def delete_object(
    *,
    bucket: str,
    key: str,
    mfa: str | None = None,
    version_id: str | None = None,
    request_payer: RequestPayer | None = None,
    bypass_governance_retention: bool | None = None,
    expected_bucket_owner: str | None = None,
    if_match: str | None = None,
    if_match_last_modified_time: str | None = None,
    if_match_size: int | None = None,
) -> DeleteObjectOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
bucket Yes The bucket name of the bucket containing the object. Directory buckets - When you use this operation with a directory bucket, you must use virtual-hosted-style requests in the format Bucket-name .s3express- zone-id . region-code .amazonaws.com . Path-style requests are not supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must...
key Yes Key name of the object to delete.
mfa No The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled. This functionality is not supported for directory buckets.
version_id No Version ID used to reference a specific version of the object. For directory buckets in this API operation, only the null value of the version ID is supported.
request_payer No
bypass_governance_retention No Indicates whether S3 Object Lock should bypass Governance-mode restrictions to process this operation. To use this header, you must have the s3:BypassGovernanceRetention permission. This functionality is not supported for directory buckets.
expected_bucket_owner No The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).
if_match No Deletes the object if the ETag (entity tag) value provided during the delete operation matches the ETag of the object in S3. If the ETag values do not match, the operation returns a 412 Precondition Failed error. Expects the ETag value as a string. If-Match does accept a string value of an '*' (asterisk) character to denote a match of any ETag. For more information about conditional requests,...
if_match_last_modified_time No If present, the object is deleted only if its modification times matches the provided Timestamp . If the Timestamp values do not match, the operation returns a 412 Precondition Failed error. If the Timestamp matches or if the object doesn’t exist, the operation returns a 204 Success (No Content) response. This functionality is only supported for directory buckets.
if_match_size No If present, the object is deleted only if its size matches the provided size in bytes. If the Size value does not match, the operation returns a 412 Precondition Failed error. If the Size matches or if the object doesn’t exist, the operation returns a 204 Success (No Content) response. This functionality is only supported for directory buckets. You can use the If-Match ,...

Output

DeleteObjectOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
delete_marker bool | None Always present —
version_id str | None Always present —
request_charged RequestChargedOutput | None Always present RequestChargedOutput

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

DeleteObjectOutput, RequestPayer

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

No modeled service errors for this operation.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model