# Update Secret

`PUT /vault/secrets/{path}` · Keys & Secrets · Secrets

Stores a new value for a secret as its next version. Only the owner can update a secret.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `projectId` | query | yes | The project's id. Example: `"3f2c9a4e-8b1d-4c6f-9e2a-7d5b1c0a4e8f"`. |
| `path` | path | yes | The secret's path: `/`-delimited segments, such as `database/prod/password`. Example: `"database/prod/password"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `value` | string | yes | New plaintext bytes, base64-encoded over the wire. Example: `"bjN3LXMzY3IzdC12YWx1ZQ=="`. |

```json
{
  "value": "bjN3LXMzY3IzdC12YWx1ZQ=="
}
```

## Responses

- **200**: The secret's new version.

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | `sec_<base62>`. Example: `"sec_4fK9xQ2mZ7"`. |
| `name` | string | yes | The secret's path. Example: `"database/prod/password"`. |
| `version` | integer (int64) | yes | The new version, one above the previous. Example: `3`. |


## Errors

| HTTP | Description |
|---|---|
| 400 | The path or the body isn't valid. |
| 401 | The request carries no authenticated caller. |
| 403 | The caller can see the secret but doesn't own it. |
| 404 | No such secret visible to the caller. |
| 409 | `K9O_REKEY_IN_PROGRESS` or `K9O_CUSTODY_TRANSITION_IN_PROGRESS`: a key rotation or custody change is running. Retry when it completes. |

## Code samples

### cURL

```bash
curl -X PUT 'https://<org>.api-<region>.k9o.io/@storefront/vault/secrets/<name>' \
  -H 'Authorization: Bearer $K9O_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "value": "bjN3LXMzY3IzdC12YWx1ZQ=="
}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/vault/secrets/<name>', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
  "value": "bjN3LXMzY3IzdC12YWx1ZQ=="
}),
});
const { data, meta } = await res.json();
```

### k9o CLI

```bash
k9o vault-secret update <name> --region <region>
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.kibo.vault.secrets.update('<name>', {
  value: 'n3w-s3cr3t-value'
})
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/keys-secrets/update-secret
