> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pinecone.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Rotate API keys and service account secrets

> Rotate or revoke Pinecone API keys and service account client secrets without downtime, and list every API key in your organization with the Admin API.

Rotating a credential replaces it with a new one while your applications keep running. Revoking a credential cuts off access, including for any application still using it. Rotate on a regular schedule and when someone with access leaves your team. Revoke right away if you think a key or secret has leaked.

## Rotate an API key

API keys can't be changed in place. To rotate one, create a replacement with the same permissions, switch your applications to it, and then delete the old key. Deleting last means your applications never lose access.

Repeat these steps in each project that has keys to rotate. To find them all at once, [list every API key in your organization](#list-every-api-key-in-your-organization).

> [tab] Pinecone console
>
> 1. Open the [Pinecone console](https://app.pinecone.io/organizations/-/projects) and select your project.
>
> 2. Go to **API keys**.
>
> 3. Note the permissions of the key you're replacing. To see them, in the key's row, click **ellipsis (...) menu > Settings**.
>
> 4. Click **+ API key**, enter an **API key name**, and select the same **Permissions** as the key you're replacing.
>
> 5. Click **Create key**.
>
> 6. Copy the new key and store it in a secure place.
>
>    > [!WARNING]
>    >
>    > You cannot view the API key again after you close the dialog.
>
> 7. Replace the old key with the new one everywhere it's used, such as environment variables, secret managers, CI pipelines, and deployed applications. Then confirm your applications work with the new key.
>
> 8. In the old key's row, click **ellipsis (...) menu > Delete**.
>
> 9. Enter the **API key name** and click **Delete API key**.

> [tab] Code
>
> > [!NOTE]
> >
> > To complete this action through the Admin API, you need an [access token](https://docs.pinecone.io/admin/organizations/manage-service-accounts.md#retrieve-an-access-token).
>
> 1. [List the project's API keys](https://docs.pinecone.io/reference/api/latest/admin/list_api_keys.md) and note the `id` and `roles` of the key you're replacing:
>
>    ```bash curl theme={null}
>    PINECONE_PROJECT_ID="YOUR_PROJECT_ID"
>    PINECONE_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
>
>    curl "https://api.pinecone.io/admin/projects/$PINECONE_PROJECT_ID/api-keys" \
>         -H "X-Pinecone-Api-Version: 2026-07" \
>         -H "Authorization: Bearer $PINECONE_ACCESS_TOKEN"
>    ```
>
> 2. [Create the replacement key](https://docs.pinecone.io/reference/api/latest/admin/create_api_key.md) with the same `roles`:
>
>    ```bash curl theme={null}
>    PINECONE_PROJECT_ID="YOUR_PROJECT_ID"
>    PINECONE_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
>
>    curl -X POST "https://api.pinecone.io/admin/projects/$PINECONE_PROJECT_ID/api-keys" \
>         -H "X-Pinecone-Api-Version: 2026-07" \
>         -H "Authorization: Bearer $PINECONE_ACCESS_TOKEN" \
>         -d '{
>               "name": "example-api-key-2",
>               "roles": ["ProjectEditor"]
>             }'
>    ```
>
>    The response's `value` field holds the new key. It's returned only once, so store it in a secure place.
>
> 3. Replace the old key with the new one everywhere it's used, and confirm your applications work with the new key.
>
> 4. [Delete the old key](https://docs.pinecone.io/reference/api/latest/admin/delete_api_key.md):
>
>    ```bash curl theme={null}
>    PINECONE_API_KEY_ID="OLD_API_KEY_ID"
>    PINECONE_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
>
>    curl -X DELETE "https://api.pinecone.io/admin/api-keys/$PINECONE_API_KEY_ID" \
>         -H "X-Pinecone-Api-Version: 2026-07" \
>         -H "Authorization: Bearer $PINECONE_ACCESS_TOKEN"
>    ```

## List every API key in your organization

In an organization with many projects, use the Admin API to find every key instead of checking each project in the console. This script lists the organization's projects, then prints each key's project, name, ID, roles, and creation time. It requires [`jq`](https://jqlang.org/).

> [!NOTE]
>
> To complete this action through the Admin API, you need an [access token](https://docs.pinecone.io/admin/organizations/manage-service-accounts.md#retrieve-an-access-token).

Use an access token for a service account with the `OrgOwner` role, so the token can read the keys in every project.

```bash curl theme={null}
PINECONE_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"

curl -s "https://api.pinecone.io/admin/projects" \
     -H "X-Pinecone-Api-Version: 2026-07" \
     -H "Authorization: Bearer $PINECONE_ACCESS_TOKEN" |
  jq -r '.data[] | [.id, .name] | @tsv' |
  while IFS=$'\t' read -r project_id project_name; do
    curl -s "https://api.pinecone.io/admin/projects/$project_id/api-keys" \
         -H "X-Pinecone-Api-Version: 2026-07" \
         -H "Authorization: Bearer $PINECONE_ACCESS_TOKEN" |
      jq -r --arg project "$project_name" \
        '.data[] | [$project, .name, .id, (.roles | join(",")), .created_at] | @tsv'
  done
```

The output has one tab-separated line per key. To find keys created before a given date, sort or filter on the last column.

```text Output theme={null}
example-project	example-api-key	62b0dbfe-3489-4b79-b850-34d911527c88	ProjectEditor	2025-10-20T23:39:43.665754Z
example-project	example-api-key-2	0d0d3678-81b4-4e0d-a4f0-70ba488acfb7	ProjectEditor	2025-10-20T23:43:13.176422Z
```

## Revoke an API key

To cut off an API key, [delete it](https://docs.pinecone.io/admin/projects/manage-api-keys.md#delete-an-api-key). Any application using the key starts getting `401 Unauthorized` errors within seconds. If you can, [create a replacement key](https://docs.pinecone.io/admin/projects/manage-api-keys.md#create-an-api-key) first.

> [!NOTE]
>
> The console doesn't let you delete a project's last API key. Create the replacement key first, then delete the old one.

## Rotate a service account secret

> [!NOTE]
>
> Service accounts are available on the [Enterprise plan](https://www.pinecone.io/pricing/). Only [organization owners](https://docs.pinecone.io/admin/organizations/organizations-overview.md#organization-roles) can rotate a service account's secret.

Rotating a service account's secret issues a new client secret, and the old secret stops working right away. The client ID doesn't change. Access tokens already issued with the old secret keep working until they expire, as shown in the token response's `expires_in` field.

Applications can't request new access tokens until you give them the new secret, so have every place the secret is used ready to update before you start.

> [tab] Pinecone console
>
> 1. Go to [**Settings > Access > Service accounts**](https://app.pinecone.io/organizations/-/settings/access/service-accounts).
>
> 2. In the service account's row, click **ellipsis (...) menu > Rotate secret**.
>
> 3. **Enter the service account name** to confirm, and click **Rotate secret**.
>
> 4. Copy the new **Client secret** and store it in a secure place.
>
>    > [!WARNING]
>    >
>    > You cannot view the client secret again after you close the dialog.
>
> 5. Click **Copy and Continue**.
>
> 6. Replace the old secret with the new one everywhere the service account is used. Keep the same client ID.

> [tab] Code
>
> > [!NOTE]
> >
> > To complete this action through the Admin API, you need an [access token](https://docs.pinecone.io/admin/organizations/manage-service-accounts.md#retrieve-an-access-token).
>
> 1. [List your organization's service accounts](https://docs.pinecone.io/reference/api/latest/admin/list_service_accounts.md) and note the `id` of the account to rotate:
>
>    ```bash curl theme={null}
>    PINECONE_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
>
>    curl "https://api.pinecone.io/admin/service-accounts" \
>         -H "X-Pinecone-Api-Version: 2026-07" \
>         -H "Authorization: Bearer $PINECONE_ACCESS_TOKEN"
>    ```
>
> 2. [Rotate the secret](https://docs.pinecone.io/reference/api/latest/admin/rotate_service_account_secret.md):
>
>    ```bash curl theme={null}
>    PINECONE_SERVICE_ACCOUNT_ID="YOUR_SERVICE_ACCOUNT_ID"
>    PINECONE_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
>
>    curl -X POST "https://api.pinecone.io/admin/service-accounts/$PINECONE_SERVICE_ACCOUNT_ID/rotate-secret" \
>         -H "X-Pinecone-Api-Version: 2026-07" \
>         -H "Authorization: Bearer $PINECONE_ACCESS_TOKEN"
>    ```
>
>    ```hcl Terraform theme={null}
>    # Change rotate_trigger to any new value to issue and store a new secret
>    resource "pinecone_service_account" "ci_prod" {
>      name           = "ci-prod"
>      rotate_trigger = "2026-11-24"
>    }
>    ```
>
>    The response's `client_secret` field holds the new secret. It's returned only once, so store it in a secure place. If you rotate the same account again, the secret from the earlier rotation stops working.
>
> 3. Replace the old secret with the new one everywhere the service account is used.

For how `rotate_trigger` works and how Terraform stores the secret, see [Service accounts](https://docs.pinecone.io/integrations/terraform.md#service-accounts) in the Terraform guide.

## Revoke a service account

To cut off a service account, choose one of these options:

* **Rotate and discard**: [Rotate its secret](#rotate-a-service-account-secret) and don't store the new one. No one can request new access tokens, but tokens already issued keep working until they expire. The account and its role assignments stay in place, so you can restore access later by rotating again.
* **Delete**: [Delete the service account](https://docs.pinecone.io/admin/organizations/manage-service-accounts.md#delete-a-service-account). Its access tokens stop working right away, and it's removed from every project. You can't undo it.

## If a key or secret stops working

A request that returns `401 Unauthorized` usually means the API key was deleted or the service account's secret was rotated. Requests with that credential won't work again, so get a new one:

* **API key**: [Create a new API key](https://docs.pinecone.io/admin/projects/manage-api-keys.md#create-an-api-key) in the project, or ask a project owner to create one.
* **Service account**: Ask an organization owner to [rotate the secret](#rotate-a-service-account-secret) and send you the new one.
