Use Requester Pays (original) (raw)
Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Tools to access and manage objects using a directory structure
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Access control
- Overview
- Bucket IP filtering
* Overview
* Create a bucket with IP filtering rules
* Create or update IP filtering rules on an existing bucket
* Get IP bucket filtering rules
* List bucket IP filtering rules
* Delete bucket IP filtering rules
* Disable bucket IP filtering
* Bypass bucket IP filtering rules - Sharing and collaboration scenarios
- Access control best practices
Monitor data and usage
Protection, backup, and recovery
Soft delete
Mount buckets with Cloud Storage FUSE
Performance
Work across products, Clouds, and platforms
Troubleshoot
Use Requester Pays
This page describes how to enable and disable Requester Pays, as well as how to check to see if Requester Pays is enabled on a bucket.
Required roles
In order to get the required permissions for setting and managing Requester Pays, ask your administrator to grant you the Storage Admin (roles.storage.Admin) role on the project that contains the bucket.
This role contains the permissions required to set and manage Requester Pays. To see the exact permissions that are required, expand theRequired permissions section:
Required permissions
storage.buckets.getstorage.buckets.updateresourcemanager.projects.createBillingAssignment- This permission is only required if you don't have a billing account to use when disabling Requester Pays. For more information, seeUse and access requirements.
You might also be able to get these permissions with otherpredefined roles or custom roles.
For instructions on granting roles on projects, seeGrant or revoke a role.
To enable or disable Requester Pays on a bucket:
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
Go to Buckets - In the list of buckets, find the bucket you want to set and locate theRequester pays column.
The value in the column indicates the current state of Requester Pays for that bucket. - Click the current state of Requester Pays for the bucket.
- In the window that appears, click Turn on or Turn off, depending on the state you want to set for Requester Pays.
When enabled, a green bubble and On appear in the Requester payscolumn for the bucket. When disabled, a gray bubble and Off appear in the column.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, seeTroubleshooting.
Command line
Use the gcloud storage buckets update command with the appropriate flag:
gcloud storage buckets update gs://BUCKET_NAME FLAG
Where:
BUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.FLAGis either--requester-paysto enable Requester Pays or--no-requester-paysto disable it.
If successful, the response looks similar to the following example:
Updating gs://my-bucket/... Completed 1
Client libraries
C++
For more information, see theCloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
C#
For more information, see theCloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
Go
For more information, see theCloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
Java
For more information, see theCloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
Node.js
For more information, see theCloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
PHP
For more information, see theCloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
Python
For more information, see theCloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
Ruby
For more information, see theCloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
The following sample enables Requester Pays on a bucket:
The following sample disables Requester Pays on a bucket:
REST APIs
JSON API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - Create a JSON file that contains the following information:
{
"billing": {
"requesterPays": STATE
}
}
Where STATE is eithertrueorfalse. - Use cURL to call the JSON API with aPATCH Bucket request:
curl -X PATCH --data-binary @JSON_FILE_NAME \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=billing"
Where:JSON_FILE_NAMEis the path for the JSON file that you created in Step 2.BUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.
XML API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - Create an XML file that contains the following information: STATE Where STATE is either `Enabled` or `Disabled`.
- Use cURL to call the XML API with aPUT Bucket request and
billingquery string parameter:
curl -X PUT --data-binary @XML_FILE_NAME \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/BUCKET_NAME?billing"
Where:XML_FILE_NAMEis the path for the XML file that you created in Step 2.BUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.
Check whether Requester Pays is enabled
To check whether Requester Pays is enabled on a bucket:
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
Go to Buckets - In the list of buckets, the Requester Pays status of each bucket is found in the Requester Pays column.
If enabled, the status is green and the word On appears.
Command line
Use the gcloud storage buckets describe command with the--format flag:
gcloud storage buckets describe gs://BUCKET_NAME --format="default(requester_pays)"
Where BUCKET_NAME is the name of the bucket whose status you want to view. For example, my-bucket.
If successful, the response looks similar to the following example:
requester_pays: true
Client libraries
C++
For more information, see theCloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
C#
For more information, see theCloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Go
For more information, see theCloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
For more information, see theCloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
For more information, see theCloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
PHP
For more information, see theCloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
For more information, see theCloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
REST APIs
JSON API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - Use cURL to call the JSON API with aGET Bucket request:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=billing"
WhereBUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.
XML API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - Use cURL to call the XML API with aGET Bucket request and
billingquery string parameter:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/BUCKET_NAME?billing"
WhereBUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.
Access Requester Pays buckets
The following example shows how to include a billing project so that you can download an object stored in a Requester Pays bucket. Use a similar procedure to perform other requests on the Requester Pays bucket or on objects within it. See Requester Pays access requirements for prerequisite considerations.
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
Go to Buckets - In the list of buckets, click the name of the bucket that contains the object you want to download.
- In the window that appears, use the drop-down menu to select a project for billing.
- Check the checkbox to confirm you are authorized to use the selected project for billing purposes.
- Click Save.
- Download the object as you normally would.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, seeTroubleshooting.
Command line
Use the --billing-project flag in your request:
gcloud storage cp gs://BUCKET_NAME/OBJECT_NAME SAVE_TO_LOCATION --billing-project=PROJECT_IDENTIFIER
Where:
BUCKET_NAMEis the name of the bucket containing the object you are downloading. For example,my-bucket.OBJECT_NAMEis the name of object you are downloading. For example,pets/dog.png.SAVE_TO_LOCATIONis the local path where you are saving your object. For example,Desktop/Images.PROJECT_IDENTIFIERis the ID or number of the project to be billed. For example,my-project.
Client libraries
C++
For more information, see theCloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
C#
For more information, see theCloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Go
For more information, see theCloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
For more information, see theCloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
For more information, see theCloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
PHP
For more information, see theCloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
For more information, see theCloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Ruby
For more information, see theCloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
REST APIs
JSON API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - In your request, include the
userProjectquery string parameter set to the ID of the project to be billed:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-o "SAVE_TO_LOCATION" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o/OBJECT_NAME?alt=media&userProject=PROJECT_IDENTIFIER"
Where:SAVE_TO_LOCATIONis the location where you want to save your object. For example,Desktop/dog.png.BUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.OBJECT_NAMEis the URL-encoded name of the object you want to download. For example,pets/dog.png, URL-encoded aspets%2Fdog.png.PROJECT_IDENTIFIERis the ID or number of the project to be billed. For example,my-project.
XML API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - In your request, include the
x-goog-user-projectheader set to the ID of the project to be billed:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: PROJECT_ID" \
-o "SAVE_TO_LOCATION" \
"https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME"
Where:PROJECT_IDis the ID of the project to be billed. For example,my-project.SAVE_TO_LOCATIONis the location where you want to save your object. For example,Desktop/dog.png.BUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.OBJECT_NAMEis the URL-encoded name of the object you want to download. For example,pets/dog.png, URL-encoded aspets%2Fdog.png.
What's next
- Learn more about Requester Pays.
- Make data publicly available.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-09 UTC.