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

# Rotate Credentials and API Keys

> Step-by-step guide to rotating every credential stored in or issued by the AI Gateway: API keys, provider credentials, MCP credentials, and self-hosted gateway secrets.

This guide lists every credential that the AI Gateway stores or issues for an organisation, and how to rotate each one. Work through the sections in order.

> [!WARNING]
>
> The AI Gateway does not support grace periods when you replace credentials stored in integrations, providers, MCP servers, or other settings. Saving a new value does not take effect on every gateway at once. Hybrid and self-hosted gateways clear cached keys, integrations, and configs on a sync that runs about once a minute, and values read from a vault are cached for up to 5 minutes. For each credential: create the new value at the source, update the AI Gateway, wait for the change to propagate, confirm requests succeed with the new value on every gateway, then revoke the old value at the source.

## Credentials at a glance

| # | Credential | Where it lives | Rotate at |
| - | - | - | - |
| 1 | [AI Gateway API keys](#1-ai-gateway-api-keys) (admin, workspace service, workspace user) and [Admin API service accounts](#admin-api-service-accounts) | AI Gateway, Strata Cloud Manager | AI Gateway, Strata Cloud Manager |
| 2 | [AI provider credentials](#2-ai-provider-credentials) (integrations and providers) | AI Gateway | Your AI provider, then the AI Gateway |
| 3 | [MCP credentials](#3-mcp-credentials) | AI Gateway | The MCP server or IdP, then the AI Gateway |
| 4 | [Secret references](#4-secret-references-and-vault-credentials) | Your vault | Your vault |
| 5 | [JWT, sessions, and users](#5-jwt-sessions-and-users) | AI Gateway | Your IdP, then the AI Gateway |
| 6 | [Plugin integration credentials](#6-plugin-integration-credentials) | AI Gateway | The plugin provider, then the AI Gateway |
| 7 | [Credentials embedded in configs and guardrails](#7-credentials-embedded-in-configs-and-guardrails) | AI Gateway | The upstream service, then the AI Gateway |
| 8 | [Observability and log export credentials](#8-observability-and-log-export-credentials) | AI Gateway or your gateway | Your destination, then the AI Gateway |
| 9 | [Self-hosted gateway secrets](#9-self-hosted-gateway-secrets) | Your deployment | Your deployment |

## Before you start

* **Use a rotation account you trust.** Sign in to the AI Gateway management console with SSO or your own credentials. Don't depend on an existing API key to run the rotation.
* **Plan for downtime.** Replacing a credential breaks any application still using the old value. Roll out new values to your applications before revoking the old ones.
* **Keep a list.** Record each credential you rotate, so you can confirm none was missed. Use the [checklist](#rotation-checklist) at the end of this page.
* **Know your permissions.** Rotating organisation-level resources requires an organisation owner or admin. Workspace-level resources require a workspace admin or manager.

## 1. AI Gateway API keys

The AI Gateway issues three kinds of API keys. They authenticate requests to the inference API and are **not** accepted on the Admin API. See [API Keys (AuthN and AuthZ)](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/api-keys-authn-and-authz.md) for how they differ.

* **Admin API keys:** organisation-level keys that work across workspaces
* **Workspace service API keys:** workspace-level keys for backends and automation
* **Workspace user API keys:** workspace-level keys owned by individual users

Admin API requests use a different credential: a Strata Cloud Manager service account. Rotate those too. See [Admin API service accounts](#admin-api-service-accounts).

### Choose a rotation method

| Method | Key ID | Old secret | Use when |
| - | - | - | - |
| **Create a new key, then delete the old key** | Changes | Revoked when you delete the key. Gateways can keep accepting it until their cache refreshes (about a minute). | The old key must stop working as soon as possible |
| **[Rotate the key](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/api-key-rotation.md)** | Unchanged | Stays valid for the transition period (minimum 30 minutes) | Usage history, budgets, and attribution must stay attached to the same key |

> [!NOTE]
>
> The rotate endpoint always keeps the previous secret valid for the transition period, with a minimum of 30 minutes. To end access as soon as possible, create a new key and delete the old one. Gateways cache API keys and clear changed ones on a sync that runs about once a minute, so confirm the old key returns `401` on every gateway, including self-hosted ones, before treating it as revoked.

### Rotate with the console

**1. Open Security Keys**

In SCM, navigate to **AI Security > AI Gateway > Security Keys**.

**2. Create a replacement key**

Click **Create New**. Select the same type, workspace, scopes, and rate or budget limits as the key it replaces. Also copy its default config and its **Config Override** setting. Without them the new key loses the routing and guardrails attached to the old one, or lets requests override the config.

**3. Deploy the new key**

Update your applications, CI pipelines, secret stores, and `Authorization: Bearer` headers with the new key.

**4. Delete the old key**

After traffic moves to the new key, delete the old key from the list.

### Rotate with the API

These endpoints are on the Admin API and require a Strata Cloud Manager access token, not an AI Gateway API key. See [Admin API authentication](https://docs.portkey.ai/docs/aigw/api-reference/admin-api/authentication.md).

1. [Create an API key](https://docs.portkey.ai/docs/aigw/api-reference/api-keys/post-api-keys-by-sub-type.md) with [`POST /v2/api-keys/{sub-type}`](https://docs.gw.prismaairs.com/docs/aigw/api-reference/api-keys/post-api-keys-by-sub-type). Set the same default config and config-override setting as the old key.
2. Deploy the new key.
3. Delete the old key with [`DELETE /v2/api-keys/{id}`](https://docs.gw.prismaairs.com/docs/aigw/api-reference/api-keys/delete-api-keys-by-id).

To keep the same key ID instead, call [`POST /v2/api-keys/{id}/rotate`](https://docs.portkey.ai/docs/aigw/api-reference/api-keys/post-api-keys-by-id-rotate). The response contains the new secret and the time the previous secret expires.

### Order of rotation

1. Rotate **admin API keys** first. They have the broadest scope on the inference path.
2. Rotate **workspace service API keys** next. They can manage other workspace keys.
3. Rotate **workspace user API keys** last. Ask each user to replace theirs, or rotate them as an admin.

List existing keys with `GET /v2/api-keys` to find every key to replace. Delete any key you don't recognise or no longer use.

### Admin API service accounts

Admin API calls are authorised with a short-lived token issued to a service account in Strata Cloud Manager, using the service account's Client ID and Client Secret. Rotate these as well:

1. In Strata Cloud Manager, go to **System Settings > Identity & Access** and issue a new credential for each service account used with the Admin API. If you can't issue a new credential, create a replacement service account in the same tenant with the same role assignments.
2. Update every job, pipeline, and secret store that holds the old Client Secret.
3. Delete the old service account or credential.

Access tokens expire after 15 minutes, so tokens issued with the old credential stop working within that time. See [Admin API authentication](https://docs.portkey.ai/docs/aigw/api-reference/admin-api/authentication.md).

## 2. AI provider credentials

Integrations and providers hold credentials for your AI providers: API keys, cloud access keys, service account JSON, and similar. Rotating the key only in the AI Gateway does not invalidate the old one. **Rotate the credential at the provider.**

For each integration:

**1. Create a new credential at the provider**

Generate a new API key, access key, or service account key in your provider's console.

**2. Update the credential in the AI Gateway**

In SCM, navigate to **AI Security > AI Gateway > Integrations**, select the integration, and replace the stored credential. To use the API, call [`PUT /integrations/{slug}`](https://docs.gw.prismaairs.com/docs/aigw/api-reference/integrations/put-integrations-by-slug) or [`PUT /providers/{slug}`](https://docs.gw.prismaairs.com/docs/aigw/api-reference/providers/put-providers-by-slug).

**3. Test a request**

Send a test request through a model on the integration to confirm the new credential works.

**4. Revoke the old credential at the provider**

Delete or disable the old key in your provider's console.

### Credentials by provider

| Provider | Credential to rotate |
| - | - |
| OpenAI | API key. Rotate the optional organisation and project IDs only if your provider treats them as secret. |
| Anthropic, Gemini, and other API-key providers | API key |
| AWS Bedrock | AWS access key ID and secret access key. For assumed-role setups, also review the role's trust policy. To rotate an external ID, see [Rotate an external ID](#rotate-an-external-id). See [Connect Bedrock with Amazon Assumed Role](https://docs.portkey.ai/docs/aigw/product/model-catalog/connect-bedrock-with-amazon-assumed-role.md). |
| Azure OpenAI | API key, or the Entra ID client secret for service principal authentication |
| Google Vertex AI | Service account key. Create a new key, update the AI Gateway, then delete the old key. |
| Custom or self-hosted model endpoints | Any bearer token or custom header value you configured |

> [!NOTE]
>
> Integrations that use [workload identity federation](https://docs.portkey.ai/docs/aigw/product/model-catalog/workload-identity-federation.md) do not store a static provider key, but they do use an identity provider client secret. Create a replacement client secret at the IdP, update it in the integration (or the vault entry it references), send a test request, then revoke the old secret. Also review the trust relationship and allowed subjects on the cloud side.

### Rotate an external ID

The role's trust policy checks the external ID in its `sts:ExternalId` condition. Changing the ID only in the integration makes `AssumeRole` calls fail. Rotate it in this order:

1. Add the new external ID to the trust policy's `sts:ExternalId` condition, keeping the old one. A condition value can list more than one ID.
2. Update the external ID in the integration.
3. Wait for the change to propagate, then send a test request through the integration.
4. Remove the old external ID from the trust policy.

### Credentials used in requests

If your applications send provider credentials per request, such as an `Authorization` header or `x-portkey-*` provider headers, rotate those in your application secret stores as well.

## 3. MCP credentials

[MCP integrations and servers](https://docs.portkey.ai/docs/aigw/product/mcp-gateway/mcp-registry.md) store credentials that the AI Gateway uses to reach upstream MCP servers. Rotate each one at the source, then update the AI Gateway.

| Authentication type | What to rotate | Steps |
| - | - | - |
| **Static headers** ([custom auth](https://docs.portkey.ai/docs/aigw/product/mcp-gateway/authentication/custom-auth.md)) | Bearer tokens, API keys, or custom header values | Generate new credentials on the MCP server. Update the headers on the MCP integration or server in the AI Gateway. Revoke the old credentials. |
| **Client credentials** | OAuth client secret | Create a new secret at your IdP. Update **Client Secret** in the integration, or in the vault entry it references. Wait up to 5 minutes for vault-cached values to refresh. Revoke the old secret. |
| **OAuth Auto** ([OAuth](https://docs.portkey.ai/docs/aigw/product/mcp-gateway/authentication/oauth.md)) | OAuth client secret, if you supplied your own OAuth app. Per-user access tokens. | Create a new client secret in the upstream OAuth app and update the integration. To force users to re-authorise, remove their stored connections with `DELETE /mcp-servers/{mcpServerId}/connections`. |
| **External OAuth or JWT validation** | Introspection client secret, if configured | Rotate the introspection credentials at your IdP and update the integration. JWKS URIs and public keys are not secret. |

Also rotate any tokens the MCP server itself holds for downstream systems. Those live outside the AI Gateway.

Use [`GET /mcp-servers`](https://docs.gw.prismaairs.com/docs/aigw/api-reference/mcp-servers/mcp-servers-list) and [`GET /mcp-integrations`](https://docs.gw.prismaairs.com/docs/aigw/api-reference/mcp-integrations/mcp-integrations-list) to list every server and integration that needs review.

## 4. Secret references and vault credentials

[Secret references](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/secret-references.md) point to secrets in AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault. The AI Gateway stores the reference configuration, including the auth config it uses to reach your vault. It does not store the secret value itself.

Rotate in this order:

1. **Vault access credentials.** Rotate the credentials in each secret reference's `auth_config` (for example an IAM access key, an Azure client secret, or a HashiCorp Vault token or AppRole secret). Update the reference with [`PUT /secret-references/{secretReferenceId}`](https://docs.portkey.ai/docs/aigw/api-reference/secret-references/update-secret-reference) on `https://api.apps.paloaltonetworks.com/ai_gw/admin/v2`. Updates to `auth_config` are merged, so send only the changed fields.
2. **The secrets themselves.** Rotate the secret values in your vault. Gateways cache fetched values for 5 minutes, so the new value takes effect within that window with no change in the AI Gateway.
3. **Revoke the old vault credentials.**

## 5. JWT, sessions, and users

> [accordion] JWT authentication
>
> The AI Gateway validates JWTs using your IdP's public keys, which are not secret. Rotate signing keys at your IdP if you suspect they were exposed, and confirm the JWKS configuration in the AI Gateway is current. See [JWT](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/jwt.md).

> [accordion] Active sessions and users
>
> Ask users to sign out and back in. Review [organisation users and pending invites](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/organizations.md), and remove any user or invite you don't recognise.

## 6. Plugin integration credentials

Plugin integrations store credentials for third-party guardrail and tool providers. Rotate the credential at the provider, then update it in the AI Gateway.

**1. Create a new credential at the plugin provider**

Generate a new API key, token, or client secret in the provider's console.

**2. Update the plugin integration**

In SCM, navigate to **AI Security > AI Gateway > Admin Settings > Plugins**, open the plugin, and replace the stored credentials.

**3. Update workspace override credentials**

Some guardrails accept workspace-specific **Override Credentials** that take precedence over the organisation-level integration. Open each guardrail that sets them and replace the values.

**4. Test**

Send a request that runs each guardrail or plugin, and confirm the check completes.

**5. Revoke the old credential at the plugin provider**

Wait for the change to propagate, then delete or disable the old credential.

| Credential type | What to rotate |
| - | - |
| API key or token | The key or token issued by the plugin provider |
| Cloud access keys | The access key ID and secret access key, or the external ID for assumed-role setups (see [Rotate an external ID](#rotate-an-external-id)) |
| OAuth or client secret | The client secret at the identity provider |
| Custom endpoint or header | Any bearer token or header value set on the integration |

Managed identity and similar setups store no secret.

Raw guardrails defined in JSON can carry a `credentials` object inline. Review those under [section 7](#7-credentials-embedded-in-configs-and-guardrails) as well.

## 7. Credentials embedded in configs and guardrails

Credentials sometimes end up inside saved resources instead of integrations. Review each of the following for static secrets:

* **[Configs](https://docs.portkey.ai/docs/aigw/product/ai-gateway/configs.md):** provider keys, `Authorization` headers, or custom headers inside targets or `override_params`
* **[Guardrails](https://docs.portkey.ai/docs/aigw/product/guardrails.md):** API keys or headers for third-party guardrail providers, and webhook URLs, headers, or signing secrets for custom guardrails
* **Custom hosts and custom headers:** bearer tokens for private endpoints

For each secret found, rotate it at the upstream service, update the saved resource, and revoke the old value. Prefer [secret references](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/secret-references.md) over inline values so future rotation happens in your vault.

## 8. Observability and log export credentials

Rotate any credential the AI Gateway uses to write to your systems:

* **OpenTelemetry exports:** authentication headers or tokens for your OTel collector. See [OpenTelemetry](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/otel/otel.md).
* **Log storage for self-hosted gateways:** object storage access keys, HMAC secrets, or service account keys.
* **Third-party observability integrations** that you configured with a token.

Create the new credential at the destination, update the AI Gateway configuration, confirm data is arriving, then revoke the old credential.

## 9. Self-hosted gateway secrets

For [hybrid deployments](https://docs.portkey.ai/docs/aigw/self-hosting/hybrid-deployments/architecture.md), rotate every secret in your deployment configuration:

* **`PORTKEY_CLIENT_AUTH`**: the credential your gateway uses to sync with the AI Gateway control plane. See [Rotate the gateway client auth key](#rotate-the-gateway-client-auth-key).
* **Log store credentials:** for example `LOG_STORE_ACCESS_KEY` and `LOG_STORE_SECRET_KEY` (S3, GCS HMAC, or Azure storage).
* **Cache and database credentials:** Redis, and any database your deployment uses.
* **Provider keys and other values in your environment files, Helm values, or Kubernetes secrets.**
* **Test keys:** replace the `PORTKEY_API_KEY` and `OPENAI_API_KEY` values from any smoke-test scripts.

Redeploy the gateway after updating secrets and confirm it registers and serves requests.

### Rotate the gateway client auth key

**1. Open the gateway deployment**

In Strata Cloud Manager, go to **AI Security > AI Gateway > Admin Settings > Gateway Registration** and open the deployment.

**2. Rotate the key**

Under **Gateway Authentication**, click **Rotate Key**. Optionally, set a **Grace period (hours)** from 0 to 24. This is how long the previous key keeps working. Leave it empty to use the default. Click **Confirm Rotation**.

![Rotate Key dialog with the Grace period (hours) field](https://mintcdn.com/portkey-docs/5-Hj3y8TRD56Y6vO/images/support/gateway-rotate-key-grace-period.png?fit=max\&auto=format\&n=5-Hj3y8TRD56Y6vO\&q=85\&s=14f81cada58d53d2eac6204f4a7b9525)

**3. Copy the new key**

Copy the new key and click **Done**. The key is shown only once.

![New gateway auth key shown once with a copy button](https://mintcdn.com/portkey-docs/5-Hj3y8TRD56Y6vO/images/support/gateway-rotate-key-copy.png?fit=max\&auto=format\&n=5-Hj3y8TRD56Y6vO\&q=85\&s=c65547fe49b23c6fda7c04ea9847f746)

**4. Update every deployed gateway and Data Service**

Update `PORTKEY_CLIENT_AUTH` to the new key for every gateway and optional Data Service instance that uses this deployment. If your deployment references a secret store, update the underlying credential while preserving secret references and any other fields in the secret. Restart all consuming services so they load the new key before the grace period ends. Services still using the old key lose control-plane authentication once it expires.

## After rotating

1. **Confirm the old credentials fail.** Wait at least a few minutes for gateway sync and caches to refresh, then send a request with each old AI Gateway API key through every gateway, including self-hosted ones. Expect a `401`.
2. **Test end-to-end.** Send a request through every integration, MCP server, and key path your applications use.
3. **Review audit logs.** Check [audit logs](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/audit-logs.md) in SCM under **Log Viewer** by selecting **Common/Audit** from the drop-down, for unexpected creation of API keys, integrations, users, or configuration changes.
4. **Review request logs and provider usage.** Check request logs and your AI providers' usage dashboards for requests you didn't make.
5. **Review users and workspaces.** Remove any user, workspace member, or workspace you don't recognise.

## Rotation checklist

Copy this list to track progress.

* [ ] Admin API keys replaced; old keys deleted
* [ ] Admin API service account credentials replaced; old credentials deleted
* [ ] Workspace service API keys replaced; old keys deleted
* [ ] Workspace user API keys replaced; old keys deleted
* [ ] Application secret stores updated with new AI Gateway keys
* [ ] Every integration and provider credential rotated at the provider, updated in the AI Gateway, and old credentials revoked
* [ ] MCP integration and server credentials rotated; user connections reset where needed
* [ ] Secret reference vault credentials rotated; secret values rotated
* [ ] Plugin integration credentials rotated, including workspace override credentials
* [ ] Configs, guardrails, and custom hosts reviewed for embedded secrets
* [ ] OTel and log export credentials rotated
* [ ] Self-hosted gateway secrets rotated; gateway redeployed
* [ ] Old AI Gateway API keys confirmed to return `401`
* [ ] Audit logs and provider usage reviewed

## Related

> [card] [API Key Rotation](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/api-key-rotation.md)

> [card] [API Keys (AuthN and AuthZ)](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/api-keys-authn-and-authz.md)

> [card] [Secret References](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/secret-references.md)

> [card] [Audit Logs](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/audit-logs.md)


## Related topics

- [Post api keys by id rotate](https://docs.portkey.ai/docs/aigw/api-reference/api-keys/post-api-keys-by-id-rotate.md)
- [Introduction](https://docs.portkey.ai/docs/aigw/api-reference/admin-api/introduction.md)
- [API Key Rotation](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/api-key-rotation.md)
- [API Keys (AuthN and AuthZ)](https://docs.portkey.ai/docs/aigw/product/enterprise-offering/org-management/api-keys-authn-and-authz.md)
- [Quickstart](https://docs.portkey.ai/docs/aigw/product/mcp-gateway/quickstart.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.