PutBucketInventory
Updated at:2025-11-03
API description
PutBucketInventory allows you to create an inventory task in the source bucket. You can name the task and use this request to initiate the inventory process.
BOS advises users to create a lifecycle policy to automatically delete outdated inventory list files.
Note:
- The user must own the source bucket with FULL_CONTROL permissions and also own the target bucket.
- The source and destination buckets must both exist, belong to the same account, and reside in the same region. Cross-account outputs are not supported.
- BOS allows for the creation of up to 20 inventory tasks per bucket.
- The inventory list reflects eventual consistency for both new objects and overwritten PUTs, as well as DELETE operations. It acts as a rolling snapshot of the bucket, meaning the content is eventually consistent, and recent object additions or deletions may not be included.
Request
-
Request syntax
Plain Text1PUT /?inventory&id=inventory-configuration-ID HTTP/1.1 2Host: <BucketName>.bj.bcebos.com 3x-bce-date: date 4Content-Length: request-body length 5Content-Type: application/json; charset=utf-8 6Authorization: AuthorizationString 7{ 8 "id": "inventory-configuration-ID", 9 "status": "enabled", 10 "resource": [ 11 "bucket/prefix/*" 12 ], 13 "schedule": "Weekly", 14 "destination": { 15 "targetBucket": "destBucketName", 16 "targetPrefix": "destination-prefix", 17 "format": "CSV" 18 } 19} -
Request headers
None
-
Request parameters
| Name | Types | Description | Required or not |
|---|---|---|---|
| id | string | Rule name of inventory. Specification: Maximum 64 bytes. Valid characters: "a-z", "A-Z", "0-9", "-", "_", and ".". | Yes |
| status | string | Identifier indicating whether the inventory is effective. If it is set to be "enabled", the inventory function will take effect; if it is set to be "disabled", no inventory will be generated. | Yes |
| resource | list | Sub-elements are strings. Effective prefix. The resource configuration format is bucket_name/<Effective Object Prefix>, and must start with bucket_name/. To apply to the entire bucket, use bucket_name/*. |
Yes |
| schedule | string | The inventory task schedule. Allowed values: ThreeDaily, Weekly, and Monthly, corresponding to every three days, weekly, and monthly respectively. | Yes |
| monthlyDate | int | If the inventory task is set to run monthly, specify the date for the inventory output. Only integers between 1 and 28 are supported. | No |
| destination | object | Details the storage information for the inventory results. | Yes |
| +targetBucket | string | Specifies the bucket where inventory files will be stored. | Yes |
| +targetPrefix | string | Defines the prefix for the final saved inventory file. | No |
| +format | string | The format of the inventory analysis results. Currently supported format: CSV. | Yes |
Response
Example
-
Request example
Plain Text1PUT /?inventory&id=inventory-configuration-ID HTTP/1.1 2Host: <BucketName>.bj.bcebos.com 3x-bce-date: date 4Content-Length: request-body length 5Content-Type: application/json; charset=utf-8 6Authorization: AuthorizationString 7{ 8 "id": "inventory-configuration-ID", 9 "status": "enabled", 10 "resource": [ 11 "bucket/prefix/*" 12 ], 13 "schedule": "Weekly", 14 "destination": { 15 "targetBucket": "destBucketName", 16 "targetPrefix": "destination-prefix", 17 "format": "CSV" 18 } 19} -
Response example
Plain Text1HTTP/1.1 200 OK 2x-bce-request-id: 4db4b34d-653d-4d9a-b49b-3049ca786409 3Date: Wed, 31 May 2018 08:34:40 GMT 4Server: BceBos
