# Enable and disable services

You can use Service Usage to enable or disable any available service
for your Google Cloud projects. This includes private
services created with [Cloud Endpoints](https://docs.cloud.google.com/endpoints/docs). To learn more
about the differences between public and private services, see
[Public and private services](https://docs.cloud.google.com/service-usage/docs/public-vs-private).

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](https://docs.cloud.google.com/service-usage/docs/libraries). 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](https://docs.cloud.google.com/service-usage/docs/quotas). You might want to limit the
billable usage. Depending on the API, you can explicitly
[cap requests](https://docs.cloud.google.com/apis/docs/capping-api-usage).

## Before you begin

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

### Console


<br />

### gcloud


<br />

### REST API

1. Have a Google Cloud project for which you want to enable or disable
   APIs.

2. Verify that you have the
   [permissions required to complete this guide](https://docs.cloud.google.com/service-usage/docs/enable-disable#required-roles).
   If you're using a project you created, then you typically already have
   the required permissions.

### Required roles


To get the permissions that
you need to enable and disable services,

ask your administrator to grant you the
[Service Usage Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/serviceusage#serviceusage.serviceUsageAdmin) (`roles/serviceusage.serviceUsageAdmin`) IAM role on your project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access).


You might also be able to get
the required permissions through [custom
roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).

## 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](https://console.cloud.google.com/apis/library)

   <br />

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

`https://docs.cloud.google.com/sdk/gcloud/reference/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`](https://docs.cloud.google.com/sdk/gcloud/reference/services/enable)


command:

#### Linux, macOS, or Cloud Shell

```bash
gcloud services enable SERVICE
```

#### Windows (PowerShell)

```bash
gcloud services enable SERVICE
```

#### Windows (cmd.exe)

```bash
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`](https://docs.cloud.google.com/sdk/gcloud/reference/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.

<br />

### REST API

### Enable a single service

To enable a single service use the
[`services.enable`](https://docs.cloud.google.com/service-usage/docs/reference/rest/v1/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:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Execute the following command:

```
curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d "" \
     "https://serviceusage.googleapis.com/v1/projects/PROJECT_ID/services/SERVICE:enable"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -Uri "https://serviceusage.googleapis.com/v1/projects/PROJECT_ID/services/SERVICE:enable" | Select-Object -Expand Content
```


If successful, the response body contains a newly created instance of
[`Operation`](https://docs.cloud.google.com/service-usage/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation):

```
{
  "name": "operations/OPERATION_ID"
}
```

<br />

> [!NOTE]
> **Note:** [By default](https://docs.cloud.google.com/service-usage/docs/enabled-service), the Service Usage API is enabled for projects, but if you disabled it for the project that's performing the request to enable a service, you receive an error when you attempt the request. To fix this, use the Google Cloud console or Google Cloud CLI to re-enable the Service Usage API for the project that's performing the request.

### Enable multiple services

To enable up to 20 services in a single operation use the
[`services.batchEnable`](https://docs.cloud.google.com/service-usage/docs/reference/rest/v1/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:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Save the request body in a file named `request.json`.
Run the following command in the terminal to create or overwrite
this file in the current directory:

```
cat > request.json << 'EOF'
{
  "serviceIds": ["SERVICE1", "SERVICE2"]
}
EOF
```


Then execute the following command to send your REST request:

```
curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d @request.json \
     "https://serviceusage.googleapis.com/v1/projects/PROJECT_ID/services:batchEnable"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Save the request body in a file named `request.json`.
Run the following command in the terminal to create or overwrite
this file in the current directory:

```
@'
{
  "serviceIds": ["SERVICE1", "SERVICE2"]
}
'@  | Out-File -FilePath request.json -Encoding utf8
```


Then execute the following command to send your REST request:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://serviceusage.googleapis.com/v1/projects/PROJECT_ID/services:batchEnable" | Select-Object -Expand Content
```


If successful, the response body contains a newly created instance of
[`Operation`](https://docs.cloud.google.com/service-usage/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation):

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

<br />

> [!NOTE]
> **Note:** [By default](https://docs.cloud.google.com/service-usage/docs/enabled-service), the Service Usage API is enabled for projects, but if you disabled it for the project that's performing the request to enable services, you receive an error when you attempt the request. To fix this, use the Google Cloud console or Google Cloud CLI to re-enable the Service Usage API for the project that's performing the request.

## 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](https://support.google.com/cloud/answer/6158867) guide
for Cloud APIs.

Many services, such as Cloud Storage and BigQuery, charge for data
storage, and disabling the API for these service's doesn't delete your data. For
these services, you'll continue to be billed for data storage even after the
API is disabled. In contrast, when you disable the Cloud Run API, the
resources associated with Cloud Run are deleted, which you might
not intend to do.

In both cases, and as a general best practice, you should take inventory of
resources associated with your service prior to disabling the service. For
services such as Cloud Storage and BigQuery, to stop
future charges and discontinue using the service, delete all associated data
before disabling its API. For Cloud Run, don't disable the API
until you've confirmed that any Cloud Run resources that exist
are safe to delete.

If you disable the 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](https://docs.cloud.google.com/kubernetes-engine/docs/get-started/cluster-lifecycle).

> [!NOTE]
> **Note:** If you try to disable a service that other enabled services depend on, the request will fail and return an error. To disable the specified service and all services that depend on it, set the `disableDependentServices` parameter in the [`services.disable`](https://docs.cloud.google.com/service-usage/docs/reference/rest/v1/services/disable) request to `true`.

### Console

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


   [Go to API Library](https://console.cloud.google.com/apis/library)

   <br />

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

`https://docs.cloud.google.com/sdk/gcloud/reference/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`](https://docs.cloud.google.com/sdk/gcloud/reference/services/disable)


command:

#### Linux, macOS, or Cloud Shell

```bash
gcloud services disable SERVICE
```

#### Windows (PowerShell)

```bash
gcloud services disable SERVICE
```

#### Windows (cmd.exe)

```bash
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`](https://docs.cloud.google.com/sdk/gcloud/reference/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.

<br />

### REST API

To disable a service use the
[`services.disable`](https://docs.cloud.google.com/service-usage/docs/reference/rest/v1/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:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Execute the following command:

```
curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d "" \
     "https://serviceusage.googleapis.com/v1/projects/PROJECT_ID/services/SERVICE:disable"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -Uri "https://serviceusage.googleapis.com/v1/projects/PROJECT_ID/services/SERVICE:disable" | Select-Object -Expand Content
```


If successful, the response body contains a newly created instance of
[`Operation`](https://docs.cloud.google.com/service-usage/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation):

```
{
  "name": "operations/OPERATION_ID"
}
```

<br />

> [!NOTE]
> **Note:** [By default](https://docs.cloud.google.com/service-usage/docs/enabled-service), the Service Usage API is enabled for projects, but if you disabled it for the project that's performing the request to disable a service, you receive an error when you attempt the request. To fix this, use the Google Cloud console or Google Cloud CLI to re-enable the Service Usage API for the project that's performing the request.

## Check the status of a long-running operation

Using the enable or disable method returns a long-running
[operation](https://docs.cloud.google.com/service-usage/docs/reference/rest/v1/operations) (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:

#### curl (Linux, macOS, or Cloud Shell)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Execute the following command:

```
curl -X GET \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     "https://serviceusage.googleapis.com/v1/operations/OPERATION_ID"
```

#### PowerShell (Windows)

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list).


Execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method GET `
    -Headers $headers `
    -Uri "https://serviceusage.googleapis.com/v1/operations/OPERATION_ID" | Select-Object -Expand Content
```

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.