> ## Documentation Index
> Fetch the complete documentation index at: https://docs.seekr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query spans

> Retrieve span summaries that match your filters.

Returns a list of span summaries matching the provided filters. All filters are optional. If `min_start_datetime` is not provided, the query defaults to the last 15 minutes. Start with `run_id` when investigating a specific agent run. Use `limit` and `offset` to paginate results and `order` to sort by start time. To filter by run metadata, add a `metadata[key]` query parameter for each field.

To retrieve the full record for a specific span, use the [get span](https://docs.seekr.com/flow/reference/retrieve_span_v2_spans__span_id__get.md) endpoint.


## OpenAPI

````yaml get /v2/spans
openapi: 3.1.0
info:
  title: SeekrFlow API
  description: SeekrFlow API Documentation
  termsOfService: http://www.seekr.com/support
  contact:
    name: Seekr API Support
    url: http://www.seekr.com/contact
    email: contact@seekr.com
  version: 6.17.0
servers:
  - url: https://flow.seekr.com
    description: SeekrBuild server base URL
security: []
paths:
  /v2/spans:
    get:
      tags:
        - Observability
      summary: Query Spans
      description: Retrieve span summaries using query parameters.
      operationId: query_spans_v2_spans_get
      parameters:
        - name: min_start_datetime
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Min Start Datetime
          description: >-
            Inclusive lower bound for span start times, in ISO 8601 format.
            Defaults to 15 minutes before the query when omitted.
        - name: max_start_datetime
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Max Start Datetime
          description: >-
            Inclusive upper bound for span start times, in ISO 8601 format. Omit
            to leave the upper bound open.
        - name: agent_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Agent Id
          description: Return only spans for this agent.
        - name: run_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Run Id
          description: Return only spans for this run.
        - name: trace_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Trace Id
          description: Return only spans belonging to this trace.
        - name: thread_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Thread Id
          description: Return only spans for this thread.
        - name: group
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Group
          description: Return only spans with this run group label.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 100
            title: Limit
          description: Maximum number of results to return.
        - name: order
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/OrderEnum'
            default: desc
          description: Direction to sort the results.
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
            title: Offset
          description: Number of results to skip.
        - name: x-team-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Team-Id
          description: >-
            ID of the team to use for the request. If omitted, the request uses
            your personal workspace.
        - name: metadata[key]
          in: query
          required: false
          schema:
            type: string
          description: >-
            Replace key with a metadata field name; repeat for additional
            fields.
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SpanSummaryResult'
                title: Response Query Spans V2 Spans Get
        '422':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    OrderEnum:
      type: string
      enum:
        - asc
        - desc
      title: OrderEnum
      description: Options for order query param in list endpoints.
    SpanSummaryResult:
      properties:
        run_id:
          type: string
          title: Run Id
          description: ID of the run.
        group:
          anyOf:
            - type: string
            - type: 'null'
          title: Group
          description: Group label attached to the run that produced the span.
        thread_id:
          type: string
          title: Thread Id
          description: ID of the thread.
        agent_id:
          type: string
          title: Agent Id
          description: ID of the agent.
        trace_id:
          type: string
          title: Trace Id
          description: ID of the distributed trace containing the span.
        span_id:
          type: string
          title: Span Id
          description: ID of this span within the trace.
        parent_span_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Span Id
          description: ID of the parent span, or null for a span without a recorded parent.
        span_name:
          type: string
          title: Span Name
          description: Name of the operation represented by the span.
        level:
          type: integer
          title: Level
          description: Numeric severity level recorded for the span.
        service_name:
          type: string
          title: Service Name
          description: Name of the service that emitted the span.
        otel_scope_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Otel Scope Name
          description: >-
            Name of the OpenTelemetry instrumentation scope that emitted the
            span.
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
          description: Time the span started, in ISO 8601 format.
        end_timestamp:
          type: string
          format: date-time
          title: End Timestamp
          description: Time the span ended, in ISO 8601 format.
        kind:
          $ref: '#/components/schemas/Kind'
        message:
          type: string
          title: Message
          description: Human-readable message recorded for the span.
        is_exception:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Exception
          description: Whether an exception was recorded on the span.
        exception_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Exception Type
          description: Type of the exception recorded on the span, when available.
        gen_ai_operation_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Gen Ai Operation Name
          description: Name of the generative AI operation recorded on the span.
        gen_ai_request_model:
          anyOf:
            - type: string
            - type: 'null'
          title: Gen Ai Request Model
          description: Model identifier recorded in the generative AI request.
        gen_ai_response_model:
          anyOf:
            - type: string
            - type: 'null'
          title: Gen Ai Response Model
          description: Model identifier recorded in the generative AI response.
        gen_ai_system:
          anyOf:
            - type: string
            - type: 'null'
          title: Gen Ai System
          description: Generative AI provider or system recorded on the span.
        gen_ai_usage_input_tokens:
          anyOf:
            - type: string
            - type: 'null'
          title: Gen Ai Usage Input Tokens
          description: >-
            Input token count recorded on the span, represented as a string when
            available.
        gen_ai_usage_output_token:
          anyOf:
            - type: string
            - type: 'null'
          title: Gen Ai Usage Output Token
          description: >-
            Reserved output-token count. The span-summary query does not
            populate this field, so it returns null.
        seekr_metadata:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Seekr Metadata
          description: Run metadata key-value pairs recorded on the span.
      type: object
      required:
        - run_id
        - thread_id
        - agent_id
        - trace_id
        - span_id
        - span_name
        - level
        - service_name
        - start_timestamp
        - end_timestamp
        - kind
        - message
      title: SpanSummaryResult
      description: >-
        Summary object of a span, meant to be retrieved in bulk and used to
        provide data on spans to be able to fetch more data.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          description: List of validation errors.
      type: object
      title: HTTPValidationError
    Kind:
      type: string
      enum:
        - span
        - pending_span
        - log
        - span_event
      title: Kind
      description: Indicates the type of record for a logfire record.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
          description: Location of the error, as a list of path segments.
        msg:
          type: string
          title: Message
          description: Description of the error.
        type:
          type: string
          title: Error Type
          description: Machine-readable validation error type.
        input:
          title: Input
          description: Input value that failed validation, when included in the error.
        ctx:
          type: object
          title: Context
          description: >-
            Additional values that explain the validation error, such as a
            failed constraint.
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      description: >-
        Your Seekr API key, sent in the Authorization header with no 'Bearer'
        prefix.
      in: header
      name: Authorization

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.