# Store or replace the connection's credential.

> Write-only.
> https://koi.dog/docs/api/connections/set-connection-secret/

`PUT /api/v1/connections/{id}/secret` · Scope: `config`

The value is encrypted at rest and is never returned, logged or put in an event. When an API key calls it, the timeline records who did what and the outcome. No query parameters.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The connection's id. |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `value` | `string` | yes | The credential. It is encrypted at rest and never returned, logged or put in an event. 1 to 20000 characters. |

## Response.

200 OK: a `Connection`. The example has placeholder values.

- **422 validation_failed**: The body does not match its schema; each problem is in `details`.

## Request.

```sh
curl -X PUT "https://app.koi.dog/api/v1/connections/$ID/secret" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "value": "<the credential>"
    }'
```

```js
const res = await fetch(`https://app.koi.dog/api/v1/connections/${process.env.ID}/secret`, {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    value: "<the credential>",
  }),
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.put(
    f"https://app.koi.dog/api/v1/connections/{os.environ['ID']}/secret",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
    json={
        "value": "<the credential>",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "name": "string",
  "harness": "claude-code",
  "provider": "anthropic",
  "model": "string",
  "auth": "local_login",
  "scope": "local",
  "metering": "subscription",
  "maxConcurrent": 0,
  "status": "untested",
  "defaultOptions": {
    …
  },
  "statusDetail": "string",
  "hasSecret": false,
  …
}
```
