This page describes how to enable and disable services for a Google Cloud project. You can use Service Usage to enable or disable any available service for your projects, including public Google Cloud services and private services created using Cloud Endpoints. For more information on the differences between public and private APIs and services, see Public and Private Services.
For most operational use cases, the simplest way to enable and disable services
is to use Google Cloud Console. If you need to create scripts, you can also use the
gcloud
command line interface. If you need to program against the
Service Usage API, we recommend that you use one of our provided
client libraries. To experiment with the API,
you can follow the alternative instructions in this guide and use the curl
command to test the API without setting up a full application development
environment.
Before you begin
To enable and disable APIs and services you need:
- A Cloud project. To learn how to create a Cloud project, see Creating and Managing Projects.
- The correct Identity and Access Management permissions. To learn about the IAM requirements for Service Usage, see Access Control.
- If you want to run the
gcloud
command line examples in this guide, you need to install the Cloud SDK. - If you want to use the
curl
examples in this guide, make sure you follow the instructions to complete the initial setup in Getting Started.
Enabling services
console
To enable an API for a project:
- Go to the Cloud Console
API Library
page.
go to the API Library page - Click Select to choose the Cloud project.
- Click the API you want to enable. If you need help finding the API, use the search field.
- Click Enable.
gcloud
Run the following command to enable the Pub/Sub API service in your current project:
gcloud services enable pubsub.googleapis.com
The command produces output similar to the following:
Waiting for async operation operations/acf.2e2fcfce-8327-4984-9040-a67777082687 to complete... Operation finished successfully.
You can use the following command to get the operation details:
gcloud services operations describe operations/acf.2e2fcfce-8327-4984-9040-a67777082687
curl
You can enable a single service using the
services.enable
.
You can enable between 2 and 20 services in a single operation using the
services.batchEnable
method.
The following command enables the Pub/Sub API service in project
number 357084163378
:
gcurl -d '{}' https://serviceusage.googleapis.com/v1/projects/357084163378/services/pubsub.googleapis.com:enable
The
services.enable
method returns a
Long Running Operation
resource, which you can use to check the operation's status. You can poll
for the operation status using the Service Usage
operations.get
method.
The following command enables both the Pub/Sub and Dataflow
API services in project number 357084163378
:
gcurl -d '{
"serviceIds": ["pubsub.googleapis.com", "dataflow.googleapis.com"]
}' https://serviceusage.googleapis.com/v1/projects/357084163378/services:batchEnable
The
services.batchEnable
method returns a
Long Running Operation
resource, which you can use to check the operation's status. You can poll
for the operation status using the Service Usage
operations.get
method.
Disabling services
You can disable an API for a project at any time, although any pending fees will still be charged to your account and you'll be charged for any billable API use in your projects. For more information, see APIs and Billing.
console
To disable an API for a project:
- Go to the Cloud Console
API Dashboard
page.
go to the API Dashboard page - Click Select to choose the Cloud project.
- Next to the API you want to disable, click Disable.
gcloud
Run the following command to disable the Pub/Sub API service for your current project:
gcloud services disable pubsub.googleapis.com
The command produces output similar to the following:
Waiting for async operation operations/acf.e9d0943b-55d9-4ac0-8af4-745e1b8983f8 to complete... Operation finished successfully.
You can use the following command to get the operation details:
gcloud services operations describe operations/acf.e9d0943b-55d9-4ac0-8af4-745e1b8983f8
curl
The following command disables the Pub/Sub API service in
project number 357084163378
:
gcurl -d '{}' https://serviceusage.googleapis.com/v1/projects/357084163378/services/pubsub.googleapis.com:disable
The services.disable
method returns a
Long Running Operation
resource, which you can use to check the operation's status. You can poll
for the operation status using the Service Usage
operations.get
method.
Next steps
To learn how to view and manage the quota metrics and limits that apply to your project, see Managing Service Quota.