# Create or replace a secret

`PUT https://api.morevoice.ai/v1/secrets/{name}`

Sets the value of {{secret.NAME}} (creating it, or replacing the value). Write-only: the value is encrypted at rest and never returned. Flows and providers pick the new value up within seconds. Needs a live key.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `secrets_set`.

## Parameters

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | yes | The secret's name. |

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |

## Request body

Required, `application/json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `value` | `string` | yes | The value (up to 8 KB). Write-only: it is encrypted at rest and never returned. |

Example:

```json
{
  "value": "sk_live_…"
}
```

## Responses

### 200 OK

OK Returns `Secret`.

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"secret"` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | Referenced as {{secret.NAME}} in flow API nodes and messaging settings. |
| `updated` | `string` | An ISO-8601 timestamp in UTC. |

Example:

```json
{
  "livemode": true,
  "name": "CRM_TOKEN",
  "object": "secret",
  "updated": "2026-11-03T09:14:22.000Z"
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 404 Not Found

No object with this ID exists in this organisation and mode. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const secret = await mv.secrets.set("name_123", {
	value: "sk_live_…",
});
console.log(secret);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

secret = client.secrets.set("name_123", {
    "value": "sk_live_…",
})
print(secret)
```

**cURL**

```sh
curl -X PUT https://api.morevoice.ai/v1/secrets/name_123 \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "value": "sk_live_…"
}'
```
