---
title: "Rotate API Key"
method: POST
path: "/v4/organizations/{organizationId}/apikeys/{ApiKeyId}/rotate"
tags: ["Api Keys"]
---

# Rotate API Key

`POST /v4/organizations/{organizationId}/apikeys/{ApiKeyId}/rotate`

## Request

- Base URL: `https://cloudapi.cloud.couchbase.com`
- URL: `https://cloudapi.cloud.couchbase.com/v4/organizations/{organizationId}/apikeys/{ApiKeyId}/rotate`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/couchbase/apis/couchbase-capella-management-api/docs/v4/organizations/:organizationId/apikeys/:ApiKeyId/rotate/post.ts> (a function with typed inputs; its response is checked against the schema)

Rotate the secret of a given API key under an organization.

Organization Owners can rotate any API key inside the Organization.

To learn more, see [Organization, Project, and Database Access Overview](https://docs.couchbase.com/cloud/organizations/organization-projects-overview.html).

## Request body

- RotateAPIKeyRequest
  - `secret` string: A secret associated with API key. One has to follow the secret key policy, such as allowed characters and a length of 64 characters. If this field is left empty, a secret will be auto-generated.

## Response `200`

Successfully rotated the API key.

- RotateAPIKeyResponse
  - `secretKey` string, required: The Secret key is a confidential piece of information that is paired with the Access key. The API key is made of an Access key and a Secret key.
  - `token` string, required: The Token is a confidential piece of information that is used to authorize requests made to v4 endpoints.

## Other responses

- `403`: The client does not have the necessary permissions to access this resource.
- `404`: The requested resource was not found.
- `422`: Request validation error.
- `500`: An unexpected error occurred in the server while processing this request.

---

[API](https://skmtc.dev/couchbase/apis/couchbase-capella-management-api.md) - [All operations](https://skmtc.dev/couchbase/apis/couchbase-capella-management-api/llms.txt) - [OpenAPI document](https://skmtc.dev/couchbase/apis/couchbase-capella-management-api/revisions/fcc4f29578b1?raw)
