Initializing Compliance Retention Policies
Updated at:2025-11-03
API description
This API allows you to create a time-based compliance retention policy for a specific bucket, with the policy status transitioning to IN_PROGRESS upon creation.
Note:
- The status remains valid for 24 hours. During this period, the associated bucket resources are safeguarded. To illustrate, consider you created a bucket named "examplebucket" on June 1, 2013, and uploaded three objects: file1.txt, file2.txt, and file3.txt at different times. Later, on July 1, 2014, a bucket locking policy was applied with a protection period of five years. The specific upload times and their corresponding expiration dates for these 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 URI
POST /v1/{bucketName}/?objectlock
| Parameter name | Parameter type | Required or not | Description | Example value | Parameter location |
|---|---|---|---|---|---|
| bucketName | String | Yes | Bucket name | "bucketName_example" | Path |
Parameters of request body
Description of the data structure of request body fields
| Parameter name | Parameter type | Required or not | Description | Example value |
|---|---|---|---|---|
| retentionDays | Integer | Yes | Protection period, in days. | 30 |
Response body parameters
None
Request example
JSON
1POST /v1/bucketName_example/?objectlock
2 <Common request headers>
3{
4 "retentionDays" : 30
5}
Response example
None
Error code
Please refer to the general error codes
