Skip to content

Add a Notion template generated from Notion's OpenAPI description - #463

Merged
tnkuehne merged 2 commits into
managed-oauth-scopeless-basic-revocationfrom
notion-template
Nov 28, 2026
Merged

tnkuehne merged 2 commits into
managed-oauth-scopeless-basic-revocationfrom
notion-template

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Change

A Notion template.

  • 61 methods for Notion's API in version 2026-03-11, generated from Notion's published OpenAPI description (https://developers.notion.com/openapi.json):
    • users, search, pages, page properties and page Markdown, async tasks
    • blocks, databases, data sources, data source templates, views and view queries
    • comments, file uploads, custom emojis, AI meeting notes from recordings
    • Custom Agents, their sessions and events, Agent Skills plugins and skills
  • streamSessionMessage sends a session message with Accept: text/event-stream and answers with the turn's events (session.snapshot, event.provisional, event.committed, stream.timeout, stream.end, stream.error), and replays a turn from a committed event with continue_from.
  • getPageProperty sends property IDs as Notion returned them, URL-encoded.
  • Every method takes an optional notionBeta for Notion's opt-in betas, such as status-group-filters-2026-10-06.
  • Not offered, because they do not work with the person's OAuth token:
    • the OAuth endpoints, which take the OAuth client's credentials
    • deleting a Custom Agent, changing its credit limit, creating a full-page meeting note and linking it to a calendar event, which take a personal access token or a Notion Worker
    • Notion's Admin API, which takes an organization bot token
  • updateAgentStatus offers the deprecated agent status endpoint, which Notion still serves.
  • Errors keep Notion's code, message, request_id and additional_data. A write that was saved although its answer timed out returns its retry_guidance and committed_resource_id.
  • 429 and 529 return rate_limited with Retry-After. A connection Notion blocked (public_api_request_blocked) returns Notion's error instead.

Connection.

  • Each person connects their own Notion account through Better Auth's Notion provider and chooses the pages to share in Notion's page picker.
  • An installation's managed notion client is used when present; it needs Allow managed OAuth clients without scopes and with HTTP Basic revocation #467, which this PR builds on. Otherwise the app asks for NOTION_CLIENT_ID and NOTION_CLIENT_SECRET of the organization's own OAuth integration.

Generator.

  • A header the description requires with one allowed value, such as Notion-Version, is sent on every request instead of being an input (fixedHeaders). The generated types describe that version.
  • A fixed header's value may come from a referenced schema.
  • encodedPathParameters names path parameters the API hands out URL-encoded; the runtime sends them as they are when they hold only unreserved characters and percent escapes.
  • A union lists no string values next to a named type of any string, such as Notion's IdRequest | "notion_ai".
  • The shared rest.ts sends the fixed headers; the other REST templates get the updated copy.

Screenshots

The connection page. The favicon is Notion's own icon from notion.com.

Setup required Not connected Connected
1280 px, light
1280 px, dark
390 px, light
390 px, dark

Not shown: the connection error alert.

Tests

  • Template tests: streamed session turns, encoded property IDs, connection, Notion-Version and Notion-Beta headers, cursor pages, user and issuer isolation, approvals, multipart uploads with binary bytes, reconnecting the same Notion user, Notion's errors, rate limits, overload and saved-but-timed-out writes.
  • Managed OAuth tests for the Notion client: authorization, exchange, refresh and revocation with HTTP Basic client authentication.
  • Generator tests for fixed headers, referenced header schemas, encoded path parameters and unions with named string types.
  • pnpm check, all template tests, the generator tests and the app runtime's OAuth tests.
  • Regenerating from the downloaded description reproduces the committed files.

Live against Notion (an OAuth integration in a workspace on the free plan):

  • Connecting through OAuth with the organization's own client.
  • Users, search, pages, page properties, page Markdown and async tasks, blocks, databases, data sources, views and view queries, comments, single-part file uploads, custom emojis, Agent Skills plugin listing and download. Test data with non-ASCII text and a PNG with binary bytes, which downloaded identically.
  • getPageProperty with property IDs as Notion returned them, URL-encoded (%5BT%40s, %3BaJY, %5CCab and others), for every property type of a test database, with non-ASCII names and values. Notion also accepts the IDs encoded a second time; the template sends them as Notion's reference and SDK do.
  • Refresh and revocation with HTTP Basic, and their rejection with credentials in the form. Notion revokes an access token and the tokens issued before it, and answers a refresh token without revoking anything, so disconnecting revokes the current access token; afterwards every access and refresh token of the grant is rejected. A revoked token returns reconnect_required.

Not run live, because the test workspace does not offer them:

  • Custom Agents and sessions: the test integration had no agent capabilities (403).
  • uploadSkill: the workspace's only skill is in use.
  • Multi-part uploads (completeFileUpload) and createMeetingNote: not available on the free plan.
  • The managed client, which the hosted installation configures after this is released.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 4011496 Nov 28 2026, 05:27 PM

@tnkuehne
tnkuehne marked this pull request as ready for review November 28, 2026 14:47
@tnkuehne
tnkuehne changed the base branch from main to managed-oauth-scopeless-basic-revocation November 28, 2026 16:40
@tnkuehne
tnkuehne added this pull request to stack #468 November 28, 2026 16:40
@tnkuehne
tnkuehne force-pushed the notion-template branch 2 times, most recently from eef8e91 to 2332048 Compare November 28, 2026 16:58
The template offers Notion's API for the person who connects their account:
pages and their content, databases, data sources and views, comments, file
uploads, meeting notes, Custom Agents and their sessions, and Agent Skills.
streamSessionMessage reads a session turn as Notion's server-sent events.

The generator sends a header the description requires with one allowed value,
such as Notion-Version, on every request instead of taking it as an input,
also when the value comes from a referenced schema; sends the path parameters
a rule names as the API encoded them, such as Notion's property IDs; and
leaves out the string values a union lists next to a named type of any string.
Notion revokes an access token and the tokens issued before it, and answers a
refresh token without revoking anything (checked against Notion). The managed
OAuth fixture answers Notion's refresh tokens the same way.
@tnkuehne
tnkuehne merged commit abb05e4 into main Nov 28, 2026
15 of 16 checks passed
@tnkuehne
tnkuehne deleted the notion-template branch November 28, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant