# Store or replace the cloud provider's API key.

> Write-only.
> https://koi.dog/docs/api/cloud/set-cloud-api-key/

`PUT /api/v1/cloud/api-key` · Scope: `config`

Koidog reads the account with it at once; `GET /cloud` then says whether the provider accepted it. When an API key calls it, the timeline records who did what and the outcome. No path or query parameters.

## 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 JSON object. 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/cloud/api-key \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "value": "<the provider key>"
    }'
```

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

```python
import os

import requests

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

## Response example.

```json
{
  "ok": true
}
```
