# API keys

> Keys for one site or the whole account, read-only or read and change.

An API key lets an agent or a script use Okidoki on your behalf. Each key covers one site or your whole account, and can only read or also change things.

## Make a key

1. Go to **Settings → Connections** and find **Your AI agent**. The card **Let your AI read your stats** at the bottom of a site's overview has the same keys under **Developers**.
2. Choose **Only mysite.com** or **All my sites**.
3. Choose **Read and change** or **Only read**.
4. Press **Make a key** and copy it. **It is shown only once.**

Next to the key you also get a sentence to paste to your agent, with the key already in it.

> [!TIP]
> For Claude and ChatGPT you do not need to make a key. Add `https://okidoki.sh/mcp` as a connector and sign in to Okidoki. Each app you connect that way gets its own key, listed under **Your AI agent**, where you can turn it off. See [MCP server](https://docs.okidoki.sh/mcp).

## What a key can do

| | Only read | Read and change |
| --- | --- | --- |
| Read reports, summaries and insights | Yes | Yes |
| Check the install, list goals and share links, make campaign links | Yes | Yes |
| Add and remove goals, make and turn off share links, set the time zone | No | Yes |
| Add or delete sites, manage keys, turn the weekly email on or off | No | Yes, with a key for all sites |

A key for one site can only see and change that site. Adding sites and managing keys needs a key for the whole account.

A key can never do more than its owner. Plus features need Plus on the account, whatever the key.

## Keep keys safe

- Keys start with `oks_`. Treat them like a password.
- Okidoki stores keys scrambled and cannot show them again. If you lose one, make a new one.
- Give an agent a read-only key if it only needs to read.
- Never put a key that can change things in public code, like a site's JavaScript.

## Turn a key off

Under **Your AI agent**, press **Turn off** next to the key. It stops working right away. The list shows when each key was last used, so you can spot keys nobody needs.

## Keys from the API

A key for the whole account that can change things can manage keys too:

```bash
# List keys (never shows the secret)
curl -H "Authorization: Bearer oks_..." https://okidoki.sh/api/v1/keys

# A read-only key for one site
curl -X POST https://okidoki.sh/api/v1/keys \
  -H "Authorization: Bearer oks_..." -H "Content-Type: application/json" \
  -d '{"site":"mysite.com","access":"read","label":"Weekly report bot"}'

# Turn a key off
curl -X DELETE -H "Authorization: Bearer oks_..." https://okidoki.sh/api/v1/keys/KEY_ID
```

The new key's secret is in `data.secret`, shown only in that answer.

## The site key is not an API key

The `ok_...` key in your script tag is a public **site key**. It only lets pages send visits. The `oks_...` keys on this page are secret **API keys**. See [Sites and settings](https://docs.okidoki.sh/sites#site-key).

