---
docId: doc_e62d6c6308eb4133ba8dc14df7360d0e
title: Rotate a secret
description: Replace a secret's value. Everything that uses it takes the new value on its next call, without binding again.
api:
  group: herramientas/secretos
  auth: bearer
  operations:
    - operationId: rotateSecret
      method: POST
      path: '/v1/secrets/{secretId}/rotate'
      postmanName: Rotate a secret
---

<script>
  import { Ways } from '$lib/components';
</script>

# Rotate a secret

Update a credential when the provider gives you a new value or the previous one is exposed. Send the new value in `value`. Bound APIs, MCP servers and webhooks use it from their next call, without binding the secret again.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X POST https://api.platic.ai/v1/secrets/$SECRET_ID/rotate \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "value": "your-new-api-key" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.secrets.rotate("secret_123", "your-new-api-key");
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `secretId` | string | Id of the secret | ✓ |

## Request body

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `value` | string | The new value. 1 to 16,384 characters | ✓ |

```json
{
  "value": "sk_test_example_new"
}
```

## Response

The response has the secret's details, never the value.

```json
{
  "status": "success",
  "message": "Secret rotated successfully",
  "data": {
    "id": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c",
    "name": "Acme Store · Orders API",
    "kind": "bearer",
    "status": "active",
    "revision": 3,
    "createdAt": "2026-10-28T12:05:00.000Z",
    "updatedAt": "2026-11-05T10:15:30.000Z"
  }
}
```

### Response fields

`data` has the secret after the change, with the fields in [list secrets](/api-reference/secrets/list#response-fields). The `id` does not change; `revision` goes up by one.

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | `value` is missing or empty. `details.issues` has the list of problems, without repeating the value |
| `403` | `FORBIDDEN` | The person behind the token cannot manage secrets |
| `404` | `SECRET_NOT_FOUND` | The secret does not exist in this workspace or was already deleted |
| `409` | `SECRET_CHANGED` | Another change arrived at the same time. Repeat the call |
| `409` | `SECRET_USE_REVOKED` | The secret is revoked or being deleted. Create a new one |

## Notes

- The `id` and the bound slots are kept: there is nothing to bind again.
- What is already published keeps working with the new value. An API you have not published yet needs a new test before you [publish it](/api-reference/custom-apis/publish), and an MCP server needs to be [tested](/api-reference/mcp-servers/test) before you [choose tools](/api-reference/mcp-servers/select-tools) again.
- If you rotate a webhook's signing secret, update the same value on your server: the following deliveries are signed with the new one.
- A revoked secret cannot be rotated.
