notion-core-workflow-a
Query, filter, and manage Notion databases and pages. Use when building database queries with filters and sorts, creating/updating pages with typed properties, or reading page content. Trigger with phrases like "notion database query", "notion filter", "notion create page", "notion update properties", "notion CRUD".
What this skill does
# Notion Core Workflow A โ Databases & Pages
## Overview
Primary workflow for Notion integrations: querying databases with filters/sorts, creating pages with typed properties, updating page properties, and retrieving page content.
## Prerequisites
- Completed `notion-install-auth` setup
- A Notion database shared with your integration
- Understanding of your database's property schema
## Instructions
### Step 1: Retrieve Database Schema
```typescript
import { Client } from '@notionhq/client';
const notion = new Client({ auth: process.env.NOTION_TOKEN });
async function getDatabaseSchema(databaseId: string) {
const db = await notion.databases.retrieve({ database_id: databaseId });
// db.properties contains the schema
for (const [name, prop] of Object.entries(db.properties)) {
console.log(`${name}: ${prop.type}`);
// For select/multi_select, show options:
if (prop.type === 'select') {
console.log(' Options:', prop.select.options.map(o => o.name));
}
}
return db.properties;
}
```
### Step 2: Query with Filters
Notion filters use a unique nested structure based on property type:
```typescript
async function queryWithFilters(databaseId: string) {
const response = await notion.databases.query({
database_id: databaseId,
filter: {
and: [
{
property: 'Status',
select: { equals: 'In Progress' },
},
{
property: 'Priority',
select: { does_not_equal: 'Low' },
},
{
or: [
{
property: 'Assignee',
people: { contains: 'user-uuid-here' },
},
{
property: 'Tags',
multi_select: { contains: 'Urgent' },
},
],
},
],
},
sorts: [
{ property: 'Priority', direction: 'ascending' },
{ property: 'Created', direction: 'descending' },
],
page_size: 50,
});
return response.results;
}
```
### Step 3: Filter Syntax by Property Type
```typescript
// Text (title, rich_text, url, email, phone_number)
{ property: 'Name', title: { contains: 'search term' } }
{ property: 'Description', rich_text: { starts_with: 'Draft' } }
{ property: 'Email', email: { equals: '[email protected]' } }
// Number
{ property: 'Score', number: { greater_than: 80 } }
{ property: 'Price', number: { less_than_or_equal_to: 100 } }
// Select / Multi-select
{ property: 'Status', select: { equals: 'Done' } }
{ property: 'Tags', multi_select: { contains: 'Bug' } }
// Date
{ property: 'Due Date', date: { before: '2026-04-01' } }
{ property: 'Created', date: { past_week: {} } }
{ property: 'Updated', date: { on_or_after: '2026-01-01' } }
// Checkbox
{ property: 'Archived', checkbox: { equals: false } }
// People
{ property: 'Assignee', people: { contains: 'user-uuid' } }
// Relation
{ property: 'Project', relation: { contains: 'page-uuid' } }
// Formula (filter on the result type)
{ property: 'Computed', formula: { number: { greater_than: 0 } } }
// Rollup (filter on the aggregated result)
{ property: 'Total', rollup: { number: { greater_than: 100 } } }
// Timestamp (no property name needed)
{ timestamp: 'last_edited_time', last_edited_time: { after: '2026-03-01' } }
```
### Step 4: Create a Page with All Property Types
```typescript
async function createFullPage(databaseId: string) {
return notion.pages.create({
parent: { database_id: databaseId },
icon: { emoji: '๐' },
properties: {
// Title (required โ every database has exactly one)
Name: {
title: [{ text: { content: 'New Task' } }],
},
// Rich text
Description: {
rich_text: [
{ text: { content: 'This is ' } },
{ text: { content: 'important' }, annotations: { bold: true, color: 'red' } },
],
},
// Number
Score: { number: 95 },
// Select
Status: { select: { name: 'In Progress' } },
// Multi-select
Tags: {
multi_select: [{ name: 'API' }, { name: 'Backend' }],
},
// Date (with optional end and timezone)
'Due Date': {
date: { start: '2026-04-15', end: '2026-04-20' },
},
// Checkbox
Urgent: { checkbox: true },
// URL
Link: { url: 'https://developers.notion.com' },
// Email
Contact: { email: '[email protected]' },
// People (array of user objects)
Assignee: {
people: [{ id: 'user-uuid-here' }],
},
// Relation (array of page references)
Project: {
relation: [{ id: 'related-page-uuid' }],
},
},
});
}
```
### Step 5: Update Page Properties
```typescript
async function updatePage(pageId: string) {
return notion.pages.update({
page_id: pageId,
properties: {
Status: { select: { name: 'Done' } },
Score: { number: 100 },
Urgent: { checkbox: false },
},
});
}
// Archive (soft delete) a page
async function archivePage(pageId: string) {
return notion.pages.update({
page_id: pageId,
archived: true,
});
}
```
### Step 6: Paginate Through All Results
```typescript
async function getAllPages(databaseId: string) {
const allPages = [];
let cursor: string | undefined = undefined;
do {
const response = await notion.databases.query({
database_id: databaseId,
start_cursor: cursor,
page_size: 100, // max is 100
});
allPages.push(...response.results);
cursor = response.has_more ? response.next_cursor ?? undefined : undefined;
} while (cursor);
return allPages;
}
```
## Output
- Database schema retrieved with property types and options
- Filtered and sorted query results
- Pages created with typed properties
- Pages updated and archived
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| `validation_error` | Property name mismatch or wrong type | Use `databases.retrieve` to check schema |
| `object_not_found` | Database not shared with integration | Add integration via Connections |
| `rate_limited` (429) | >3 requests/second average | Respect `Retry-After` header |
| Empty `results` | Filter too restrictive or no data | Test with no filter first |
## Examples
### Extract Property Values Helper
```typescript
function getPropertyValue(property: any): string | number | boolean | null {
switch (property.type) {
case 'title':
return property.title.map((t: any) => t.plain_text).join('');
case 'rich_text':
return property.rich_text.map((t: any) => t.plain_text).join('');
case 'number':
return property.number;
case 'select':
return property.select?.name ?? null;
case 'multi_select':
return property.multi_select.map((s: any) => s.name).join(', ');
case 'date':
return property.date?.start ?? null;
case 'checkbox':
return property.checkbox;
case 'url':
return property.url;
case 'email':
return property.email;
case 'formula':
return property.formula?.[property.formula.type] ?? null;
default:
return null;
}
}
```
## Resources
- [Query a Database](https://developers.notion.com/reference/post-database-query)
- [Filter Database Entries](https://developers.notion.com/reference/post-database-query-filter)
- [Create a Page](https://developers.notion.com/reference/post-page)
- [Page Property Values](https://developers.notion.com/reference/page-property-values)
- [Database Object](https://developers.notion.com/reference/database)
## Next Steps
For block-level content operations, see `notion-core-workflow-b`.
Related in Productivity
gitea-workflow
IncludedOrchestrate agile development workflows for Gitea repositories using the tea CLI. Use when working with Gitea-hosted repos and asking to 'run the workflow', 'continue working', 'what's next', 'complete the task cycle', 'start my day', 'end the sprint', 'implement the next task', or wanting guided step-by-step development assistance. Keywords: workflow, orchestrate, agile, task cycle, sprint, daily, implement, review, PR, standup, retrospective, gitea, tea.
microsoft-graph-gateway
IncludedRoute Microsoft Graph work in this workspace. Use when users want to read or write Outlook mail, calendar events, contacts, OneDrive or SharePoint files, Teams, Planner, To Do, users, groups, directory data, or arbitrary Microsoft Graph endpoints from VS Code. Prefer WorkIQ for common read scenarios. Use Microsoft Graph for write actions and gap-read scenarios that need exact Graph properties, filters, permissions, or endpoints.
copilotkit
IncludedUse when building with CopilotKit โ setup, development, integrations, debugging, upgrading, or contributing. Routes to the appropriate specialized skill based on the task.
wordly-wisdom
IncludedProvides calibrated decision analysis using Charlie Munger-style multiple mental models, inversion, incentive mapping, circle-of-competence checks, misjudgment audits, second-order effects, and forecast updates. Use when the user asks for an oracle take, a hard call, a decision memo, a premortem, an outside view, a red-team, a sanity-check, what am I missing, think this through, or wants a strategy, hire, investment, plan, product, partnership, or major life choice analysed. Avoid for simple factual lookups or time-sensitive legal, medical, or market questions without fresh evidence.
swain-session
IncludedSession management and project status dashboard. Owns the full session lifecycle (start/work/close/resume), focus lane, bookmarks, worktree detection, and tab naming. Also serves as the project status dashboard โ shows active epics, progress, actionable next steps, blocked items, tasks, GitHub issues, and recommendations. Worktree creation is deferred to swain-do task dispatch (SPEC-195). Triggers on: 'session', 'status', 'what's next', 'dashboard', 'overview', 'where are we', 'what should I work on', 'show me priorities', 'bookmark', 'focus on', 'session info'.
gandi
IncludedComprehensive Gandi domain registrar integration for domain and DNS management. Register and manage domains, create/update/delete DNS records (A, AAAA, CNAME, MX, TXT, SRV, and more), configure email forwarding and aliases, check SSL certificate status, create DNS snapshots for safe rollback, bulk update zone files, and monitor domain expiration. Supports multi-domain management, zone file import/export, and automated DNS backups. Includes both read-only and destructive operations with safety controls.