Skip to main content
Custom blocks are in private alpha:
  • Do not discuss publicly or share with anyone outside your workspace.
  • Access must be enabled per workspace. Installing the SDK does not grant access.
  • These APIs may experience breaking changes without notice.

worker.customBlock()

Registers a custom block: a custom interface that Notion embeds in a page and provides data. See the custom blocks quickstart for a walkthrough of building, previewing, and deploying one. Unlike other worker capabilities, a custom block has no execute handler — its code runs in the browser, not the Workers runtime, so there is nothing to invoke with ntn workers exec. During ntn workers deploy, the configured source directory is built and published alongside the worker.
Data source and property keys are names you choose. The property keys match their types in the example above, but they do not need to. For example, the first property key could be name or Title. The type field defines the kind of data the property holds and uses Notion Public API type names. The declaration key appears in deploy output, so choose a stable value. When slashCommand is set, members who can connect to the worker see the custom block in the slash menu after deployment. Custom blocks in different workers can share a slash command name. Within one worker, each custom block slash command must be unique. The registered slash command does not appear on mobile. The configuration UI uses the block key when name is absent. Without icon, Notion uses the default custom-block icon. Without description, the configuration UI omits the description. The slash menu preserves its command label and worker details when metadata is absent. You can search by display name, slash command, block key, or worker name. Deploy an existing worker again with an SDK version that supports these fields to populate its metadata.

Block sources

The default "project" source is built during deploy, running command in path and uploading output, as in the example above. A "static" source is instead a directory of already-built browser assets, uploaded as-is with no build step. command and output do not apply:

Remove or rename a custom block

Each Worker deployment reconciles the declared custom block keys with the previous deployment. If you remove a worker.customBlock() declaration, Notion soft-deletes that block definition. Deleting the Worker soft-deletes all its custom block definitions. Changing a block key removes the old definition and creates a new one. Existing block instances stay connected to the old key and stop rendering their custom interface. To recover from an accidental removal or rename, add the worker.customBlock() declaration with its original key. Then deploy the Worker again. For 30 days after removal, Notion retains the definition and its deployments. Redeploying the same key on the same Worker in the same workspace restores the definition during this period. Existing block instances can then render again. After 30 days, Notion permanently deletes the retained definition, deployment records, and bundles. After permanent deletion, redeploying the same key on the same Worker in the same workspace recreates the definition with the same ID. Existing instances can render the new deployment. You cannot recover the deleted deployment history. Choose stable block keys. Repeated deployments without the removed key do not restart the 30-day retention period.

Data source schemas

dataSources declares what Notion data the block expects to read. Each entry describes a shape, not a specific data source — the person configuring a block instance in Notion binds each declaration to a concrete Notion data source. The worker never names one.
Property type accepts the Notion property types: title, rich_text, number, select, multi_select, status, date, people, files, checkbox, url, email, phone_number, formula, relation, rollup, created_time, created_by, last_edited_time, last_edited_by, last_visited_time, button, unique_id, location, verification, and place. Supported property types vary by operation. See supported filters, sorts, and updates. See the data sources reference for querying and updating rows.