Skip to main content
A data source is a table of pages under a Notion database. For background on how databases and data sources fit together, see Working with databases. Log in to the CLI before you start.

Find a data source ID

Set DATABASE_ID to the ID of the parent database. List its data sources with this command.
Find your data source in the response’s data_sources array and set DATA_SOURCE_ID to its id. In Notion, you can also find the ID under Manage data sources in the database settings. Open the data source’s ••• menu and select Copy data source ID.

Retrieve a data source

Fetch the schema (properties, title, parent) for a single data source. See Retrieve a data source for the response shape:

Create a data source

To add a data source, pass the parent database ID and define each column in properties. See Create a data source for the full list of fields.
A default “table” view is created alongside the data source. See Working with views to learn about managing views.

Query a data source

Use ntn datasources query to list pages in a data source:
Pass --filter with the same shape documented in Filter data source entries:
Paginate with --start-cursor using the next_cursor from the previous response. Add --json for machine-readable output. To use the query endpoint directly, pass the filter and sort order in the request body.
To return fewer columns, pass filter_properties once for each property name or ID you need.
While has_more is true, pass next_cursor as start_cursor in the next request. If your query reaches the 10,000-result limit, follow Query large data sources to read the remaining pages.

Update a data source

PATCH updates the title, description, parent, or schema. To add a column, pass it under properties keyed by name:
To rename or remove a property, key it by its existing name and pass either a new name or null:
See Update a data source for the full list of editable fields and properties that can’t be changed via the API.

List page templates

List the page templates that show up in a data source’s New dropdown. See List data source templates for the response shape:
Set TEMPLATE_ID to a template ID from the response, then retrieve the page:

Discover the endpoints

To see the request schema or jump to the docs for any of these commands: