Skip to main content

Run document queries with the Query API

The List document queries API provides information about documents and their associated queries. You can use these queries to programmatically run a document’s saved queries, either directly or after modifying them.
If you just need to run one saved query, the Run a saved document query API is a simpler alternative to the steps below — it runs the query directly from the document, optionally scoped with filters, without extracting and resubmitting the query JSON.

Requirements

To follow the steps in this guide, you’ll need an Omni API key.

Run a saved query directly

Use the Run a saved document query API to run one of a document’s saved queries in a single call. The query is read from the document on the server, so you only need the document identifier and the query’s queryIdentifierMapKey or presentation ID. Unlike the Run query API, this endpoint doesn’t require Restricted Querier permissions — it runs at the same access level the document itself grants the authenticating user.
POST /api/v1/documents/:documentId/queries/:queryId/run

Modify a query before running it

If you need to change a saved query before running it, such as adding fields, filters, or sorts, retrieve the query’s definition and submit it to the Run query API. This path requires Restricted Querier permissions or higher, since it can run any query definition you send it.
1

Retrieve the document's queries

GET /api/v1/documents/:documentId/queries
2

Extract a query object from the response

The query objects returned by the Document Queries API are already structured in the format required by the Query API, making it easy to run these queries programmatically without having to manually build the query structure.
3

Modify and run the query

Change the query object as needed, then use it with the Run query API to run it:
POST /api/v1/query/run