Feature Overview
This API is used to delete a specified object. To call this API, you need to have permission to write to the object.
Versioning
To delete a specified version of object/delete marker, use the
versionId request parameter to specify the ID of the object version/delete marker. In this way, the x-cos-version-id response header will be returned, indicating the version ID to delete.If
versionId is not specified:When versioning is enabled, the
DELETE operation will create the latest version of delete marker for this object, and the x-cos-version-id response header will be returned to indicate the version ID of the delete marker created in this request.When versioning is suspended, the
DELETE operation will create a delete marker whose ID is null as the latest version of the object, and all other versions whose ID is null (if any) will be deleted.When the
DELETE operation creates or deletes a marker, the x-cos-delete-marker: true response header will be returned, indicating that the DELETE operation has created or deleted the delete marker for the specified object.For more information about the enabled/suspended status of versioning, please see Versioning Overview.
Requests
Sample Request
DELETE /<ObjectKey> HTTP/1.1Host: <BucketName-APPID>.cos.<Region>.myqcloud.comDate: GMT DateAuthorization: Auth String
Note
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com, where <BucketName-APPID> is the bucket name with the APPID suffix, such as examplebucket-1250000000. You can refer to the Bucket Overview > Basic Information and Bucket Overview > Bucket Naming Convention documentation. <Region> represents the available regions for COS, which can be found in the Regions and Access Domain Names documentation.
Authorization: Auth String (For more information, see Request Signature.)
Request Parameters
Name | Description | Local Disk Types | Required |
versionId | ID of an object version to delete | string | Not required |
Request Header
Request Body
The request body of this request is empty.
Response
Response Header
In addition to common response headers, this API also returns the following response headers. For more information on common response headers, see Common Response Headers.
Versioning-Related Headers
If you delete an object or a specified version of object from a versioning-enabled bucket, the following response headers will be returned:
Name | Description | Local Disk Types |
x-cos-version-id | ID of the object version/delete marker | string |
x-cos-delete-marker | When using the versionId request parameter to specify the delete marker's version ID, this response header will be returned with a value of true, indicating that the deleted version ID corresponds to a delete marker. When the versionId request parameter is not used and the specified object's bucket has versioning enabled, this response header will be returned with a value of true, indicating that the delete request created a new delete marker as the latest version of the object. | boolean |
Response Body
The response body is empty.
Error Codes
Examples
Example 1: versioning not enabled
Requests
DELETE /exampleobject HTTP/1.1Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.comDate: Wed, 14 Aug 2019 11:59:40 GMTAuthorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO**&q-sign-time=1565783980;1565791180&q-key-time=1565783980;1565791180&q-header-list=date;host&q-url-param-list=&q-signature=75ae614a90d55054f7dea2b5cdcfdeaa1f85**Connection: close
Response
HTTP/1.1 204 No ContentContent-Length: 0Connection: closeDate: Wed, 14 Aug 2019 11:59:40 GMTServer: tencent-cosx-cos-request-id: NWQ1M2Y3YWNfMzdiMDJhMDlfODA1Yl8xZThj****
Sample 2: enabling versioning (creating a delete marker)
Requests
DELETE /exampleobject HTTP/1.1Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.comDate: Wed, 14 Aug 2019 12:00:21 GMTAuthorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO**&q-sign-time=1565784021;1565791221&q-key-time=1565784021;1565791221&q-header-list=date;host&q-url-param-list=&q-signature=f5ee3ccd55378061f1890b9a2d3dd1af94f6**Connection: close
Response
HTTP/1.1 204 No ContentContent-Length: 0Connection: closeDate: Wed, 14 Aug 2019 12:00:21 GMTServer: tencent-cosx-cos-delete-marker: truex-cos-request-id: NWQ1M2Y3ZDVfN2RiNDBiMDlfMmMwNmVfMTc4****x-cos-version-id: MTg0NDUxNzgyODk2ODc1NjY0NzQ
Sample 3: deleting a specified version of object permanently
Requests
DELETE /exampleobject?versionId=MTg0NDUxNzgyODk3MDgyMzI4NDY HTTP/1.1Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.comDate: Wed, 14 Aug 2019 12:00:32 GMTAuthorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO**&q-sign-time=1565784032;1565791232&q-key-time=1565784032;1565791232&q-header-list=date;host&q-url-param-list=versionid&q-signature=9553e1210ba22f0725e5ff7f9bb7c8760c58**Connection: close
Response
HTTP/1.1 204 No ContentContent-Length: 0Connection: closeDate: Wed, 14 Aug 2019 12:00:32 GMTServer: tencent-cosx-cos-request-id: NWQ1M2Y3ZTBfODhjMjJhMDlfMWNkOF8xZDZi****x-cos-version-id: MTg0NDUxNzgyODk3MDgyMzI4NDY
Sample 4: deleting a specified delete marker permanently
Requests
DELETE /exampleobject?versionId=MTg0NDUxNzgyODk2ODc1NjY0NzQ HTTP/1.1Host: examplebucket-1250000000.cos.ap-beijing.myqcloud.comDate: Wed, 14 Aug 2019 12:00:42 GMTAuthorization: q-sign-algorithm=sha1&q-ak=AKID8A0fBVtYFrNm02oY1g1JQQF0c3JO**&q-sign-time=1565784042;1565791242&q-key-time=1565784042;1565791242&q-header-list=date;host&q-url-param-list=versionid&q-signature=14e18786f25e762fb11560ea788d5e07c375**Connection: close
Response
HTTP/1.1 204 No ContentContent-Length: 0Connection: closeDate: Wed, 14 Aug 2019 12:00:42 GMTServer: tencent-cosx-cos-delete-marker: truex-cos-request-id: NWQ1M2Y3ZWFfNzljMDBiMDlfMjkyMDJfMWRjNjVm****x-cos-version-id: MTg0NDUxNzgyODk2ODc1NjY0NzQ