You can call this operation to enable pay-by-requester for a bucket.

Usage notes

Note the following items when you enable pay-by-requester for a bucket:

  • Access from anonymous users is rejected

    If you enable pay-by-requester for a bucket, anonymous users are not allowed to access the bucket. Requesters must provide authentication information to OSS so that OSS can identify and charge requesters for requests and traffic.

    If a requester assumes a RAM role of an Alibaba Cloud account to request data, OSS charges this Alibaba Cloud account for the requests sent by the requester and the generated traffic.

  • Requesters must specify the x-oss-request-payer header in the request

    If you enable pay-by-requester for a bucket, requesters must specify the x-oss-request-payer:requester header in the POST, GET, or HEAD requests. This header indicates that requesters understand that they are charged for the requests and downloaded data. If requester does not specify the x-oss-request-payer header in requests sent to a bucket with pay-by-requester enabled, the requests fail to pass authentication.

    Bucket owners do not need to specify the x-oss-request-payer header in requests sent to access their buckets. In this case, bucket owners are charged for the requests sent by them and the traffic generated by the requests.

Request structure

PUT /? requestPayment HTTP/1.1
Date: GMT Date
Content-Length: ContentLength
Content-Type: application/xml
Host: BucketName.oss.aliyuncs.com
Authorization: SignatureValue 
<? xml version="1.0" encoding="UTF-8"? >
<RequestPaymentConfiguration>
  <Payer>Requester</Payer>
</RequestPaymentConfiguration>

Request headers

PutBucketRequestPayment requests contain only common request headers. For more information, see Common request headers.

Request elements

Element Type Required Description
RequestPaymentConfiguration Container Yes The container that stores pay-by-requester configurations.

Child node: Payer

Payer String Yes The payer of the request and traffic fees.
Valid values:
  • BucketOwner: request and traffic fees are paid by the bucket owner.
  • Requester: request and traffic fees are paid by the requester.
,

Parent node: RequestPaymentConfiguration

Response headers

Responses for PutBucketRequestPayment requests contain only common response headers. For more information, see Common response headers.

Examples

Sample request
PUT /? requestPayment
Content-Length: 83
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 23 Jul 2019 01:33:47 GMT
Authorization: OSS qn6qrrqxo2oawuk53otf****:77Dvh5wQgIjWjwO/KyRt8dOP****
<RequestPaymentConfiguration>
  <Payer>Requester</Payer>
</RequestPaymentConfiguration>
Sample response
200 (OK)
content-length: 0
x-oss-request-id: 5D3663FBB007B79097FC****
date: Tue, 23 Jul 2019 01:33:47 GMT

SDK

You can use OSS SDKs for the following programming languages to call PutBucketRequestPayment:

Error codes

Error code HTTP status code Description
NoSuchBucket 404 The error message returned because the specified bucket does not exist.