---
docId: doc_0d3d950dd16c4a12b607728b28c9b35d
title: Update a secret
description: Change a secret's name, its expiration, or both. It does not change the value.
api:
  group: herramientas/secretos
  auth: bearer
  operations:
    - operationId: updateSecret
      method: PATCH
      path: '/v1/secrets/{secretId}'
      postmanName: Update a secret
---

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

# Update a secret

Change the name, expiration or both by sending `name` or `expiresAt`. The secret’s value is preserved; to change it, use [Rotate a secret](/api-reference/secrets/rotate).

## Example

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

```bash
curl -X PATCH https://api.platic.ai/v1/secrets/$SECRET_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Orders API (production)" }'
```

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

```ts
await platic.secrets.update("secret_123", { name: "Orders API (production)" });
```

</Ways.Way>
</Ways>

## Path parameters

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

## Request body

Send at least one.

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `name` | string | New name, 1 to 150 characters | — |
| `expiresAt` | string \| null | A future date in ISO 8601 with a time zone. `null` removes the expiration | — |

```json
{
  "name": "Acme Store · Orders API (production)",
  "expiresAt": "2027-06-30T06:00:00.000Z"
}
```

## Response

```json
{
  "status": "success",
  "message": "Secret updated successfully",
  "data": {
    "id": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c",
    "name": "Acme Store · Orders API (production)",
    "kind": "bearer",
    "status": "active",
    "revision": 2,
    "createdAt": "2026-10-28T12:05:00.000Z",
    "updatedAt": "2026-11-03T18:40:12.000Z",
    "expiresAt": "2027-06-30T06:00:00.000Z"
  }
}
```

### Response fields

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

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | The body is empty or a field is not valid. `details.issues` has the list of problems |
| `400` | `INVALID_EXPIRY` | `expiresAt` is not in the future |
| `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 being deleted |

## Notes

- You do not need to send the secret's revision: the API uses the current one.
- Changing the name or expiration does not affect resources that already work. Before publishing an API or [choosing tools](/api-reference/mcp-servers/select-tools) from an MCP server that uses this secret, test it again: both operations require a test with the secret’s current configuration.
- The `kind` cannot be changed. If you made a mistake, create another secret.
