Documentation Index
Fetch the complete documentation index at: https://docs.omni.co/llms.txt
Use this file to discover all available pages before exploring further.
The Document queries API provides information about documents and their associated queries. You can use these queries directly with the Run query API to programmatically run the document’s queries.
Requirements
To follow the steps in this guide, you’ll need an Omni API key.
Steps
Retrieve the document's queries
GET /api/v1/documents/:id/queries
curl -L'https://<your-omni-org>.omniapp.co/api/v1/documents/12db1a0a/queries' \
-H 'Authorization: Bearer <TOKEN>'
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.const document = response.body;
const queryObject = document.queries[0].query;
Run the query
Use the query object directly with the Run query API to run the query:curl -L -X POST 'https://<your-omni-org>.omniapp.co/api/v1/query/run' \
-H 'Authorization: Bearer <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"query": {
"limit": 1000,
"sorts": [
{
"column_name": "order_items.created_at[month]",
"sort_descending": false
}
],
"table": "order_items",
"fields": [
"order_items.created_at[month]",
"order_items.sale_price_sum"
],
"filters": {},
"modelId": "7155f419-a071-405c-8426-b4b5d3939049"
}
}'