All Products
Search
Document Center

Object Storage Service:Query the retention policy configured for a bucket

Last Updated:Mar 20, 2026

Retrieves the Write Once Read Many (WORM) retention policy configured for a bucket, including the policy status and retention period.

Prerequisites

Before you begin, make sure that you have:

Syntax

ossutil api get-bucket-worm --bucket <bucket-name> [flags]

Parameters

ParameterTypeRequiredDescription
--bucketstringYesThe name of the bucket

For a full list of global flags, see Command-line options.

Examples

Query the retention policy for a bucket

ossutil api get-bucket-worm --bucket examplebucket

Query the retention policy and format the output as JSON

ossutil api get-bucket-worm --bucket examplebucket --output-format json

Query the retention policy and format the output as YAML

ossutil api get-bucket-worm --bucket examplebucket --output-format yaml

Usage notes

  • OSS supports a time-based retention policy based on the WORM model. Once configured, objects in the bucket cannot be deleted or overwritten until the retention period expires. A retention policy has a retention period that ranges from one day to 70 years.

  • After a policy is locked, you can read objects from and upload objects to the bucket. However, the policy itself and any objects within the retention period cannot be deleted.

What's next