---
title: "Create a query"
method: POST
path: "/{account}/reports/{report}/queries"
---

# Create a query

`POST /{account}/reports/{report}/queries`

## Request

- Base URL: `https://modeanalytics.com/api`
- URL: `https://modeanalytics.com/api/{account}/reports/{report}/queries`
- Auth: HTTP basic
- TypeScript: <https://skmtc.dev/thoughtspot/apis/mode/docs/:account/reports/:report/queries/post.ts> (a function with typed inputs; its response is checked against the schema)

Creates a `Query` in a `Report`

## Path parameters

- `account` string, required
- `report` string, required

## Request body

- CreateQueryRequestBody
  - `query` object, required: The parameters for the new `query`
    - `data_source_id` integer, required: The id of the data source to use
    - `raw_query` string, required: The raw query to be executed
    - `name` string: The name of the new `query`

## Response `200`

`Query` response

- Query
  - `id` string, required
  - `token` string, required
  - `raw_query` string
  - `created_at` string, required
  - `updated_at` string, required
  - `name` string, required
  - `last_run_id` string, required
  - `data_source_id` string, required
  - `explorations_count` string, required
  - `report_imports_count` string, required
  - `dbt_metric_id` string, required
  - `dbt_metric_token` string
  - `mapping_id` string
  - `_links` QueryLinks, required
    - `self` Link, required
      - `href` string, required
      - `templated` boolean
    - `report` Link, required
      - `href` string, required
      - `templated` boolean
    - `report_runs` Link, required
      - `href` string, required
      - `templated` boolean
    - `charts` Link
      - `href` string, required
      - `templated` boolean
    - `new_chart` Link
      - `href` string, required
      - `templated` boolean
    - `new_query_table` Link
      - `href` string, required
      - `templated` boolean
    - `query_tables` Link
      - `href` string, required
      - `templated` boolean
    - `query_runs` Link, required
      - `href` string, required
      - `templated` boolean
    - `creator` Link
      - `href` string, required
      - `templated` boolean
    - `metric` Link
      - `href` string, required
      - `templated` boolean
  - `_embedded` unknown

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `404`: `Report` not found

---

[API](https://skmtc.dev/thoughtspot/apis/mode.md) - [All operations](https://skmtc.dev/thoughtspot/apis/mode/llms.txt) - [OpenAPI document](https://skmtc.dev/thoughtspot/apis/mode/revisions/4c694c3fdeb1?raw)
