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

# List spans in a trace

> Returns spans ordered by start_time and span_id, with cursor pagination. Requires telemetry:ReadTraces.

<Info>
  Requires the IAM action **`telemetry:ReadTraces`**. See [TELEMETRY permissions](/telemetry#permissions) for the full list, what each one covers, and an example policy.
</Info>


## OpenAPI

````yaml /api-reference/specs/telemetry.yaml get /v1/traces/{trace_id}/spans
openapi: 3.0.3
info:
  title: Basaltic Telemetry API
  version: 1.0.0
  description: >
    Regional telemetry API — log groups and log ingest/search,

    metrics (remote_write ingestion and native structured JSON queries), span
    ingest, and trace search/detail + per-account

    trace settings.


    Log-group request references accept UUIDs, CRNs or exact account-scoped

    names, classified by syntax without lookup fallback. CRNs must match the

    authenticated account handle and serving region. HTTP and gRPC OTLP logs

    use basaltic.log_group, falling back to service.name, with the same

    reference contract. Trace/span identifiers, metric labels and region

    search dimensions are protocol values, independent of resource resolution.
  contact:
    name: Basaltic Support
    email: ping@basaltic.sh
  license:
    name: Proprietary
    url: https://basaltic.sh/terms
servers:
  - url: https://telemetry.{region}.basaltic.sh
    description: Regional API endpoint (one per region)
    variables:
      region:
        default: sa-saopaulo-1
        description: Region code
security:
  - BearerAuth: []
paths:
  /v1/traces/{trace_id}/spans:
    get:
      tags:
        - Telemetry
      summary: List spans in a trace
      description: >-
        Returns spans ordered by start_time and span_id, with cursor pagination.
        Requires telemetry:ReadTraces.
      operationId: listTraceSpans
      parameters:
        - name: trace_id
          in: path
          required: true
          schema:
            type: string
            example: 4bf92f3577b34da6a3ce929d0e0e4736
        - $ref: '#/components/parameters/LimitDefault50'
        - $ref: '#/components/parameters/Marker'
      responses:
        '200':
          description: Span page
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpanListResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    LimitDefault50:
      name: limit
      in: query
      description: >-
        Maximum number of items to return. A value above the maximum is clamped
        to it rather than rejected, so a page shorter than the one you asked for
        is normal — page until `meta.has_more` is false, not until a page looks
        short.
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 50
      example: 50
    Marker:
      name: marker
      in: query
      description: >-
        Opaque pagination cursor. Echo back the `meta.marker` value from the
        previous page to fetch the next one; do not construct or parse it. The
        token's internal form varies by endpoint (a resource ID, a timestamp, …)
        and is not guaranteed stable across releases.
      required: false
      schema:
        type: string
      example: 550e8400-e29b-41d4-a716-446655440000
  schemas:
    SpanListResponse:
      type: object
      required:
        - spans
        - meta
      properties:
        spans:
          type: array
          items:
            $ref: '#/components/schemas/Span'
        meta:
          $ref: '#/components/schemas/PaginationMeta'
    Span:
      type: object
      properties:
        trace_id:
          type: string
          example: 4bf92f3577b34da6a3ce929d0e0e4736
        span_id:
          type: string
          example: 00f067aa0ba902b7
        parent_span_id:
          type: string
          example: a2fb4a1d1a96d312
        name:
          type: string
          example: GET /api/users
        kind:
          type: string
          enum:
            - INTERNAL
            - SERVER
            - CLIENT
            - PRODUCER
            - CONSUMER
          example: SERVER
        service_name:
          type: string
          example: api-gateway
        start_time:
          type: string
          format: date-time
          example: '2026-01-15T09:30:00Z'
        end_time:
          type: string
          format: date-time
          example: '2026-01-15T09:30:00.012Z'
        duration_ms:
          type: number
          format: double
          example: 12.4
        status_code:
          type: string
          enum:
            - UNSET
            - OK
            - ERROR
          example: OK
        status_message:
          type: string
          example: ''
        attributes:
          type: object
          additionalProperties:
            type: string
        resource:
          type: object
          additionalProperties:
            type: string
        events:
          type: array
          items:
            $ref: '#/components/schemas/SpanEvent'
        links:
          type: array
          items:
            $ref: '#/components/schemas/SpanLink'
      required:
        - trace_id
        - span_id
        - name
        - kind
        - service_name
        - start_time
        - end_time
        - duration_ms
        - status_code
    PaginationMeta:
      type: object
      properties:
        total:
          type: integer
          description: Total number of items
          example: 150
        limit:
          type: integer
          description: Number of items per page
          example: 20
        marker:
          type: string
          description: >-
            Opaque cursor for the next page. Pass it back as the `marker` query
            parameter; treat it as a token, not a value to parse.
          example: 550e8400-e29b-41d4-a716-446655440000
        has_more:
          type: boolean
          description: Whether there are more items
          example: true
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - request_id
          properties:
            code:
              type: string
              description: Error code identifying the type of error
              example: INVALID_INPUT
            message:
              type: string
              description: Human-readable error message
              example: Invalid request parameters
            params:
              type: object
              additionalProperties: true
              description: >-
                Optional non-sensitive values for interpolation of localized
                errors, keyed by error code. Never present for server errors.
              example:
                instances: 2
                pools: 0
            request_id:
              type: string
              format: uuid
              description: Request ID for debugging
              example: 550e8400-e29b-41d4-a716-446655440000
    SpanEvent:
      type: object
      required:
        - name
      properties:
        timestamp:
          type: string
          format: date-time
          example: '2026-01-15T09:30:00.008Z'
        name:
          type: string
          example: cache.miss
        attributes:
          type: object
          additionalProperties:
            type: string
    SpanLink:
      type: object
      required:
        - trace_id
        - span_id
      properties:
        trace_id:
          type: string
          example: 8a3c60f7d188f8fa79d48a391a778fa6
        span_id:
          type: string
          example: b7ad6b7169203331
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INVALID_INPUT
              message: Invalid request parameters
              request_id: 550e8400-e29b-41d4-a716-446655440000
    Unauthorized:
      description: Authentication required or token invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: UNAUTHORIZED
              message: Authentication required
              request_id: 550e8400-e29b-41d4-a716-446655440000
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: ACCESS_DENIED
              message: You don't have permission to perform this action
              request_id: 550e8400-e29b-41d4-a716-446655440000
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: NOT_FOUND
              message: Resource not found
              request_id: 550e8400-e29b-41d4-a716-446655440000
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INTERNAL_ERROR
              message: An internal error occurred
              request_id: 550e8400-e29b-41d4-a716-446655440000
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        An OAuth 2.0 bearer token, sent as `Authorization: Bearer <token>`.
        This is the recommended way to authenticate.

        Get one by exchanging a service account's access key pair at
        `POST /v1/oauth/token` with `grant_type=client_credentials`. It is the
        standard client-credentials grant, so any OAuth-aware library will
        obtain and refresh it for you.

        ```
        curl -s -u "$KEY_ID:$SECRET" -d grant_type=client_credentials \
          https://iam.basaltic.sh/v1/oauth/token
        ```

        Tokens last an hour by default. The same access key pair is separately
        your AWS SigV4 credential for the S3-compatible object endpoint, which
        speaks nothing else.

````

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