notion-security-basics
Apply Notion API security best practices for integration tokens, OAuth2 flows, least-privilege capabilities, and page-level access control. Use when securing integration tokens, configuring OAuth2 for public integrations, rotating credentials, or auditing which pages an integration can access. Trigger with phrases like "notion security", "notion secrets", "secure notion", "notion API key security", "notion token rotation", "notion OAuth2", "notion permissions audit".
What this skill does
# Notion Security Basics
## Overview
Security fundamentals for the Notion API: integration token management, internal vs public integration models, principle of least privilege for capabilities, page-level access auditing, token rotation, OAuth2 flows for public integrations, and webhook verification. All examples use `@notionhq/client` v2.x and target the `2022-06-28` API version.
## Prerequisites
- Notion integration created at [notion.so/my-integrations](https://www.notion.so/my-integrations)
- Node.js 18+ with `@notionhq/client` installed (`npm install @notionhq/client`)
- Understanding of environment variables and `.env` file patterns
- For public integrations: OAuth2 client ID and secret from the integration dashboard
## Instructions
### Step 1: Secure Token Storage and `.env` Management
Integration tokens are secrets with the same sensitivity as database passwords. Notion tokens use the `ntn_` prefix (current) or `secret_` prefix (legacy). Both grant full access to every page shared with the integration.
```bash
# .gitignore — add these patterns BEFORE creating .env
.env
.env.local
.env.*.local
.env.production
.env.staging
# .env.example — commit this template (no real values)
NOTION_TOKEN=ntn_your_internal_integration_token_here
NOTION_OAUTH_CLIENT_ID=
NOTION_OAUTH_CLIENT_SECRET=
NOTION_OAUTH_REDIRECT_URI=http://localhost:3000/auth/notion/callback
```
```typescript
import { Client } from '@notionhq/client';
// Always load tokens from environment — never hardcode
const token = process.env.NOTION_TOKEN;
if (!token) {
throw new Error(
'NOTION_TOKEN is required. ' +
'Create an integration at https://www.notion.so/my-integrations ' +
'and set the token in your .env file.'
);
}
// Validate token format before using it
if (!token.startsWith('ntn_') && !token.startsWith('secret_')) {
throw new Error(
'NOTION_TOKEN has an unexpected format. ' +
'Internal integration tokens start with ntn_ (or legacy secret_).'
);
}
const notion = new Client({ auth: token });
```
**Git secret scanning** to catch accidental commits:
```yaml
# .github/workflows/secret-scan.yml
name: Secret Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for Notion tokens
run: |
# Scan for internal integration tokens
if grep -rE "(ntn_|secret_)[a-zA-Z0-9]{30,}" \
--include="*.ts" --include="*.js" --include="*.json" \
--include="*.yaml" --include="*.yml" --include="*.env" .; then
echo "::error::Notion token found in source code! Rotate immediately."
exit 1
fi
```
### Step 2: Least-Privilege Capabilities and Access Auditing
Configure integration capabilities at the [integration dashboard](https://www.notion.so/my-integrations). Each integration should request only the capabilities it actually uses.
| Capability | Grant when... | Do NOT grant for... |
|------------|---------------|---------------------|
| Read content | Reading pages, databases, blocks | Write-only bots (form submissions) |
| Update content | Modifying existing page properties/blocks | Read-only dashboards |
| Insert content | Creating new pages, appending blocks | Analytics/reporting tools |
| Read comments | Listing and reading page comments | Data sync pipelines |
| Create comments | Adding comments to discussions | Read-only integrations |
| Read user info (with email) | User lookup by email address | Most integrations |
| Read user info (without email) | Resolving user references in properties | None (safe default) |
**Separate integrations by responsibility:**
```typescript
// Create distinct integrations with different capabilities:
// "acme-reader" — Read content only
// "acme-writer" — Read + Update + Insert content
const readerNotion = new Client({ auth: process.env.NOTION_READ_TOKEN });
const writerNotion = new Client({ auth: process.env.NOTION_WRITE_TOKEN });
// Dashboards and reporting use the reader
const results = await readerNotion.databases.query({
database_id: process.env.NOTION_DATABASE_ID!,
filter: {
property: 'Status',
select: { equals: 'Published' },
},
});
// Mutations use the writer only when needed
await writerNotion.pages.update({
page_id: pageId,
properties: {
'Last Synced': {
date: { start: new Date().toISOString() },
},
},
});
```
**Audit which pages are shared with an integration:**
```typescript
async function auditIntegrationAccess(notion: Client): Promise<void> {
// Search with empty query returns all pages the integration can access
let hasMore = true;
let startCursor: string | undefined;
const accessiblePages: Array<{ id: string; title: string; type: string }> = [];
while (hasMore) {
const response = await notion.search({
start_cursor: startCursor,
page_size: 100,
});
for (const result of response.results) {
if (result.object === 'page') {
const titleProp = Object.values((result as any).properties || {})
.find((p: any) => p.type === 'title') as any;
const title = titleProp?.title?.[0]?.plain_text || '(untitled)';
accessiblePages.push({ id: result.id, title, type: 'page' });
} else if (result.object === 'database') {
const title = (result as any).title?.[0]?.plain_text || '(untitled)';
accessiblePages.push({ id: result.id, title, type: 'database' });
}
}
hasMore = response.has_more;
startCursor = response.next_cursor ?? undefined;
}
console.log(`Integration has access to ${accessiblePages.length} objects:`);
for (const page of accessiblePages) {
console.log(` [${page.type}] ${page.title} (${page.id})`);
}
}
```
**Page sharing hierarchy rules:**
- Sharing a parent page grants access to all child pages and databases
- Sharing a child page alone does NOT grant access to its parent
- Removing integration access from a parent cascades to all children
- The API returns `object_not_found` for both non-existent pages and unshared pages — this is intentional to prevent information leakage
### Step 3: Token Rotation, OAuth2, and Webhook Verification
#### Token Rotation for Internal Integrations
```bash
# 1. Go to notion.so/my-integrations → select integration
# Click "Show" under Internal Integration Secret → "Regenerate"
# WARNING: regeneration immediately invalidates the old token
# 2. Update the secret in your deployment platform FIRST
# AWS Secrets Manager:
aws secretsmanager update-secret \
--secret-id notion/integration-token \
--secret-string "ntn_new_token_value"
# GCP Secret Manager:
echo -n "ntn_new_token_value" | \
gcloud secrets versions add notion-integration-token --data-file=-
# Vault:
vault kv put secret/notion token="ntn_new_token_value"
# 3. Restart services to pick up the new secret
# 4. Verify the new token works
curl -s https://api.notion.com/v1/users/me \
-H "Authorization: Bearer ${NOTION_TOKEN}" \
-H "Notion-Version: 2022-06-28" | jq '.name // .bot'
# 5. Old token is already invalidated (step 1), no separate revocation needed
```
#### OAuth2 Flow for Public Integrations
Public integrations use OAuth2 to let users authorize access without sharing raw tokens. This is required when distributing your integration to other Notion workspaces.
```typescript
import { Client } from '@notionhq/client';
import express from 'express';
const app = express();
const OAUTH_CLIENT_ID = process.env.NOTION_OAUTH_CLIENT_ID!;
const OAUTH_CLIENT_SECRET = process.env.NOTION_OAUTH_CLIENT_SECRET!;
const REDIRECT_URI = process.env.NOTION_OAUTH_REDIRECT_URI!;
// Step A: Redirect user to Notion's authorization page
app.get('/auth/notion', (req, res) => {
const authUrl = new URL('https://api.notion.com/v1/oauth/authorize');
authUrl.searchParams.set('client_id', OAUTH_CLIENT_ID);
authUrl.searchParams.set('response_type', 'code');
authUrl.searchParams.set('redirect_uri', REDIRECT_URRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.