Notion api basics

From theheavenlyd3mon/hermes-profiles · View interactive version

Notion api basics is an AI agent skill from the GitHub repository theheavenlyd3mon/hermes-profiles. Notion API fundamentals: authentication, curl patterns, property types, API version differences, and troubleshooting.

How to use this skill

Skill file

Notion API Basics

Foundation skill for all Notion API operations. Covers authentication, the base curl pattern, property types, API version differences, and common troubleshooting.

Prerequisites

  1. Create an integration at https://notion.so/my-integrations
  2. Copy the API key (starts with ntn_ or secret_)
  3. Store it in ~/.hermes/.env:

```bash

echo 'NOTION_API_KEY=ntn_your_key_here' >> ~/.hermes/.env

```

  1. Important: Share target pages/databases with your integration in Notion (click "..." → "Connect to" → your integration name)
  2. Find a page/database ID: open it in Notion, copy the URL — the ID is the UUID segment (32 hex chars, dashes optional)

Pitfall: Check the key isn't commented out

grep '^NOTION_API_KEY=' ~/.hermes/.env

If you see # NOTION_API_KEY=... (commented out), uncomment it:

sed -i '' 's/^# NOTION_API_KEY=/NOTION_API_KEY=/' ~/.hermes/.env

The .env file is write-protected from Hermes tools — use sed via terminal.

Pitfall: Terminal sandbox points HOME elsewhere

When running inside a profile (e.g. Senna), $HOME resolves to ~/.hermes/profiles/<profile>/home — NOT ~. This means source ~/.hermes/.env fails. Always use the absolute path:

source ~/.hermes/.env

This applies to cron jobs and terminal() calls inside the profile sandbox.

Authentication Options

| Method | What it is | Page sharing needed? | Workspace scope |

|--------|-----------|----------------------|-----------------|

| Internal Integration (recommended) | A bot with its own permissions | ✅ Share each page/database with the bot explicitly | One workspace |

| PAT (Personal Access Token) | Acts as you — has your existing permissions | ❌ No sharing needed — sees what you see | One user in one workspace |

| OAuth 2.0 | For apps distributed to other people's workspaces | ❌ Users pick pages during install | Any workspace |

Recommendation: Start with an Internal Integration unless the user explicitly asks for a PAT.

Base curl Pattern

All requests follow this pattern:

curl -s -X GET "https://api.notion.com/v1/..." \
  -H "Authorization: Bearer $NOTION_API_KEY" \
  -H "Notion-Version: 2025-09-03" \
  -H "Content-Type: application/json"

Key points:

Property Types Reference

When creating or updating database entries (pages), properties follow these formats:

| Type | JSON Format |

|------|------------|

| Title | {"title": [{"text": {"content": "..."}}]} |

| Rich text | {"rich_text": [{"text": {"content": "..."}}]} |

| Select | {"select": {"name": "Option"}} |

| Multi-select | {"multi_select": [{"name": "A"}, {"name": "B"}]} |

| Date | {"date": {"start": "2026-01-15", "end": null}} |

| Checkbox | {"checkbox": true} |

| Number | {"number": 42} |

| URL | {"url": "https://..."} |

| Email | {"email": "user@example.com"} |

| Relation | {"relation": [{"id": "page_id"}]} |

Key API Version Differences (2025-09-03 vs older)

Notes

Troubleshooting

`object_not_found` (404)

Almost always a permissions issue, not a missing page. The integration hasn't been granted access.

Fix: In Notion, open the page → "..." → "Connect to" → select your integration name.

`validation_error` — property doesn't exist

The property name in your JSON doesn't match the schema. Fetch actual property names:

source ~/.hermes/.env
DS_ID=$(curl -s "https://api.notion.com/v1/databases/{database_id}" \
  -H "Authorization: Bearer $NOTION_API_KEY" \
  -H "Notion-Version: 2025-09-03" | jq -r '.data_sources[0].id')
curl -s "https://api.notion.com/v1/data_sources/$DS_ID" \
  -H "Authorization: Bearer $NOTION_API_KEY" \
  -H "Notion-Version: 2025-09-03" | jq '.properties | keys'

Properties silently dropped during database creation

If you used POST /v1/databases with top-level properties (old API pattern), the properties are silently dropped — only a default "Name" title property exists. Fix by PATCHing the data source (see notion-databases skill).

Load-bearing URLs

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.