Enables or disables access tracking for a bucket.

Precautions

To enable or disable access tracking for a bucket, you must have the oss:PutBucketAccessMonitor permission. For more information, see Attach a custom policy to a RAM user.

Request syntax

PUT /?accessmonitor HTTP/1.1
Host: BucketName.oss.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue 
<?xml version="1.0" encoding="UTF-8"?>
<AccessMonitorConfiguration>
  <Status>Enabled</Status>
</AccessMonitorConfiguration>

Request headers

This request contains only common request headers. For more information, see Common request headers.

Request parameters

Parameter Type Required Example Description
AccessMonitorConfiguration Container Yes N/A The access tracking configuration of the bucket.

Child nodes: Status

Status String Yes Enabled Specifies whether to enable access tracking for the bucket. Default value: Disabled. Valid values:
  • Enabled: enables access tracking.

    After you enable access tracking for a bucket, Object Storage Service (OSS) uses the time when access tracking is enabled for the bucket as the default last access time of all objects in the bucket. Then, OSS updates the last access time of the objects in asynchronous mode based on the access of users.

    The last access time of the objects is updated with a latency. If you access an object multiple times within 24 hours, the last access time of the object is updated to the time when you access the object for the first time within the period. You can specify a lifecycle rule based on the last access time for the bucket.

  • Disabled: disables access tracking.

    You can set the access tracking state of a bucket to Disabled only if no lifecycle rules based on the last access time are configured for the bucket.

Parent nodes: AccessMonitorConfiguration

Response headers

This request contains only common response headers. For more information, see Common response headers.

Examples

Sample requests
PUT /?accessmonitor HTTP/1.1
Host: oss-example.oss.aliyuncs.com
Date: Mon, 26 Jul 2021 13:08:38 GMT
Authorization: OSS qn6qrrqxo2oawuk53otf****:ceOEyZavKY4QcjoUWYSpYbJ3**** 
<?xml version="1.0" encoding="UTF-8"?>
<AccessMonitorConfiguration>
  <Status>Enabled</Status>
</AccessMonitorConfiguration>
Sample responses
HTTP/1.1 200 OK
x-oss-request-id: 5C1B138A109F4E405B2D****
Date: Mon, 26 Jul 2021 13:08:38 GMT
Content-Length: 0
Connection: keep-alive
Server: AliyunOSS

Error codes

Error code HTTP status code Description
MalformedXML 400 The error message returned because the access tracking state of the bucket is invalid.
AccessMonitorDisableNotAllowed 400 The error message returned because the bucket has lifecycle rules configured based on the last access time. In this case, you cannot set the Status parameter to Disabled.
AccessDenied 403 The error message returned because you are not authorized to access the bucket.
NoSuchBucket 404 The error message returned because the bucket does not exist.