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

# Get a span within a trace

> Retrieve the full span payload using its complete trace-scoped identity.

Use this endpoint when both identifiers are known; GET /v5/spans/{span_id}
remains available for callers that have only a span id. Reads use the
account's configured source, the legacy trace store or the tracing service,
with fallback to the legacy trace store outside strict mode. Access is
authorized against the trace, and
an unknown span or a span belonging to another trace returns 404. ``input_tokens`` and
``output_tokens`` carry the token usage the span's producer reported at ingest, and are absent
both for a span that reported none and for every span served from the legacy trace store,
which keeps no token counts.



## OpenAPI

````yaml /openapi/v5.yaml get /v5/traces/{trace_id}/spans/{span_id}
openapi: 3.1.0
info:
  title: EGP API V5
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
paths:
  /v5/traces/{trace_id}/spans/{span_id}:
    get:
      tags:
        - Spans
      summary: Get a span within a trace
      description: >-
        Retrieve the full span payload using its complete trace-scoped identity.


        Use this endpoint when both identifiers are known; GET
        /v5/spans/{span_id}

        remains available for callers that have only a span id. Reads use the

        account's configured source, the legacy trace store or the tracing
        service,

        with fallback to the legacy trace store outside strict mode. Access is

        authorized against the trace, and

        an unknown span or a span belonging to another trace returns 404.
        ``input_tokens`` and

        ``output_tokens`` carry the token usage the span's producer reported at
        ingest, and are absent

        both for a span that reported none and for every span served from the
        legacy trace store,

        which keeps no token counts.
      operationId: GET-V5-/v5/traces/trace_id/spans/span_id
      parameters:
        - name: trace_id
          in: path
          required: true
          schema:
            type: string
            title: Trace Id
        - name: span_id
          in: path
          required: true
          schema:
            type: string
            title: Span Id
        - name: x-selected-account-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Account ID Header
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Span'
        '400':
          description: >-
            The request carried a value this API or the tracing service
            rejected, such as a search term breaking a documented rule or a
            malformed pagination cursor.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpanReadErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '503':
          description: >-
            The configured tracing read backend is unavailable. Known service
            configuration failures include a stable error_code; other failures
            return only detail.
          headers:
            x-correlation-id:
              description: Correlation ID for this request.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpanReadErrorResponse'
      security:
        - APIKeyHeader: []
components:
  schemas:
    Span:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          const: span
          title: Object
          default: span
        created_by:
          anyOf:
            - $ref: '#/components/schemas/Identity'
            - type: 'null'
          description: The identity that created the entity.
        name:
          type: string
          title: Name
        trace_id:
          type: string
          maxLength: 256
          title: Trace Id
          description: id for grouping traces together, uuid is recommended
        parent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Id
          description: Reference to a parent span_id
        group_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Group Id
          description: Reference to a group_id
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
        end_timestamp:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: End Timestamp
        input:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Input
        output:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Output
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        expected:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Expected
        status:
          anyOf:
            - $ref: '#/components/schemas/ApplicationOperationStatus'
            - type: 'null'
          default: SUCCESS
        type:
          anyOf:
            - $ref: '#/components/schemas/ApplicationOperationType'
            - type: 'null'
          default: STANDALONE
        application_interaction_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Application Interaction Id
          description: The interaction ID this span belongs to
        application_variant_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Application Variant Id
          description: The id of the application variant this span belongs to
        obs_trace_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Obs Trace Id
          description: >-
            W3C trace id of the observability trace this span executed in. Null
            for spans written without the edge, and for accounts still served by
            the legacy trace store.
        obs_span_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Obs Span Id
          description: W3C span id of the observability span this span executed in.
        input_tokens:
          anyOf:
            - type: integer
              maximum: 4294967295
              minimum: 0
            - type: 'null'
          title: Input Tokens
          description: >-
            Prompt tokens the producer reported for this span, absent when it
            reported none. Same quantity the input_tokens sort orders by.
        output_tokens:
          anyOf:
            - type: integer
              maximum: 4294967295
              minimum: 0
            - type: 'null'
          title: Output Tokens
          description: >-
            Completion tokens the producer reported for this span, absent when
            it reported none. Same quantity the output_tokens sort orders by.
        account_id:
          type: string
          title: Account Id
      type: object
      required:
        - id
        - name
        - trace_id
        - start_timestamp
        - account_id
    SpanReadErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
          description: A user-safe explanation of why the tracing read failed.
        error_code:
          anyOf:
            - type: string
              const: TRACES_SERVICE_CONFIGURATION_ERROR
            - type: 'null'
          title: Error Code
          description: >-
            Stable classification for a known EGP-to-tracing-service
            configuration failure. Omitted when the downstream failure is not
            safely classifiable.
      type: object
      required:
        - detail
      title: SpanReadErrorResponse
      description: Safe public error body for a tracing read that could not be completed.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Identity:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          const: identity
          title: Object
          default: identity
        type:
          $ref: '#/components/schemas/IdentityType'
      type: object
      required:
        - id
        - type
      title: Identity
    ApplicationOperationStatus:
      type: string
      enum:
        - SUCCESS
        - ERROR
        - CANCELED
      title: ApplicationOperationStatus
    ApplicationOperationType:
      type: string
      enum:
        - TEXT_INPUT
        - TEXT_OUTPUT
        - COMPLETION_INPUT
        - COMPLETION
        - KB_RETRIEVAL
        - KB_INPUT
        - RERANKING
        - EXTERNAL_ENDPOINT
        - PROMPT_ENGINEERING
        - DOCUMENT_INPUT
        - MAP_REDUCE
        - DOCUMENT_SEARCH
        - DOCUMENT_PROMPT
        - CUSTOM
        - CODE_EXECUTION
        - DATA_MANIPULATION
        - EVALUATION
        - FILE_RETRIEVAL
        - KB_ADD_CHUNK
        - KB_MANAGEMENT
        - GUARDRAIL
        - OUTPUT_GUARDRAIL
        - TRACER
        - AGENT_TRACER
        - AGENT_WORKFLOW
        - STANDALONE
      title: ApplicationOperationType
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    IdentityType:
      type: string
      enum:
        - user
        - service_account
      title: IdentityType
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````