Skip to content

Notion: Query a data source

Notion dataSources.postDatabaseQuery: arguments, response, policy and SDK examples.

← Data sources operations · Get started

Operation notion.post_database_query

Provider route: POST /v1/data_sources/{data_source_id}/query. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/notion with npm, or alter-sdk-notion with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { NotionIntegration } from "@alter-ai/notion";
async function execute(input: Parameters<NotionIntegration["dataSources"]["postDatabaseQuery"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new NotionIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.dataSources.postDatabaseQuery(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_notion import NotionIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = NotionIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.data_sources.post_database_query(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.data_source_idstringRequired within parent
queryobjectOptionalAdditional keys: not allowed
query.filter_propertiesarrayOptionalProperty names or IDs to include in each page’s `properties` object. Other properties are left out. Repeat the parameter to pass more than one value, for example `filter_properties=title&filter_properties=Status`. Pages that aren’t in a data source always return only `title`.
query.filter_properties[]stringEach item
bodyobjectRequired within parentAdditional keys: not allowed
body.filterModelOptionalExpand Query a data source — request body — body filter
body.is_archivedbooleanOptionalWhether to return archived pages. When omitted or false, returns non-archived pages. When true, returns archived pages.
body.page_sizeintegerOptionalMinimum: 1
body.result_typestringOptionalOptionally filter the results to only include pages or data sources. Regular, non-wiki databases only support page children. The default behavior is no result type filtering, in other words, returning both pages and data sources for wikis.
One of: page, data_source
body.sortsarrayOptional
body.sorts[]ModelEach itemExpand Query a data source — request body — body sorts item
body.start_cursorstringOptional

Referenced models: Query a data source — request body — body filter, Query a data source — request body — body sorts item

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Search by title — response body

Referenced models: Search by title — response body

151 more schemas are linked from the tables above, on the schema pages.

Search by title — response body
FieldTypePresenceDescription and constraints
$objectRoot
has_morebooleanRequired within parent
next_cursorJSONRequired within parent
next_cursor (anyOf 1)stringAlternative
next_cursor (anyOf 2)nullAlternative
objectstringRequired within parentMust equal: list
page_or_data_sourceModelRequired within parentExpand List views — response body — view
request_statusobjectOptional
request_status.incomplete_reasonstringOptionalKnown values: query_result_limit_reached
request_status.typestringRequired within parentKnown values: complete, incomplete
resultsarrayRequired within parent
results[]JSONEach item
results[] (anyOf 1)JSONAlternative
results[] (anyOf 1) (anyOf 1)ModelAlternativeExpand Update page — response body — object page — page Object Response
results[] (anyOf 1) (anyOf 2)ModelAlternativeExpand Update page — response body — object page — partial Page Object Response
results[] (anyOf 2)JSONAlternative
results[] (anyOf 2) (anyOf 1)ModelAlternativeExpand Create a data source — response body — object data source — partial Data Source Object Response
results[] (anyOf 2) (anyOf 2)ModelAlternativeExpand Create a data source — response body — object data source — data Source Object Response
typestringRequired within parentMust equal: page_or_data_source

Referenced models: List views — response body — view, Create a data source — response body — object data source — data Source Object Response, Update page — response body — object page — page Object Response, Create a data source — response body — object data source — partial Data Source Object Response, Update page — response body — object page — partial Page Object Response

Query a data source — request body — body filter
FieldTypePresenceDescription and constraints
$JSONRootA property filter, timestamp filter, or compound and/or filter.
$ (anyOf 1)JSONAlternative
$ (anyOf 1) (anyOf 1)objectAlternative
$ (anyOf 1) (anyOf 1).orModelRequired within parentExpand Query a data source — request body — body filter value or or
$ (anyOf 1) (anyOf 2)objectAlternative
$ (anyOf 1) (anyOf 2).andModelRequired within parentExpand Query a data source — request body — body filter value or or
$ (anyOf 2)ModelAlternativeExpand Query a data source — request body — body filter value — property Filter
$ (anyOf 3)ModelAlternativeExpand Query a data source — request body — body filter value — timestamp Filter

Referenced models: Query a data source — request body — body filter value or or, Query a data source — request body — body filter value — property Filter, Query a data source — request body — body filter value — timestamp Filter

Query a data source — request body — body sorts item
FieldTypePresenceDescription and constraints
$JSONRootSort by property name or ID, or by timestamp.
$ (anyOf 1)objectAlternative
$ (anyOf 1).directionstringRequired within parentOne of: ascending, descending
$ (anyOf 1).propertystringRequired within parent
$ (anyOf 2)objectAlternative
$ (anyOf 2).directionstringRequired within parentOne of: ascending, descending
$ (anyOf 2).timestampstringRequired within parentOne of: created_time, last_edited_time
List views — response body — view
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: allowed
Update page — response body — object page — page Object Response
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: allowed
coverJSONRequired within parentPage cover image.
cover (anyOf 1)ModelAlternativeExpand Update page — response body — object page cover value
cover (anyOf 2)nullAlternative
created_byModelRequired within parentExpand Update page — response body — object page created by
User who created the page.
created_timestringRequired within parentDate and time when this page was created.
Format: date-time
iconJSONRequired within parentPage icon.
icon (anyOf 1)ModelAlternativeExpand Get agent — response body — icon value
icon (anyOf 2)nullAlternative
idstringRequired within parentThe ID of the page.
Format: uuid
in_trashbooleanRequired within parentWhether the page is in trash.
is_archivedbooleanRequired within parentWhether the page has been archived.
is_lockedbooleanRequired within parentWhether the page is locked from editing in the Notion app UI.
last_edited_byModelRequired within parentExpand Update page — response body — object page created by
User who last edited the page.
last_edited_timestringRequired within parentDate and time when this page was last edited.
Format: date-time
objectstringRequired within parentThe page object type name.
Must equal: page
parentModelRequired within parentExpand Update page — response body — object page parent
Information about the page's parent.
propertiesobjectRequired within parentProperty values of this page.
Additional keys: see wildcard field
properties.*ModelAdditional keysExpand Update page — response body — object page properties value
public_urlJSONRequired within parentThe public URL of the Notion page, if it has been published to the web.
public_url (anyOf 1)stringAlternative
public_url (anyOf 2)nullAlternative
urlstringRequired within parentThe URL of the Notion page.

Referenced models: Update page — response body — object page cover value, Get agent — response body — icon value, Update page — response body — object page properties value, Update page — response body — object page parent, Update page — response body — object page created by

Create a data source — response body — object data source — partial Data Source Object Response
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: allowed
idstringRequired within parentThe ID of the data source.
Format: uuid
objectstringRequired within parentThe data source object type name.
Must equal: data_source
propertiesobjectRequired within parentThe properties schema of the data source.
Additional keys: see wildcard field
properties.*ModelAdditional keysExpand Create a data source — response body — object data source properties value

Referenced models: Create a data source — response body — object data source properties value

Update page — response body — object page — partial Page Object Response
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: allowed
idstringRequired within parentThe ID of the page.
Format: uuid
objectstringRequired within parentThe page object type name.
Must equal: page
Query a data source — request body — body filter value — timestamp Filter
FieldTypePresenceDescription and constraints
$JSONRoot
$ (anyOf 1)ModelAlternativeExpand Query a data source — request body — body filter value Created Time
$ (anyOf 2)ModelAlternativeExpand Query a data source — request body — body filter value Last Edited Time

Referenced models: Query a data source — request body — body filter value Created Time, Query a data source — request body — body filter value Last Edited Time

SDK function policy ID: notion.post_database_query. Catalog operation: post_database_query. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"Notion-Version": "2026-03-11"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.