# rotateSecret()

Rotates the client secret for a given [`OAuthApplication`](https://clerk.com/docs/reference/backend/types/backend-oauth-application.md) by its ID. When the client secret is rotated, ensure that you update it in your authorized OAuth clients.

```ts
function rotateSecret(oauthApplicationId: string): Promise<OAuthApplication>
```

## Parameters

| Name               | Type   | Description                                                            |
| ------------------ | ------ | ---------------------------------------------------------------------- |
| oauthApplicationId | string | The ID of the OAuth application for which to rotate the client secret. |

## Example

> Using `clerkClient` varies based on the SDK you're using. Refer to the [overview](https://clerk.com/docs/reference/backend/overview.md) for usage details, including guidance on [how to access the `userId` and other properties](https://clerk.com/docs/reference/backend/overview.md#example-get-the-user-id-and-other-properties).

```tsx
const oauthApplicationId = 'oauthapp_123'

const response = await clerkClient.oauthApplications.rotateSecret(oauthApplicationId)
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `POST/oauth_applications/{oauth_application_id}/rotate_secret`. See the [BAPI reference](https://clerk.com/docs/reference/backend-api/tag/oauth-applications/POST/oauth_applications/%7Boauth_application_id%7D/rotate_secret){{ target: '_blank' }} for more information.

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
