# client.secrets

> The secrets methods of the morevoice Python SDK: Secret names available to tools and flows (values are never returned).

Secret names available to tools and flows (values are never returned). These methods are on `client.secrets`, where `client` is a `MoreVoice` client (see [the Python SDK](https://docs.morevoice.ai/sdk/python/#connect)). On `AsyncMoreVoice` the same methods are awaited. Each one returns the response object and raises an exception when the API answers with an error.

## `delete()`

**Delete a secret.** Flows that still reference {{secret.NAME}} then get an empty value. Needs a live key.

```python
# client.secrets
def delete(self, name: str, *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.DeletedSecret
```

`client.secrets.delete()` · `await async_client.secrets.delete()` · `DELETE /secrets/{name}` · [API reference](https://docs.morevoice.ai/api/operations/secrets_delete/)

### Parameters

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

### Returns

`DeletedSecret`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"secret"` | Always `secret`. |
| `name` | `string` | — |
| `deleted` | `true` | — |

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

deleted_secret = client.secrets.delete("name_123")
print(deleted_secret)
```

## `list()`

**List secrets.** Names and update times only, most recently changed first: values are never returned.

```python
# client.secrets
def list(self, *, limit: int | Unset = 20, starting_after: str | Unset = UNSET, ending_before: str | Unset = UNSET, more_voice_version: str | Unset = UNSET) -> AsyncPage[_m.Secret]
```

`client.secrets.list()` · `await async_client.secrets.list()` · `GET /secrets` · [API reference](https://docs.morevoice.ai/api/operations/secrets_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |

### Returns

A page of results (`SecretList`): `data`, `has_more` and `next_cursor`.

### Example

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

for secret in client.secrets.list():
    print(secret)
```

## `set()`

**Create or replace a secret.** 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.

```python
# client.secrets
def set(self, name: str, body: _m.SecretsSetBody | Mapping[str, Any], *, more_voice_version: str | Unset = UNSET) -> _m.Secret
```

`client.secrets.set()` · `await async_client.secrets.set()` · `PUT /secrets/{name}` · [API reference](https://docs.morevoice.ai/api/operations/secrets_set/)

### Parameters

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

### Request body

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

### Returns

`Secret`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"secret"` | Always `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

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

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