Querying the Object Lock

Last Updated At: 2025-10-21 09:10:00

Description

COS allows you set object locking for existing buckets. The GET Bucket ObjectLockConfiguration API is used to obtain the effective object locking configuration.

Request

Request Example

GET /?object-lock HTTP/1.1
Host: <BucketName-APPID>.<Endpoint>
Date: GMT Date
Authorization: Auth String 

Note:

  • <BucketName-APPID> is the bucket name with APPID as the suffix, for example, examplebucket-1250000000.
  • Authorization: Auth String (For details, refer to Request Signature).

Request Header

This API only uses common request headers. For details, see Common Request Headers documentation.

Request Body

The request body of this request is empty.

Response

Response Headers

This API only returns common response headers. For details, please refer to the Public Response Headers document.

Response Body

<?xml version="1.0" encoding="UTF-8" ?>
<ObjectLockConfiguration>
      <ObjectLockEnabled>Enabled</ObjectLockEnabled> 
      <Rule> 
           <DefaultRetention>
                 <Days>30</Days> 
           </DefaultRetention> 
      </Rule> 
</ObjectLockConfiguration> 

The detailed data is described as follows:

Node Name (Keyword) Parent Node Description Type
ObjectLockConfiguration No Object locking configuration Container
ObjectLockEnabled ObjectLockConfiguration Whether object locking is enabled String
Rule ObjectLockConfiguration Object locking rule Containers
DefaultRetention ObjectLockConfiguration.Rule Default object locking period Containers
Days ObjectLockConfiguration.Rule.DefaultRetention Duration of the default object locking period (1–36500 days) Int

Error Code

This API follows unified error response and error codes. For details, please refer to the Error Codes document.

Practical Case

Request

The following example obtains the object locking configuration of the bucket examplebucket-1250000000.

GET /?object-lock= HTTP/1.1
Host: examplebucket-1250000000.cos.city.yfm4.fsphere.cn
Authorization: Auth String

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 180
Connection: keep-alive
Date: Fri, 09 Dec 2022 08:31:25 GMT
x-cos-request-id: NjM5MmYyNWNfMzBkMDM4MGJfMmUzNzFfM****

<ObjectLockConfiguration>
    <ObjectLockEnabled>Enabled</ObjectLockEnabled>
    <Rule>
        <DefaultRetention>
            <Days>1</Days>
        </DefaultRetention>
    </Rule>
</ObjectLockConfiguration>