# post

## Overview

This endpoint is used for executing SQL queries against data stored in Redivis.

{% hint style="warning" %}
API queries are designed for interactive exploration of data on Redivis, and should not be used for ETL operations or real-time analysis of very large tables. \
\
All users are subject to a moving 24-hour computational limit for interactive queries of 100,000 compute slot-seconds. To avoid exceeding this limit, make sure to first transform your data on Redivis.\
\
Each user is also limited to 5 simultaneous query jobs. Additional queries will automatically be enqueued and then dequeued as outstanding query jobs finish.
{% endhint %}

## HTTP Request

```http
POST /api/v1/queries
```

{% hint style="info" %}
This endpoint extends the [general API structure](/api/rest-api/general-structure.md)
{% endhint %}

## Request body

Provide a JSON object with information about the dataset.

<table><thead><tr><th width="187.1484375">Property name</th><th width="150.29427083333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong>query</strong></td><td><strong>string</strong></td><td><p><strong>Required.</strong> The SQL query, following the standard Redivis SQL syntax. All table references in the query must be fully qualified, unless a <code>defaultWorkflow</code> or <code>defaultDataset</code> is provided (see below).</p><p></p><p>The query cannot be more than 256k characters.</p></td></tr><tr><td><strong>timeoutMs</strong></td><td><strong>integer</strong></td><td><strong>Optional, defaults to 30,000.</strong> The maximum amount of time, in milliseconds, the request should wait for the query to finish. <br><br>If the timeout is exceeded and the query is still running, the query will be returned with a status of <code>"running"</code> , and you will need to poll the query until its status is <code>"completed"</code> or <code>"failed"</code>. <br><br>The timeout must be between 0 and 60,000. It is generally simpler and more performant to have a higher timeout, as opposed to receiving a running query and then polling that for completion.</td></tr><tr><td><strong>defaultWorkflow</strong></td><td><strong>string</strong></td><td><p><strong>Optional.</strong>  Cannot be present if <code>defaultDataset</code> is specified.</p><p></p><p>Should be specified as the fully qualified <a href="/pages/-LzsPrAlHWxazTnhQQJE">workflow reference</a>. Any tables in your query that aren't fully qualified will be assumed to be a part of this workflow. </p></td></tr><tr><td><strong>defaultDataset</strong></td><td><strong>string</strong></td><td><p><strong>Optional.</strong> Cannot be present if <code>defaultWorkflow</code> is specified.  </p><p></p><p>Should be specified as the fully qualified <a href="/pages/-LzsPrAlHWxazTnhQQJE">dataset reference</a>. Any tables in your query that aren't fully qualified will be assumed to be a part of this dataset.</p></td></tr></tbody></table>

## Authorization

Data access to all tables referenced by the query is required. If a table's data is not public, your access token must have one of the following scopes:

* data.data
* data.edit

[Learn more about authorization.](/api/rest-api/authorization.md)

## Response body

Returns the JSON-encoded "get" representation of a [query resource](/api/resource-definitions/query.md#get).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redivis.com/api/rest-api/queries/post.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
