# Replace a secret set (/en/api-reference/api-ref/conversational-ai/platform/replace-secret-set)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

> Documentation: Conversational AI API.
> Documentation version: Preview.
> This document describes only this version. [Version index](/llms/doc-versions-convoai-api-v2.txt).


Replaces all the keys in a secret set in one change.

- OpenAPI: /openapi/conversational-ai/rest-api-platform.en.yaml
- Operation ID: replace-secret-set
- Method: PUT
- Path: /v1/projects/{appid}/secrets/{name}
- Endpoint: https://preview.ai.agora.io/conversational-ai/v1/projects/{appid}/secrets/{name}

## Servers

- https://preview.ai.agora.io/conversational-ai

After the request, the set contains only the keys you pass. Keys you omit are removed. Agents keep referencing the set by name, so you don't need to change them.


## Authorization

This endpoint requires authentication.

- `tokenAuth`
- `basicAuth`

## Parameters

- `appid` (path, required, string) - The App ID of your project.
- `name` (path, required, string) - The name of the secret set.
- `If-Match` (header, required, string) - The `ETag` value from the most recent response for this resource. If the resource has changed since then, the request fails with `412` and reason `PreconditionFailed`. Retrieve the resource, apply your change again, and retry with the new `ETag`.

## Request body

- `secrets` (object, required) - The secrets, as key-value pairs. Each key is 1 to 64 characters from `A-Z`, `a-z`, `0-9`, and `_`, and must be unique within the set. Values are write-only and are never returned. A set can hold at most 64 KiB, measured as the UTF-8 size of its keys and values encoded as a JSON object. A larger set is rejected with `400`.

### Request body example

```json
{
  "secrets": {
    "asr": "<your_asr_api_key>",
    "llm": "<your_llm_api_key>"
  }
}
```

## Responses

### 200

The secret set was replaced. The response body lists its keys.

- `name` (string, required) - The name of the secret set.
- `keys` (array, required) - The names of the keys in the set. Values are never returned.
  - `keys.items` (string)
- `create_ts` (integer, required) - The time the set was created, as a Unix timestamp in seconds.
- `update_ts` (integer, required) - The time the set was last updated, as a Unix timestamp in seconds.
### 400

The request is invalid. Check `reason` and `detail` in the response body.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 401

Authentication is missing or invalid. The reason is `InvalidPermission`.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 404

The resource in the path doesn't exist. The reason is `ResourceNotFound`.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 409

`SecretSetInUse`: An agent references a key that the replacement removes.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### 412

The `If-Match` value doesn't match the current version of the resource. The reason is `PreconditionFailed`. Retrieve the resource, apply your change again, and retry with the new `ETag`.

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
### default

The request failed. The response body contains the `reason` and `detail` of the failure. For possible reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).

- `detail` (string, required) - A human-readable description of the error. It names the field or resource involved, when there is one. Don't parse it; branch on `reason` instead.
- `reason` (string, required) - A machine-readable error reason, such as `InvalidFieldValue` or `ResourceNotFound`. For all reasons, see [Status codes](/en/api-reference/api-ref/conversational-ai/platform/status-codes).
