---
name: notion-apikeys
description: Look up API keys from Anthony's Notion 'API' database. Use this skill whenever you need an API key, token, or secret for any service (Brave, OpenAI, Notion, etc.) and it isn't already configured. Instead of asking Anthony for the key manually, query his Notion database to retrieve it automatically. Triggers on missing API key errors, needing to configure a service, or any request to find/use a stored API key.
---

# Notion API Key Lookup

Query Anthony's Notion 'API' database to retrieve API keys and secrets.

## Config File

Credentials are stored at `~/.config/notion-apikeys.json`:
```json
{
  "token": "secret_...",
  "database_id": "..."
}
```

## Script

```
skills/notion-apikeys/scripts/query.py
```

## Usage

```bash
# Look up a specific service
python3 scripts/query.py "Brave"

# List all entries (keys are partially masked)
python3 scripts/query.py --list

# First-time setup (interactive)
python3 scripts/query.py --setup

# Discover what columns exist in the database
python3 scripts/query.py --find-db

# Pass token inline without saving
python3 scripts/query.py "Brave" --token secret_xxx
```

## Workflow: Retrieve a Key and Configure OpenClaw

1. Run `query.py <service>` with the service name
2. Extract the key from the output
3. Apply to OpenClaw config via `gateway config.patch` or edit `~/.openclaw/openclaw.json` directly
4. Restart gateway if needed

## Setup (First Time)

Anthony must:
1. Create a Notion integration at https://www.notion.so/my-integrations
2. Share the 'API' database page with that integration (Share → Invite)
3. Copy the integration token (starts with `secret_`)
4. Run: `python3 scripts/query.py --setup`

If the Notion token is already known, pass it directly:
```bash
python3 scripts/query.py "Brave" --token secret_xxxx
```

## Notion Database Structure

The script auto-discovers column names. Common layouts:
- **Name** (title) — service/provider name  
- **API Key** / **Key** / **Token** — the actual secret  
- **URL** / **Endpoint** — optional base URL  
- **Notes** — optional context  

If the property names differ, run `--find-db` to inspect them.

## Error Handling

- "Could not find 'API' database" → integration hasn't been shared with the database
- "Notion API error 401" → token is invalid or expired
- "No entries found for X" → check spelling; use `--list` to see all available entries
