Notion API filter exclusion of formula, rollup, and relation properties forces client-side filtering
0 reputation · 12 Jan 2021, 08:04 UTC
0 reputation · 12 Jan 2021, 08:04 UTC
The Notion API's query database endpoint accepts filter objects for a defined set of property types — title, rich_text, number, select, multi_select, date, checkbox, url, email, phone_number, created_time, last_edited_time, created_by, and last_edited_by. Formula, rollup, and relation properties are not included in this allowlist. Attempting to filter on any of these computed properties returns a 400 error, so applications that need to query pages based on derived values must retrieve the full database (or a broad superset) and filter locally.
Client-side filtering works for small databases but becomes impractical once the page count exceeds a few thousand because of Notion's rate limits (3 requests/second per integration) and the 100-page pagination limit. A full scan of a 10,000-page database can take minutes and risks timeouts. Relation properties can be partially worked around by querying the related database first, but this adds round-trips and does not help with formula or rollup results that depend on timezone or locale. The Notion team has acknowledged the feature request, but no public roadmap entry confirms when — or if — computed-property filters will be added.
35275 reputation · 12 Jan 2021, 15:48 UTC
Because the Notion API returns a 400 error when filtering on formula, rollup, or relation properties, teams dealing with datasets larger than a few thousand pages typically move away from real-time API querying in favor of Data Mirroring.
The most reliable pattern for maintaining low latency is synchronizing Notion data to an external indexed database (such as PostgreSQL, MongoDB, or Elasticsearch). In this architecture:
For relation properties specifically, you can reduce the payload size by performing a two-step query:
There is currently no dedicated metadata endpoint to check if a property type has become filterable. The only reliable way to detect this at runtime is to attempt a scoped query (e.g., a query with a limit of 1) using the property in a filter. If the API returns a 400 error, the property remains unsupported. If it returns a 200, the feature has been deployed.
Querying a target database and then joining those results with a source database on the client side introduces Eventual Consistency risks. Because these are separate HTTP requests, the following can occur:
To mitigate this, treat client-side joins as "best effort" and implement a validation step to handle null or missing references gracefully.
To confirm your current API version's behavior, attempt a query against a formula property using curl:
curl -X POST https://api.notion.com/v1/databases/{database_id}/query \
-H "Authorization: Bearer {token}" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
--data '{"filter": {"property": "Your Formula Property", "formula": {"string_contains": "Value"}}}'
A 400 Bad Request confirms that the property is not filterable.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.