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.
Call through Alter
Section titled “Call through Alter”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 osfrom alter_sdk import Appfrom 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()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.data_source_id | string | Required within parent | |
query | object | Optional | Additional keys: not allowed |
query.filter_properties | array | Optional | Property 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[] | string | Each item | |
body | object | Required within parent | Additional keys: not allowed |
body.filter | Model | Optional | Expand Query a data source — request body — body filter |
body.is_archived | boolean | Optional | Whether to return archived pages. When omitted or false, returns non-archived pages. When true, returns archived pages. |
body.page_size | integer | Optional | Minimum: 1 |
body.result_type | string | Optional | Optionally 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.sorts | array | Optional | |
body.sorts[] | Model | Each item | Expand Query a data source — request body — body sorts item |
body.start_cursor | string | Optional |
Referenced models: Query a data source — request body — body filter, Query a data source — request body — body sorts item
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Search by title — response body |
Referenced models: Search by title — response body
Schemas
Section titled “Schemas”151 more schemas are linked from the tables above, on the schema pages.
Search by title — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
has_more | boolean | Required within parent | |
next_cursor | JSON | Required within parent | |
next_cursor (anyOf 1) | string | Alternative | |
next_cursor (anyOf 2) | null | Alternative | |
object | string | Required within parent | Must equal: list |
page_or_data_source | Model | Required within parent | Expand List views — response body — view |
request_status | object | Optional | |
request_status.incomplete_reason | string | Optional | Known values: query_result_limit_reached |
request_status.type | string | Required within parent | Known values: complete, incomplete |
results | array | Required within parent | |
results[] | JSON | Each item | |
results[] (anyOf 1) | JSON | Alternative | |
results[] (anyOf 1) (anyOf 1) | Model | Alternative | Expand Update page — response body — object page — page Object Response |
results[] (anyOf 1) (anyOf 2) | Model | Alternative | Expand Update page — response body — object page — partial Page Object Response |
results[] (anyOf 2) | JSON | Alternative | |
results[] (anyOf 2) (anyOf 1) | Model | Alternative | Expand Create a data source — response body — object data source — partial Data Source Object Response |
results[] (anyOf 2) (anyOf 2) | Model | Alternative | Expand Create a data source — response body — object data source — data Source Object Response |
type | string | Required within parent | Must 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | A property filter, timestamp filter, or compound and/or filter. |
$ (anyOf 1) | JSON | Alternative | |
$ (anyOf 1) (anyOf 1) | object | Alternative | |
$ (anyOf 1) (anyOf 1).or | Model | Required within parent | Expand Query a data source — request body — body filter value or or |
$ (anyOf 1) (anyOf 2) | object | Alternative | |
$ (anyOf 1) (anyOf 2).and | Model | Required within parent | Expand Query a data source — request body — body filter value or or |
$ (anyOf 2) | Model | Alternative | Expand Query a data source — request body — body filter value — property Filter |
$ (anyOf 3) | Model | Alternative | Expand 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | Sort by property name or ID, or by timestamp. |
$ (anyOf 1) | object | Alternative | |
$ (anyOf 1).direction | string | Required within parent | One of: ascending, descending |
$ (anyOf 1).property | string | Required within parent | |
$ (anyOf 2) | object | Alternative | |
$ (anyOf 2).direction | string | Required within parent | One of: ascending, descending |
$ (anyOf 2).timestamp | string | Required within parent | One of: created_time, last_edited_time |
List views — response body — view
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: allowed |
Update page — response body — object page — page Object Response
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: allowed |
cover | JSON | Required within parent | Page cover image. |
cover (anyOf 1) | Model | Alternative | Expand Update page — response body — object page cover value |
cover (anyOf 2) | null | Alternative | |
created_by | Model | Required within parent | Expand Update page — response body — object page created by User who created the page. |
created_time | string | Required within parent | Date and time when this page was created. Format: date-time |
icon | JSON | Required within parent | Page icon. |
icon (anyOf 1) | Model | Alternative | Expand Get agent — response body — icon value |
icon (anyOf 2) | null | Alternative | |
id | string | Required within parent | The ID of the page. Format: uuid |
in_trash | boolean | Required within parent | Whether the page is in trash. |
is_archived | boolean | Required within parent | Whether the page has been archived. |
is_locked | boolean | Required within parent | Whether the page is locked from editing in the Notion app UI. |
last_edited_by | Model | Required within parent | Expand Update page — response body — object page created by User who last edited the page. |
last_edited_time | string | Required within parent | Date and time when this page was last edited. Format: date-time |
object | string | Required within parent | The page object type name. Must equal: page |
parent | Model | Required within parent | Expand Update page — response body — object page parent Information about the page's parent. |
properties | object | Required within parent | Property values of this page. Additional keys: see wildcard field |
properties.* | Model | Additional keys | Expand Update page — response body — object page properties value |
public_url | JSON | Required within parent | The public URL of the Notion page, if it has been published to the web. |
public_url (anyOf 1) | string | Alternative | |
public_url (anyOf 2) | null | Alternative | |
url | string | Required within parent | The 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: allowed |
id | string | Required within parent | The ID of the data source. Format: uuid |
object | string | Required within parent | The data source object type name. Must equal: data_source |
properties | object | Required within parent | The properties schema of the data source. Additional keys: see wildcard field |
properties.* | Model | Additional keys | Expand 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: allowed |
id | string | Required within parent | The ID of the page. Format: uuid |
object | string | Required within parent | The page object type name. Must equal: page |
Query a data source — request body — body filter value — timestamp Filter
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | |
$ (anyOf 1) | Model | Alternative | Expand Query a data source — request body — body filter value Created Time |
$ (anyOf 2) | Model | Alternative | Expand 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
Policy, approvals and errors
Section titled “Policy, approvals and errors”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"}