V2
Query Database
Query database page records with filters, sorts, and pagination.
Query Database
Use Case
Use this endpoint to list database records as pages, optionally filtered, sorted, and paginated.
Endpoint
| Item | Value |
|---|---|
| Method | POST |
| Path | /v2/databases/:database_id/query |
| Request body | JSON |
| Returns | list of page objects |
| Scope | databases.read |
Permissions
Requires databases.read and access to the database.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
database_id |
string | Yes | Database ID. |
view_id |
string | No | Query with this view's configuration: the view's page_sort provides manual ordering and the filter/sorters saved in the view act as the base; explicit request filter/sorts override them respectively. |
filter |
object | No | Database filter object. |
sorts |
array | No | Sort definitions. |
start_cursor |
string | No | Pagination cursor. |
page_size |
number | No | Defaults to 20; maximum is 100. |
Request Example
{
"filter": {
"property": "Status",
"select": {
"equals": "Doing"
}
},
"sorts": [
{
"property": "Name",
"direction": "ascending"
}
],
"start_cursor": null,
"page_size": 20
}
Response Example
{
"object": "list",
"results": [
{
"object": "page",
"id": "11111111-1111-4111-8111-111111111111",
"page_type": "page",
"created_time": "2026-04-09T08:00:00.000Z",
"last_edited_time": "2026-04-09T09:30:00.000Z",
"created_by": {
"object": "user",
"id": "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"
},
"last_edited_by": {
"object": "user",
"id": "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"
},
"parent": {
"type": "page_id",
"page_id": "55555555-5555-4555-8555-555555555555"
},
"in_trash": false,
"icon": null,
"cover": null,
"properties": {
"title": {
"id": "title",
"type": "title",
"title": [
{
"type": "text",
"text": {
"content": "Release Checklist",
"link": null
},
"plain_text": "Release Checklist",
"href": null
}
]
}
},
"url": "https://buildin.ai/docs/11111111-1111-4111-8111-111111111111"
}
],
"next_cursor": null,
"has_more": false
}
Behavior
- Results are
pageobjects because database records are pages. - Filters and sorts must match the database property schema.
- Unsupported filters or sorts return explicit errors.
- Use
next_cursorandhas_morefor pagination.
View queries (view_id)
- When
view_idis provided, the server applies the view configuration with web-client semantics: the view'ssorterssort first,page_sortbreaks ties, and the view'sfilteris evaluated in memory. - Explicit request
filter/sortsoverride the view configuration respectively (they do not merge). - Known evaluator limitations:
formula/rollupconditions are skipped like invalid conditions; page-link and person segments in text conditions render as@<uuid>. See Get Database View for the stored structure contract. - Cursors are bound to the effective configuration signature (request filter + sorts + view version). If any of them changes between pages, the next page returns
409 conflictand the query must be restarted with a fresh cursor.
Errors
400 validation_error: invalid filter, sort, pagination shape, orview_id.400 unsupported_filter: unsupported filter type.400 unsupported_sort: unsupported sort type.401 unauthorized: invalid or expired token.403 forbidden: missingdatabases.reador no access.404 not_found: database or view does not exist.409 conflict: the effective filter, sorts, or view configuration changed during pagination.