Skip to main content
Use this guide to add a page to an existing data source. The example creates a grocery item with a name, price, and order date.

Get access and the data source ID

Your connection needs insert content capabilities and access to the parent database. The schema check also needs read content capabilities. In Notion, open the database’s ••• menu and add the connection through Add connections. Use Retrieve a database to list its data_sources. Choose the ID of the source you want. You can also copy a data source ID from Manage data sources in Notion. Set NOTION_API_KEY and NOTION_DATA_SOURCE_ID in your server’s environment. Tokens must not appear in browser page source, client bundles, or public repositories. The JavaScript example uses the Notion SDK in a Node.js project.

Check the schema

Retrieve the data source. Check its properties map for these names and types, or adjust the request to match your source: Use Update data source properties if you need to add or rename a property. Each data source must have one Name property (title).

Create the page

Set parent.data_source_id and supply the page values in properties. Property names or IDs can be used as keys. The JavaScript example checks the schema before creating the page. Save it as create-page.mjs and run node create-page.mjs.
The response contains the new page’s id. Save it if you need to update its properties later. Running this example again creates another page.

Handle failures

For a 400 validation error, check that each name and value matches the current schema. For a 403, check the connection’s capabilities. For a 404, check the data source ID and database sharing settings. If a request times out, check whether the page was created before retrying. Repeating a create request can create a duplicate.