---
title: "Run a span analytics query asynchronously."
method: POST
path: "/v1/tracing/spanquery"
tags: ["spanAnalytics"]
---

# Run a span analytics query asynchronously.

`POST /v1/tracing/spanquery`

Execute a span analytics query and get the id to fetch its status and results. Use the [Span Query Status](#operation/getSpanQueryStatus) endpoint to check a query status. When the query has been completed, use the [Span Query Result](#operation/getSpanQueryResult) endpoint to get the result of the asynchronous query.

## Request body

- SpanQueryRequest
  - `queryRows` SpanQueryRow[], required — A list of span analytics queries.
    - `queryString` string, required — Query string using the log search syntax.
    - `rowId` string, required — An identifier used to reference this particular row of the query request. Within a query, row ids must have distinct values.
  - `timeRange` ResolvableTimeRange, required
    - `type` string, required — Type of the time range. Value must be either `CompleteLiteralTimeRange` or `BeginBoundedTimeRange`.
  - `timeZone` string — Time zone for the query time ranges. Follow the format in the [IANA Time Zone Database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List).

## Response `200`

Query execution result.

- SpanQueryResponse
  - `queryId` string, required — Id of the created query
  - `queryRows` SpanQueryRowResponse[], required — A list of row responses with details about individual queries.
    - `rowId` string, required — A unique identifier of the query.
    - `errors` SpanQueryRowError[] — List of errors which occured when executing the query
      - `code` string, required — The error code.
      - `message` string, required — Short description of the occured error.
      - `details` string — Details about the occured error.
    - `isAggregation` boolean, required — Indicates whether this query is an aggregation
    - `executedQuery` string — The executed query after rewriting
  - `hasErrors` boolean — Indicates whether there was an error while executing the query.
  - `timeRange` BeginBoundedTimeRange
    - `type` string, required — Type of the time range. Value must be either `CompleteLiteralTimeRange` or `BeginBoundedTimeRange`.
    - `from` TimeRangeBoundary, required
      - `type` string, required — Type of the time range boundary. Value must be from list: - `RelativeTimeRangeBoundary`, - `EpochTimeRangeBoundary`, - `Iso8601TimeRangeBoundary`, - `LiteralTimeRangeBoundary`.
    - `to` TimeRangeBoundary
      - `type` string, required — Type of the time range boundary. Value must be from list: - `RelativeTimeRangeBoundary`, - `EpochTimeRangeBoundary`, - `Iso8601TimeRangeBoundary`, - `LiteralTimeRangeBoundary`.

## Other responses

- `default` — Operation failed with an error.

---

[API](https://skmtc.net/sumologic/apis/sumo-logic-api.md) · [All operations](https://skmtc.net/sumologic/apis/sumo-logic-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sumologic/sumo-logic-api/revisions/e4e4c7554890/schema)
