Skip to main content

Overview

The pull command generates or updates the configured TypeScript schema from the databases registered in your NotCMS workspace.
init already performs the first pull. Run this standalone command after a database or its properties change.

What it does

  1. Loads NOTCMS_SECRET_KEY and NOTCMS_WORKSPACE_ID
  2. Fetches the current workspace schema from NotCMS
  3. Generates the configured schema module and its nc client
  4. Prints a query for the first database

Options

--check exits with code 1 when the generated file is missing or out of date, which makes it suitable for CI/CD.

Examples

Update the schema

Load credentials from a custom env file

Check without writing

Generated schema

The command generates both the typed schema and a ready-to-use client:
You can add a package script for later updates:

Schema change summary

A normal pull compares the previous generated schema and reports added or removed databases, changed database IDs, and added, removed, or changed property types. Missing or unsupported manually edited schemas are skipped for comparison and are never executed. --check never writes the file. It omits the summary when the file is current and prints semantic changes when it is stale. Stale pull --check also prints the semantic summary without writing. The first pull and an unsupported previous schema file have distinct messages. Comparison never executes the local module.

Choice types

The CLI automatically requests choice metadata with ?include=options. Older CLIs keep receiving schemas without options, so their generated modules remain compatible with older SDKs. The optional per-database options field contains names for select, status, and multi_select properties. Generated schemas use as const satisfies Schema, so a select or status with options: { language: ["en", "ja"] } becomes "en" | "ja" | null. A multi-select becomes ("en" | "ja")[] | null. These choices also constrain where operands. A known empty option list yields null for select/status and never[] | null for multi-select. Older schemas without options retain string | null or string[] | null. The API omits options until metadata has been fetched; normal database sync or the service backfill populates it. After changing options in Notion, sync the database and run notcms pull again. Pull reports added and removed choices, including metadata becoming available. Types describe the pulled snapshot; the SDK does not coerce or discard an unknown runtime value. Check schemas in CI