Querying a Bucket Policy

Last Updated At: 2025-10-21 09:10:00

Description

The GET Bucket policy API is used to read the permission policy of a bucket.

Request

Request Example

GET /?policy HTTP/1.1
Host: <BucketName-APPID>.<Endpoint>
Date:date
Authorization: Auth String

Note:

Authorization: Auth String (See Request Signature for details.)

Request Header

Common Headers

This request uses common request headers. For details, see Public Request Headers.

Non-common Headers

This request has no special request header information.

Request Body

The request body of this request is empty.

Response

Response Headers

Common Response Headers

This response uses common response headers. For details, see Common Response Headers.

Special Response Headers

There are no special response headers for this response operation.

Response Body

The permission policy is returned in the response body.

{
  "Statement": [
    {
      "Principal": {
        "qcs": [
          "qcs::cam::uin/100000000001:uin/100000000001"
        ]
      },
      "Effect": "allow",
      "Action": [
        "name/cos:GetBucket"
      ],
      "Resource": [
        "qcs::cos:ap-city:uid/1250000000:examplebucket-1250000000/*"
      ]
    }
  ],
  "version": "2.0"
}

Error Code

This request returns common error responses and error codes. For more information, see Error Codes.

Practical Case

Request

GET /?policy HTTP/1.1
Host: <BucketName-APPID>.<Endpoint>
Authorization:q-sign-algorithm=sha1&q-ak=AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&q-sign-time=1484814099;32557710099&q-key-time=1484814099;32557710099&q-header-list=host&q-url-param-list=policy&q-signature=0523d7c6305b6676611c44798d2c48b659e68869 

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 237
Connection: keep-alive
Date: Thu Jan 19 16:21:46 2017
x-cos-request-id: NTg4MDc3MWFfOWIxZjRlXzZmNDVfZTBl

{
  "Statement": [
    {
      "Principal": {
        "qcs": [
          "qcs::cam::uin/100000000001:uin/100000000001"
        ]
      },
      "Effect": "allow",
      "Action": [
        "name/cos:GetBucket"
      ],
      "Resource": [
        "qcs::cos:ap-city:uid/1250000000:examplebucket-1250000000/*"
      ]
    }
  ],
  "version": "2.0"
}