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

# Get span by ID

> Get a specific span by its ID. See [Spans](https://docs.galtea.ai/sdk/api/span/service). These endpoints serve spans, the steps inside a trace. Their REST path `/traces` keeps the old name of this entity.

> [!WARNING]
>
> You are reading the docs of Galtea 5.17. [Read this page in the latest version](https://docs.galtea.ai/api-reference/spans/get-span-by-id.md).


## OpenAPI

````yaml /v5.17/openapi.json get /traces/{id}
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /traces/{id}:
    get:
      tags:
        - spans
      summary: Get span by ID
      description: >-
        Get a specific span by its ID. See
        [Spans](https://docs.galtea.ai/sdk/api/span/service). These endpoints
        serve spans, the steps inside a trace. Their REST path `/traces` keeps
        the old name of this entity.
      operationId: getTraceById
      parameters:
        - name: id
          in: path
          description: Span ID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Span retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Trace'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Span not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    Trace:
      type: object
      description: >-
        A span: one step inside a trace, such as a tool call, a retrieval or an
        LLM call. The schema name and the `/traces` path still carry the old
        name of this entity, "trace". The parent trace is `inferenceResultId`;
        the `parentTraceId` field is the parent span, not the trace. Span ids
        start with `trace_`, so a `trace_` id belongs here and never to a trace.
      properties:
        id:
          type: string
          example: trace_123
        inferenceResultId:
          type: string
          example: ir_123
        name:
          type: string
          example: fetch_user_data
        type:
          type: string
          enum:
            - SPAN
            - GENERATION
            - EVENT
            - AGENT
            - TOOL
            - CHAIN
            - RETRIEVER
            - EVALUATOR
            - EMBEDDING
            - GUARDRAIL
          nullable: true
          example: TOOL
        description:
          type: string
          nullable: true
          example: Fetches user data from the database by ID
          description: Human-readable description of the operation. Maximum 1MB.
        inputData:
          type: object
          nullable: true
          example:
            user_id: '123'
          description: Input parameters passed to the operation
        outputData:
          oneOf:
            - type: object
            - type: string
          nullable: true
          example:
            name: John Doe
            email: john@example.com
          description: >-
            Result returned by the operation. Usually an object; a plain string
            for retrieval-context spans
        error:
          type: string
          nullable: true
          example: Connection timeout
          description: Error message if failed
        latencyMs:
          type: number
          nullable: true
          example: 45.5
          description: Execution time in milliseconds
        metadata:
          type: object
          nullable: true
          example:
            model: gpt-4
            temperature: 0.7
          description: Additional custom metadata
        parentTraceId:
          type: string
          nullable: true
          example: trace_parent_123
          description: ID of parent span for hierarchical relationships
        startTime:
          type: string
          format: date-time
          nullable: true
        endTime:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        deletedAt:
          type: string
          format: date-time
          nullable: true
        modelId:
          type: string
          nullable: true
          readOnly: true
          example: model_123
          description: >-
            The model that answered this LLM call, matched by name when the span
            was ingested. Null when no live model of the organization, or global
            model, had any of the model names of the span. A name also matches
            without its provider prefix. Deleting the model keeps it, so it can
            name a deleted model.
        modelName:
          type: string
          nullable: true
          readOnly: true
          example: gpt-4o-mini
          description: The model name the span reported, whether or not it matched a model.
        inputTokens:
          type: integer
          nullable: true
          readOnly: true
          example: 100
          description: >-
            Input tokens the LLM call reported, cached input included. Null
            without `evaluation.readInference` on the product.
        outputTokens:
          type: integer
          nullable: true
          readOnly: true
          example: 50
          description: >-
            Output tokens the LLM call reported. Null without
            `evaluation.readInference` on the product.
        cacheReadInputTokens:
          type: integer
          nullable: true
          readOnly: true
          example: 20
          description: >-
            Input tokens the LLM call read from the cache, a part of
            `inputTokens` priced at the cache-read rate. A count above
            `inputTokens` is taken as counted apart and flagged in the metadata.
            Null without `evaluation.readInference` on the product.
        tokens:
          type: integer
          nullable: true
          readOnly: true
          example: 170
          description: >-
            Sum of the input and output tokens, so cached input counts once,
            plus the cache read when the source counted it apart from the input.
            Null without `evaluation.readInference` on the product.
        costPerInputToken:
          type: number
          nullable: true
          readOnly: true
          example: 0.00001
          description: >-
            Price of one input token, frozen at ingest from the model of this
            call, or from the version model when the span names no model. Null
            when the named model links to nothing or has no price. Null without
            `evaluation.readInference` on the product.
        costPerOutputToken:
          type: number
          nullable: true
          readOnly: true
          example: 0.00003
          description: >-
            Price of one output token, frozen at ingest like costPerInputToken.
            Null without `evaluation.readInference` on the product.
        costPerCacheReadInputToken:
          type: number
          nullable: true
          readOnly: true
          example: 0.000005
          description: >-
            Price of one cache-read token, frozen at ingest like
            costPerInputToken. Null without `evaluation.readInference` on the
            product.
        cost:
          type: number
          nullable: true
          readOnly: true
          example: 0.0026
          description: >-
            Cost of this call at the frozen rates. Null when no rates were
            found. A turn's cost sums the costs of the spans it counts. A call
            counts once for each side, input and output, from the deepest span
            that reports it. A span that loses one side to a span below is
            priced again for the side it keeps. Null without
            `evaluation.readInference` on the product.
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````

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