For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/api/latest/ddsql/execute-a-tabular-ddsql-query.md. A documentation index is available at /llms.txt.
Language
Datadog site

Execute a tabular DDSQL query

POSThttps://api.datadoghq.com/api/v2/ddsql/query/tabularhttps://api.us3.datadoghq.com/api/v2/ddsql/query/tabularhttps://api.us5.datadoghq.com/api/v2/ddsql/query/tabularhttps://api.datadoghq.eu/api/v2/ddsql/query/tabularhttps://api.ap1.datadoghq.com/api/v2/ddsql/query/tabularhttps://api.ap2.datadoghq.com/api/v2/ddsql/query/tabularhttps://api.uk1.datadoghq.com/api/v2/ddsql/query/tabularhttps://api.ddog-gov.com/api/v2/ddsql/query/tabularhttps://api.us2.ddog-gov.com/api/v2/ddsql/query/tabular

Overview

Submit a DDSQL statement and return either a running state with an opaque query_id for the client to poll, or a completed state with the column-major result set inlined when the query finishes quickly enough to be served synchronously.

For a scoped application key, include timeseries_query in its scopes. A query that does not read a data source, such as SELECT 1, requires no additional data-source permissions. Queries that read data sources also require the user or service account that owns the application key to have the corresponding data access permissions through their roles. The timeseries_query permission does not grant access to the underlying data sources.

This endpoint requires the timeseries_query permission.

OAuth apps require the timeseries_query authorization scope to access this endpoint.

Request

Body Data (required)

Field
Type
Description
data [required]
object

JSON:API resource object for a DDSQL tabular query execution request.

Response

OK

Response envelope for both the execute and fetch DDSQL tabular query endpoints. Carries the JSON:API primary resource and a top-level meta block with request-scoped observability handles.

Field
Type
Description
data [required]
object

JSON:API resource object for a DDSQL tabular query response.

meta [required]
object

Top-level JSON:API meta block accompanying every DDSQL tabular query response. Carries standard observability handles for client-side correlation.

Code Example

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ddsql/query/tabular" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
      "row_limit": 1000,
      "time": {
        "from_timestamp": 1736942400000,
        "to_timestamp": 1736946000000
      }
    },
    "type": "ddsql_query_request"
  }
}
EOF