---
title: "Search spans"
method: POST
path: "/api/v2/spans/events/search"
tags: ["Spans"]
---

# Search spans

`POST /api/v2/spans/events/search`

List endpoint returns spans that match a span search query.
[Results are paginated][1].

Use this endpoint to build complex spans filtering and search.
This endpoint is rate limited to `300` requests per hour.

[1]: /logs/guide/collect-multiple-logs-with-pagination?tab=v2api

## Request body

- SpansListRequest — The request for a spans list.
  - `data` SpansListRequestData — The object containing the query content.
    - `attributes` SpansListRequestAttributes — The object containing all the query parameters.
      - `filter` SpansQueryFilter — The search and filter query settings.
        - `from` string — The minimum time for the requested spans, supports date-time ISO8601, date math, and regular timestamps (milliseconds).
        - `query` string — The search query - following the span search syntax.
        - `to` string — The maximum time for the requested spans, supports date-time ISO8601, date math, and regular timestamps (milliseconds).
      - `options` SpansQueryOptions — Global query options that are used during the query. Note: You should only supply timezone or time offset but not both otherwise the query will fail.
        - `timeOffset` integer — The time offset (in seconds) to apply to the query.
        - `timezone` string — The timezone can be specified as GMT, UTC, an offset from UTC (like UTC+1), or as a Timezone Database identifier (like America/New_York).
      - `page` SpansListRequestPage — Paging attributes for listing spans.
        - `cursor` string — List following results with a cursor provided in the previous query.
        - `limit` integer — Maximum number of spans in the response.
      - `sort` 'timestamp' | '-timestamp' — Sort parameters when querying spans.
    - `type` 'search_request' — The type of resource. The value should always be search_request.

## Response `200`

OK

- SpansListResponse — Response object with all spans matching the request and pagination information.
  - `data` Span[] — Array of spans matching the request.
    - `attributes` SpansAttributes — JSON object containing all span attributes and their associated values.
      - `attributes` object — JSON object of attributes from your span.
      - `custom` object — JSON object of custom spans data.
      - `end_timestamp` string, date-time — End timestamp of your span.
      - `env` string — Name of the environment from where the spans are being sent.
      - `host` string — Name of the machine from where the spans are being sent.
      - `ingestion_reason` string — The reason why the span was ingested.
      - `parent_id` string — Id of the span that's parent of this span.
      - `resource_hash` string — Unique identifier of the resource.
      - `resource_name` string — The name of the resource.
      - `retained_by` string — The reason why the span was indexed.
      - `service` string — The name of the application or service generating the span events. It is used to switch from APM to Logs, so make sure you define the same value when you use both products.
      - `single_span` boolean — Whether or not the span was collected as a stand-alone span. Always associated to "single_span" ingestion_reason if true.
      - `span_id` string — Id of the span.
      - `start_timestamp` string, date-time — Start timestamp of your span.
      - `tags` string[] — Array of tags associated with your span.
      - `trace_id` string — Id of the trace to which the span belongs.
      - `type` string — The type of the span.
    - `id` string — Unique ID of the Span.
    - `type` 'spans' — Type of the span.
  - `links` SpansListResponseLinks — Links attributes.
    - `next` string — Link for the next set of results. Note that the request can also be made using the POST endpoint.
  - `meta` SpansListResponseMetadata — The metadata associated with a request.
    - `elapsed` integer — The time elapsed in milliseconds.
    - `page` SpansResponseMetadataPage — Paging attributes.
      - `after` string — The cursor to use to get the next results, if any. To make the next request, use the same parameters with the addition of the `page[cursor]`.
    - `request_id` string — The identifier of the request.
    - `status` 'done' | 'timeout' — The status of the response.
    - `warnings` SpansWarning[] — A list of warnings (non fatal errors) encountered, partial results might be returned if warnings are present in the response.
      - `code` string — A unique code for this type of warning.
      - `detail` string — A detailed explanation of this specific warning.
      - `title` string — A short human-readable summary of the warning.

## Other responses

- `400` — Bad Request.
- `403` — Forbidden: Access denied.
- `422` — Unprocessable Entity.
- `429` — Too many requests: The rate limit set by the API has been exceeded.

---

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