InitBucketObjectLock
Updated at:2025-11-03
API description
Create a time-based compliance retention policy for the specified bucket. In this case, the policy status will change to IN_PROGRESS.
Note:
- The validity period of this status is 24 hours. The bucket resources corresponding to this policy are protected in this 24-hour period, with the protection rules as follows: Suppose you create a bucket named examplebucket on June 1, 2013, and upload three Objects: file1.txt, file2.txt, and file3.txt at different time. Subsequently, a bucket locking policy with a protection period of 5 years was created on July 1, 2014. The specific upload time and corresponding expiration time for these three objects are as follows:
Object name Upload time Object expiration time file1.txt June 1, 2013 May 31, 2018 file2.txt July 1, 2014 June 30, 2019 file3.txt September 30, 2018 September 29, 2023
- When bucket data is protected, any attempts (including your own) to delete or modify the data will result in a 409 FileImmutable error from the BOS API. Please apply this compliance policy carefully.
Request
-
Request syntax
Plain Text1POST /?objectlock HTTP/1.1 2Host: <BucketName>.bj.bcebos.com 3Date: <Date> 4Authorization: <AuthorizationString> 5Content-Type: application/json; charset=utf-8 6Content-Length: <ContentLength> 7{ 8 "retentionDays" : 30 9} -
Request headers
No special request headers
-
Request parameters
| Name | Types | Description | Required or not |
|---|---|---|---|
| retentionDays | int | Protection period, in days. | Yes |
Response
Example
-
Request example
Plain Text1POST /?objectlock HTTP/1.1 2Host: <BucketName>.bj.bcebos.com 3x-bce-date: 2016-04-06T06:34:40Z 4Authorization: AuthorizationString 5{ 6 "retentionDays" : 30 7} -
Response example
Plain Text1HTTP/1.1 200 OK 2x-bce-request-id: 4db2b34d-654d-4d8a-b49b-3049ca786409 3Content-Length: 0 4Date: Wed, 06 Apr 2016 06:34:40 GMT 5Server: BceBos
