Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Monitor data and usage
Protection, backup, and recovery
Mount buckets with Cloud Storage FUSE
Work across products, Clouds, and platforms
Troubleshoot
Stay organized with collections Save and categorize content based on your preferences.
This page describes how to configure your bucket to send notifications about object changes to a Pub/Sub topic. For information on subscribing to a Pub/Sub topic that receives notifications, see Choose a subscription type.
Before you beginBefore using this feature, complete the following instructions.
Enable the Pub/Sub APIEnable the Pub/Sub API for the project that will receive notifications.
Get required rolesTo get the permissions that you need to configure and view Pub/Sub notifications for a bucket, ask your administrator to grant you the following roles. These predefined roles contain the permissions required to configure and view Pub/Sub notifications.
Storage Admin (roles/storage.admin
) role on the bucket for which you want to configure Pub/Sub notifications
Pub/Sub Admin (roles/pubsub.admin
) role on the project in which you want to receive Pub/Sub notifications
You might be able to get these permissions with other predefined roles or custom roles.
See Set and manage IAM policies on buckets for instructions on granting roles on buckets. See Controlling access for instructions on granting roles on projects and setting access controls for topics and subscriptions.
Make sure you have an existing Pub/Sub topicIf you haven't already, create a Pub/Sub topic to which you want to send notifications. This step is not necessary if you plan on using the Google Cloud CLI or Terraform to perform the instructions on this page.
Grant required role to your project's service agentThe following steps are not necessary if you plan on using the Google Cloud CLI or Terraform to perform the instructions on this page.
Get the email address of the service agent associated with the project that contains your Cloud Storage bucket.
Grant the service agent the Pub/Sub Publisher (roles/pubsub.publisher
) role for the relevant Pub/Sub topic. See Controlling access for instructions on granting roles for topics.
The following steps add a notification configuration to your bucket that sends notifications for all supported events.
ConsoleYou cannot manage Pub/Sub notifications with the Google Cloud console. Use the gcloud CLI or one of the available client libraries instead.
Command lineUse the gcloud storage buckets notifications create
command:
gcloud storage buckets notifications create gs://BUCKET_NAME --topic=TOPIC_NAME
Where:
BUCKET_NAME
is the name of the relevant bucket. For example, my-bucket
.
TOPIC_NAME
is the Pub/Sub topic to send notifications to. If you specify a topic that doesn't exist in your project, the command creates one for you.
To send notifications for a subset of events, include the --event-types
flag.
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To create a notification configuration for a bucket using PHP, see the Google Cloud Client Library reference documentation. PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
TerraformYou can use a Terraform resource to add a notification configuration to a bucket.
REST APIs Get a notification configurationTo get a specific notification configuration that's associated with your bucket, complete the following steps:
ConsoleYou cannot manage Pub/Sub notifications with the Google Cloud console. Use the Google Cloud CLI or one of the available client libraries instead.
Command lineUse the gcloud storage buckets notifications describe
command:
gcloud storage buckets notifications describe projects/_/buckets/BUCKET_NAME/notificationConfigs/NOTIFICATION_ID
Where:
BUCKET_NAME
is the name of the bucket whose notification configuration you want to retrieve For example, my-bucket
.
NOTIFICATION_ID
is the ID number of the relevant configuration. For example, 5
.
If successful, the response looks similar to the following example:
etag: '132' id: '132' kind: storage#notification payload_format: JSON_API_V1 selfLink: https://www.googleapis.com/storage/v1/b/my-bucket/notificationConfigs/132 topic: //pubsub.googleapis.com/projects/my-project/topics/my-bucketClient libraries C++
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To get a notification configuration for a bucket using PHP, see the Google Cloud Client Library reference documentation. PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
REST APIs List notification configurations for a bucketTo list all the notification configurations associated with a particular bucket:
ConsoleYou cannot manage Pub/Sub notifications with the Google Cloud console. Use the gcloud CLI or one of the available client libraries instead.
Command lineUse the gcloud storage buckets notifications list
command:
gcloud storage buckets notifications list gs://BUCKET_NAME
Where BUCKET_NAME
is the name of the bucket whose notification configurations you want to list. For example, my-bucket
.
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To list notification configurations associated with a bucket using PHP, see the Google Cloud Client Library reference documentation. PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
REST APIs Remove a notification configurationTo remove an existing notification configuration from your bucket:
ConsoleYou cannot manage Pub/Sub notifications with the Google Cloud console. Use the gcloud CLI or one of the available client libraries instead.
Command lineUse the gcloud storage buckets notifications delete
command:
gcloud storage buckets notifications delete projects/_/buckets/BUCKET_NAME/notificationConfigs/NOTIFICATION_ID
Where:
BUCKET_NAME
is the name of the bucket whose notification configuration you want to delete. For example, my-bucket
.
NOTIFICATION_ID
is the ID number of the configuration you want to delete. For example, 5
.
If successful, the response looks similar to the following example:
Completed 1
Once sent, it might take up to 30 seconds for all notifications triggered by the notification configuration to stop.
Client libraries C++For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To delete a notification configuration for a bucket using PHP, see the Google Cloud Client Library reference documentation. PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
TerraformTo remove the notification configuration you created, run terraform destroy
from the folder containing your Terraform file.
Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization
header.
Use cURL
to call the JSON API with a DELETE notificationConfigs
request:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/notificationConfigs/NOTIFICATION_ID"
Where:
BUCKET_NAME
is the name of the bucket whose notification configuration you want to delete. For example, my-bucket
.
NOTIFICATION_ID
is the ID number of the notification configuration you want to delete. For example, 5
.
Once sent, it may take up to 30 seconds for all notifications triggered by the notification configuration to stop.
XML APIYou cannot manage Pub/Sub notifications with the XML API.
What's nextLearn more about Pub/Sub notifications for Cloud Storage.
Create a subscription in Pub/Sub to view notifications sent by Cloud Storage.
See a Python example app that polls for notifications on GitHub.
Use Cloud Run functions to deliver events with a Cloud Storage trigger.
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-10-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-02 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5