> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/api/rest-api/queries/post.md).

# post

## Overview

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

{% hint style="warning" %}
Note that API-initiated queries are subject to certain [quotas and limits](/reference/platform-essentials/quotas-and-limits.md#queries).
{% 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="/api/referencing-resources.md">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="/api/referencing-resources.md">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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
