The page describes the steps that need to be completed before you
can start to use the Service Consumer Management API. It assumes that you already have a
Google Cloud project and a [managed service](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#managed)
(such as a managed service created using [Cloud Endpoints](https://docs.cloud.google.com/endpoints/docs.md.txt)) in
that project, and that you understand
[Tenancy Units](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#tenancy).

## Activating the service

While the Service Consumer Management API helps you to manage the usage of your own
[managed services](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#managed), it is also a service
itself. Therefore, before you can use it, you must activate the
Service Consumer Management API for the Google Cloud project that hosts your managed
service. This project is known as a [service producer](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#producer)
project.

The simplest way to enable the Service Consumer Management API for your service
producer project is to use the
[Google Cloud console](https://console.cloud.google.com/apis/api/serviceconsumermanagement.googleapis.com).
Alternatively, you can enable it from the command line or programmatically. You
can find out more in
[Enabling and Disabling Services](https://docs.cloud.google.com/service-usage/docs/enable-disable.md.txt).

## Setting permissions

After the Service Consumer Management API is enabled for your service producer
project, you must create your own service identity and grant it permissions on
your resources so that it can create [tenant projects](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#tenant) in
your folders and set up the correct billing account on tenant projects. These
actions are executed by a service account owned by the Service Consumer Management
API, which is specified in the following format:

```
service-PROJECT_NUMBER@service-consumer-management.iam.gserviceaccount.com
```

where *PROJECT_NUMBER* is the project number for your service producer project
that activated the Service Consumer Management service.

The remainder of this guide uses *GCM_SA* to represent the
Service Consumer Management API service account.

You can use the following commands to generate the service identity.

1. Login with your user account.

```
gcloud auth login
```

1. Generate the service identity.

```
gcloud beta services identity create --service=serviceconsumermanagement.googleapis.com --project=PROJECT_ID
```

### Setting folder permissions

1. Ensure that you have a folder for holding your tenant projects: you'll need
   to have an [Organization](https://docs.cloud.google.com/resource-manager/docs/creating-managing-organization.md.txt)
   to create folders within your service producer project. If you don't have a
   folder, follow the instructions in
   [Creating and Managing Folders](https://docs.cloud.google.com/resource-manager/docs/creating-managing-folders.md.txt#create-folder)
   to create one. Your folder will have an integer based *FOLDER_ID*.

2. On your folder, assign the **Project Creator/Deleter** role to the
   Service Consumer Management API service account. Follow the instructions in
   [Configuring Access to Folders](https://docs.cloud.google.com/resource-manager/docs/creating-managing-folders.md.txt#configuring_access_to_folders)
   to add the **Project Creator** and **Project Deleter** role, using *GCM_SA* as
   the user.

### Setting billing account permissions

1. Ensure that you have a billing account that can be shared for tenant
   projects. If you don't have a billing account, see
   [Create, Modify, or Close a Billing Account](https://docs.cloud.google.com/billing/docs/how-to/manage-billing-account.md.txt)
   for instructions to create one.

2. Follow the
   [instructions](https://docs.cloud.google.com/billing/docs/how-to/billing-access.md.txt)
   to add the **Billing Account User** role to *GCM_SA*.

## Resource requirements

- The Service Consumer Management API creates [tenant projects](https://docs.cloud.google.com/service-infrastructure/docs/glossary.md.txt#tenant) on your behalf, so ensure you have enough quota to create them.
- See the [project limits](https://cloud.google.com/resource-manager/docs/limits#project-limits) documentation to know how many projects can be created by default and to request increases to that limit.