Enable and disable services

You can use Service Usage to enable or disable any available service for your Google Cloud projects. This includes public Google Cloud services and private services created with Cloud Endpoints. To learn more about the differences between public and private services, see Public and private services.

Most users can enable and disable services with the Google Cloud console. For scripts, use the Google Cloud CLI. To access the Service Usage API programmatically, we recommend using a client library. To try the API, you can send a request without setting up a full development environment.

For Service Usage quota limits, see Quotas and limits. You might want to limit the billable usage. Depending on the API, you can explicitly cap requests.

Before you begin

Before enabling and disabling services, you must set up your Google Cloud project and environment for Service Usage.

Console

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Service Usage API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Service Usage API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

gcloud

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. Install the Google Cloud CLI.

  3. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  4. To initialize the gcloud CLI, run the following command:

    gcloud init
  5. Create or select a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  6. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  7. Verify that billing is enabled for your Google Cloud project.

  8. Enable the Service Usage API:

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    gcloud services enable serviceusage.googleapis.com
  9. Install the Google Cloud CLI.

  10. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  11. To initialize the gcloud CLI, run the following command:

    gcloud init
  12. Create or select a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  13. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  14. Verify that billing is enabled for your Google Cloud project.

  15. Enable the Service Usage API:

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    gcloud services enable serviceusage.googleapis.com

Required roles

To get the permissions that you need to enable and disable services, ask your administrator to grant you the Service Usage Admin (roles/serviceusage.serviceUsageAdmin) IAM role on your project. For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Enable a service

The process to enable a service can vary. Some APIs ask you to first accept their Terms of Service, or are in preview and require approval before you can use them. Other APIs might ask for additional information, such as your organization's contact details and the name of your application. Any requested information stays confidential within Google. We use it to understand API usage and to contact you if necessary.

Console

  1. In the Google Cloud console, go to the APIs & Services > API Library page.

    Go to API Library

  2. Select a recent project or use the resource selector on the console toolbar to select the Google Cloud project where you want to enable an API.

  3. Click the API you want to enable or search for it using the Search for APIs & Services box.

  4. Click Enable.

gcloud

The gcloud services enable command enables a service with the name specified for the current project.

Before using any of the command data below, make the following replacements:

  • SERVICE: the name of the service you want to enable.

Execute the gcloud services enable command:

Linux, macOS, or Cloud Shell

gcloud services enable SERVICE

Windows (PowerShell)

gcloud services enable SERVICE

Windows (cmd.exe)

gcloud services enable SERVICE

You should receive a response similar to the following:


Waiting for async operation operations/OPERATION_ID to complete...
Operation finished successfully.

To enable multiple services, use space-delimited service names—for example, the following command enables both the BigQuery and Pub/Sub services:

gcloud services enable bigquery.googleapis.com pubsub.googleapis.com

To retrieve the operation details, use the gcloud services operations describe command:

gcloud services operations describe operations/OPERATION_ID

Replace OPERATION_ID with the operation ID you received in response to your original request.

REST API

Enable a single service

To enable a single service use the services.enable method.

Before using any of the request data, make the following replacements:

  • PROJECT_ID: your Google Cloud project ID.
  • SERVICE: the name of the service that you want to enable.

To send your request, expand one of these options:

If successful, the response body contains a newly created instance of Operation:

{
  "name": "operations/OPERATION_ID"
}

Enable multiple services

To enable up to 20 services in a single operation use the services.batchEnable method.

Before using any of the request data, make the following replacements:

  • PROJECT_ID: your Google Cloud project ID.
  • SERVICE1: the name of a service that you want to enable.
  • SERVICE2: the name of another service that you want to enable.

Request JSON body:

{
  "serviceIds": ["SERVICE1", "SERVICE2"]
}

To send your request, expand one of these options:

If successful, the response body contains a newly created instance of Operation:

{
  "name": "operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.api.serviceusage.v1.OperationMetadata"
  }
}

Disable a service

You can disable an API for a project anytime. However, you'll still be charged for any pending fees and billable API use in your projects. For more information, see the Getting started guide for Cloud APIs.

Many services, such as Cloud Storage and BigQuery, charge for data storage. Disabling a service's API doesn't delete your data, and you'll continue to be billed for it. To stop future charges and discontinue using a service, delete all associated data before disabling its API.

If you disable the Google Kubernetes Engine API, running clusters in the project become suspended. After 30 days, these suspended clusters are deleted. To reactivate your clusters, re-enable the GKE API. It can take up to 24 hours for clusters to be reinstated. For more information, see Cluster lifecycle.

Console

  1. In the Google Cloud console, go to the APIs & Services > API Library page.

    Go to API Library

  2. Select a recent project or use the resource selector on the console toolbar to select the Google Cloud project where you want to disable an API.

  3. Click the API you want to disable or search for it using the Search for APIs & Services box.

  4. Click Disable API.

gcloud

The gcloud services disable command disables a service with the name specified for the current project.

Before using any of the command data below, make the following replacements:

  • SERVICE: the name of the service you want to disable.

Execute the gcloud services disable command:

Linux, macOS, or Cloud Shell

gcloud services disable SERVICE

Windows (PowerShell)

gcloud services disable SERVICE

Windows (cmd.exe)

gcloud services disable SERVICE

You should receive a response similar to the following:


Waiting for async operation operations/OPERATION_ID to complete...
Operation finished successfully.

To disable multiple services, use space-delimited service names—for example, the following command disables both the BigQuery and Pub/Sub services:

gcloud services disable bigquery.googleapis.com pubsub.googleapis.com

To retrieve the operation details, use the gcloud services operations describe command:

gcloud services operations describe operations/OPERATION_ID

Replace OPERATION_ID with the operation ID you received in response to your original request.

REST API

To disable a service use the services.disable method.

Before using any of the request data, make the following replacements:

  • PROJECT_ID: your Google Cloud project ID.
  • SERVICE: the name of the service that you want to disable.

To send your request, expand one of these options:

If successful, the response body contains a newly created instance of Operation:

{
  "name": "operations/OPERATION_ID"
}

Check the status of a long-running operation

Using the enable or disable method returns a long-running operation (LRO). The LRO tracks the status of the request and indicates whether the change to the service is complete.

Before using any of the request data, make the following replacements:

OPERATION_ID: the operation identifier. You receive this ID in the response to your original request.

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.api.serviceusage.v1.EnableServiceResponse",
    "service": {
      "name": "projects/PROJECT_NUMBER/services/SERVICE",
      "config": {
        "name": "SERVICE",
        "title": "TITLE",
        "documentation": {},
        "quota": {},
        "authentication": {},
        "usage": {
          "requirements": [
            "serviceusage.googleapis.com/tos/cloud"
          ]
        },
        "monitoring": {}
      },
      "state": "ENABLED",
      "parent": "projects/PROJECT_NUMBER"
    }
  }
}

When the done field is set to true, the operation is complete.