Secret Manager exposes a REST API and a gRPC API for using and managing secrets
directly or in your applications. This page describes how to enable the
Secret Manager API and configure your Google Cloud project to use
Secret Manager for the first time.

This step is a prerequisite for all tasks in Secret Manager, including the
[quickstart](https://docs.cloud.google.com/secret-manager/docs/quickstart).

When you are becoming familiar with Secret Manager, we recommend using a
separate Google Cloud project. Deleting the project also deletes all
resources created during testing, including billable resources.

If you are developing an application in an IDE with [Cloud Code](https://cloud.google.com/code) installed,
Secret Manager comes integrated into the extension. This means that you
can create, view, update, and use secrets without having to leave your IDE. For
more on using Secret Manager with Cloud Code, refer to the secret
managing guide for your preferred IDE,
[VS Code](https://docs.cloud.google.com/code/docs/vscode/secret-manager.md.txt),
[IntelliJ](https://docs.cloud.google.com/code/docs/intellij/secret-manager.md.txt),
or [Cloud Shell Editor](https://docs.cloud.google.com/code/docs/shell/secret-manager.md.txt).

## Before you begin

1. In the Google Cloud console, go to the project selector page.

   [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)
2. 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](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access).

   > [!NOTE]
   > **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

## Enable the Secret Manager API

### Console

1. In the Google Cloud console, go to the **Secret Manager API** page.

   [Go to Secret Manager API](https://console.cloud.google.com/apis/library/secretmanager.googleapis.com)
2. Verify that the name of your project appears in the project selector at the top of the page.

   If you don't see the name of your project, click the project selector, and then select your project.
3. Click **Enable**.

### gcloud

1. In the Google Cloud console, activate Cloud Shell.

   [Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)


   At the bottom of the Google Cloud console, a
   [Cloud Shell](https://docs.cloud.google.com/shell/docs/how-cloud-shell-works.md.txt)
   session starts and displays a command-line prompt. Cloud Shell is a shell environment
   with the Google Cloud CLI
   already installed and with values already set for
   your current project. It can take a few seconds for the session to initialize.
2. To set your Google Cloud project in the gcloud session, run the [`gcloud config set project`](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt) command. Replace <var translate="no">PROJECT_ID</var> with your Google Cloud project ID.

   ```
   gcloud config set project PROJECT_ID
   ```
3. To enable the Secret Manager API, run the [`gcloud services enable`](https://docs.cloud.google.com/sdk/gcloud/reference/services/enable) command:

   ```
   gcloud services enable secretmanager.googleapis.com
   ```
4. To verify that the Secret Manager API is enabled, run the [`gcloud services list`](https://docs.cloud.google.com/sdk/gcloud/reference/services/list) command:

   ```
   gcloud services list --enabled
   ```

   Verify that the Secret Manager API is listed in the list of enabled APIs.

## Configure roles and permissions


To get the permissions that
you need to set up Secret Manager,

ask your administrator to grant you the
[Secret Manager Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/secretmanager.md.txt#secretmanager.admin) (`roles/secretmanager.admin`) IAM role on the 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.md.txt).


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).

For more information about the access control for Secret Manager, see
[Access control with IAM](https://docs.cloud.google.com/secret-manager/docs/access-control.md.txt).

## What's next

- Learn more about [authentication and access](https://docs.cloud.google.com/secret-manager/docs/authentication.md.txt) to the Secret Manager API.
- Learn more about [creating secrets](https://docs.cloud.google.com/secret-manager/docs/creating-and-accessing-secrets.md.txt).
- Learn more about [adding a secret version](https://docs.cloud.google.com/secret-manager/docs/add-secret-version.md.txt).