Skip to content

delete_object_tagging

delete_object_tagging(
    bucket: BucketName,
    key: ObjectKey,
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    version_id: Optional[ObjectVersionId] = None,
    expected_bucket_owner: Optional[AccountId] = None,
) -> DeleteObjectTaggingOutput

This operation is not supported for directory buckets.

Removes the entire tag set from the specified object. For more information about managing object tags, see Object Tagging.

To use this operation, you must have permission to perform the s3:DeleteObjectTagging action.

To delete tags of a specific object version, add the versionId query parameter in the request. You will need permission for the s3:DeleteObjectVersionTagging action.

The following operations are related to DeleteObjectTagging:

You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.

Parameters:

  • bucket (BucketName) –

    The bucket name containing the objects from which to remove the tags.

    Access points - When you use this action with an access point for general purpose buckets, you must provide the alias of the access point in place of the bucket name or specify the access point ARN. When you use this action with an access point for directory buckets, you must provide the access point name in place of the bucket name. When using the access point ARN, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide.

    S3 on Outposts - When you use this action with S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When you use this action with S3 on Outposts, the destination bucket must be the Outposts access point ARN or the access point alias. For more information about S3 on Outposts, see What is S3 on Outposts? in the Amazon S3 User Guide.

  • key (ObjectKey) –

    The key that identifies the object in the bucket from which to remove all tags.

  • version_id (Optional[ObjectVersionId], default: None ) –

    The versionId of the object that the tag-set will be removed from.

  • expected_bucket_owner (Optional[AccountId], default: None ) –

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

Raises:

Examples:

To remove tag set from an object The following example removes tag set associated with the specified object. If the bucket is versioning enabled, the operation removes tag set from the latest object version.

>>> client.delete_object_tagging(bucket='examplebucket', key='HappyFace.jpg')
To remove tag set from an object version
The following example removes tag set associated with the specified object version. The request specifies both the object key and object version.
>>> client.delete_object_tagging(bucket='examplebucket', key='HappyFace.jpg', version_id='ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI')
Source code in docs_src/capo_s3/_services/s3.py
def delete_object_tagging(
    self,
    bucket: "capo_s3.types.bucket_name.BucketName",
    key: "capo_s3.types.object_key.ObjectKey",
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    version_id: Optional["capo_s3.types.object_version_id.ObjectVersionId"] = None,
    expected_bucket_owner: Optional["capo_s3.types.account_id.AccountId"] = None,
) -> "capo_s3.types.delete_object_tagging_output.DeleteObjectTaggingOutput":
    """<note> <p>This operation is not supported for directory buckets.</p> </note> <p>Removes the entire tag set from the specified object. For more information about managing object tags, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html"> Object Tagging</a>.</p> <p>To use this operation, you must have permission to perform the <code>s3:DeleteObjectTagging</code> action.</p> <p>To delete tags of a specific object version, add the <code>versionId</code> query parameter in the request. You will need permission for the <code>s3:DeleteObjectVersionTagging</code> action.</p> <p>The following operations are related to <code>DeleteObjectTagging</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectTagging.html">PutObjectTagging</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html">GetObjectTagging</a> </p> </li> </ul> <important> <p>You must URL encode any signed header values that contain spaces. For example, if your header value is <code>my file.txt</code>, containing two spaces after <code>my</code>, you must URL encode this value to <code>my%20%20file.txt</code>.</p> </important>

    Args:
        bucket: <p>The bucket name containing the objects from which to remove the tags. </p> <p> <b>Access points</b> - When you use this action with an access point for general purpose buckets, you must provide the alias of the access point in place of the bucket name or specify the access point ARN. When you use this action with an access point for directory buckets, you must provide the access point name in place of the bucket name. When using the access point ARN, you must direct requests to the access point hostname. The access point hostname takes the form <i>AccessPointName</i>-<i>AccountId</i>.s3-accesspoint.<i>Region</i>.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html">Using access points</a> in the <i>Amazon S3 User Guide</i>.</p> <p> <b>S3 on Outposts</b> - When you use this action with S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form <code> <i>AccessPointName</i>-<i>AccountId</i>.<i>outpostID</i>.s3-outposts.<i>Region</i>.amazonaws.com</code>. When you use this action with S3 on Outposts, the destination bucket must be the Outposts access point ARN or the access point alias. For more information about S3 on Outposts, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html">What is S3 on Outposts?</a> in the <i>Amazon S3 User Guide</i>.</p>
        key: <p>The key that identifies the object in the bucket from which to remove all tags.</p>
        version_id: <p>The versionId of the object that the tag-set will be removed from.</p>
        expected_bucket_owner: <p>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 <code>403 Forbidden</code> (access denied).</p>

    Raises:
        capo_s3.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To remove tag set from an object
        The following example removes tag set associated with the specified object. If the bucket is versioning enabled, the operation removes tag set from the latest object version.

        >>> client.delete_object_tagging(bucket='examplebucket', key='HappyFace.jpg')
        To remove tag set from an object version
        The following example removes tag set associated with the specified object version. The request specifies both the object key and object version.

        >>> client.delete_object_tagging(bucket='examplebucket', key='HappyFace.jpg', version_id='ydlaNkwWm0SfKJR.T1b1fIdPRbldTYRI')
    """

    def _handler(
        req: "OperationRequest[capo_s3.types.delete_object_tagging_request.DeleteObjectTaggingRequest]",
    ) -> OperationResponse[
        "capo_s3.types.delete_object_tagging_output.DeleteObjectTaggingOutput"
    ]:
        import capo_s3._operations.amazon_s3.delete_object_tagging

        output, http_response = (
            capo_s3._operations.amazon_s3.delete_object_tagging.delete_object_tagging(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteObjectTagging")
    )
    input_: capo_s3.types.delete_object_tagging_request.DeleteObjectTaggingRequest = {
        "bucket": bucket,
        "key": key,
    }
    if version_id is not None:
        input_["version_id"] = version_id
    if expected_bucket_owner is not None:
        input_["expected_bucket_owner"] = expected_bucket_owner

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output