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

# Get trace

> Retrieve a specific trace by ID, including all its spans.

Pass `?fields=graph` to include agent-workflow DAG nodes in the `graph` field of the response. Successor to the deprecated `GET /v1/traces/{traceId}/graph` sub-resource.



## OpenAPI

````yaml /openapi.yaml get /v1/traces/{traceId}
openapi: 3.0.3
info:
  contact:
    email: hello@agentmark.co
    url: https://docs.agentmark.co
  description: >-
    The AgentMark Gateway API lets you ingest traces, create scores, and
    retrieve prompt templates programmatically.


    Most developers should use the [AgentMark SDK](/introduction/overview) for
    integration.

    The REST API is for cases where you need direct HTTP access or are building
    a custom integration.


    Versioning: every endpoint is prefixed with `/v1/`. Breaking changes ship
    under a new version prefix (`/v2/`, etc.) with a 90-day-minimum deprecation
    window — see [API versioning & stability](/api-reference/versioning) for the
    full policy on what constitutes a breaking vs. additive change.
  title: AgentMark Gateway API
  version: '1.0'
servers:
  - description: Production (AgentMark Cloud)
    url: https://api.agentmark.co
  - description: Local dev server (`npx @agentmark-ai/cli dev`)
    url: http://localhost:9418
security:
  - AppId: []
    BearerAuth: []
tags:
  - description: Ingest, query, and export OpenTelemetry trace data.
    name: Traces
  - description: >-
      Coding-agent session ingest (outerlayer sync) and content-addressed
      session images.
    name: Agents
  - description: Query individual spans across traces.
    name: Spans
  - description: Create, retrieve, list, and delete score records for spans and traces.
    name: Scoring
  - description: Structured-filter search across observability resources.
    name: Search
  - description: Retrieve the effective synced project configuration.
    name: Config
  - description: List and retrieve datasets.
    name: Datasets
  - description: Query server feature availability.
    name: Capabilities
  - description: Per-model LLM pricing data. Public, unauthenticated.
    name: Pricing
  - description: >-
      Create, list, and revoke tenant API keys. Plaintext returned exactly once
      at creation.
    name: API Keys
  - description: >-
      List and retrieve score configuration definitions from the synced project
      config.
    name: Score Configs
  - description: >-
      Trigger and inspect managed deployments. POST returns 202; deployments run
      asynchronously and progress is observed via GET.
    name: Deployments
  - description: >-
      Per-app named environments (e.g. `dev`, `prod`). CRUD for env lifecycle;
      promote/rollback routes land alongside in this group as feature 054 lands
      the saga.
    name: Environments
  - description: >-
      App CRUD — the top-level tenant entity every other resource hangs off.
      Lets a headless agent provision an app without the dashboard.
    name: Apps
  - description: Service health checks.
    name: Health
paths:
  /v1/traces/{traceId}:
    get:
      tags:
        - Traces
      summary: Get trace
      description: >-
        Retrieve a specific trace by ID, including all its spans.


        Pass `?fields=graph` to include agent-workflow DAG nodes in the `graph`
        field of the response. Successor to the deprecated `GET
        /v1/traces/{traceId}/graph` sub-resource.
      operationId: get-trace
      parameters:
        - in: path
          name: traceId
          required: true
          schema:
            type: string
        - in: query
          name: fields
          required: false
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    properties:
                      cost:
                        type: number
                      end:
                        format: date-time
                        type: string
                      graph:
                        items:
                          properties:
                            displayName:
                              type: string
                            nodeId:
                              type: string
                            nodeType:
                              type: string
                            parentNodeId:
                              type: string
                            spanId:
                              type: string
                            spanName:
                              type: string
                          required:
                            - nodeId
                            - spanId
                            - nodeType
                            - displayName
                            - spanName
                          type: object
                        type: array
                      id:
                        type: string
                      input:
                        type: string
                      latency_ms:
                        type: number
                      metadata:
                        additionalProperties:
                          type: string
                        type: object
                      name:
                        type: string
                      output:
                        type: string
                      scores:
                        items:
                          properties:
                            created_at:
                              type: string
                            id:
                              type: string
                            label:
                              nullable: true
                              type: string
                            name:
                              type: string
                            reason:
                              nullable: true
                              type: string
                            resource_id:
                              type: string
                            score:
                              type: number
                            source:
                              type: string
                            user_id:
                              nullable: true
                              type: string
                          required:
                            - id
                            - resource_id
                            - name
                            - score
                            - source
                            - created_at
                          type: object
                        type: array
                      spans:
                        items:
                          properties:
                            cost:
                              type: number
                            duration_ms:
                              type: number
                            finish_reason:
                              nullable: true
                              type: string
                            id:
                              type: string
                            input:
                              nullable: true
                              type: string
                            input_tokens:
                              minimum: 0
                              type: integer
                            metadata:
                              additionalProperties:
                                type: string
                              type: object
                            model:
                              nullable: true
                              type: string
                            name:
                              type: string
                            output:
                              nullable: true
                              type: string
                            output_object:
                              nullable: true
                              type: string
                            output_tokens:
                              minimum: 0
                              type: integer
                            parent_id:
                              nullable: true
                              type: string
                            prompt_name:
                              nullable: true
                              type: string
                            props:
                              nullable: true
                              type: string
                            reasoning_tokens:
                              minimum: 0
                              type: integer
                            service_name:
                              type: string
                            settings:
                              nullable: true
                              type: string
                            span_kind:
                              type: string
                            status:
                              enum:
                                - UNSET
                                - OK
                                - ERROR
                              type: string
                            status_message:
                              nullable: true
                              type: string
                            timestamp:
                              format: date-time
                              type: string
                            tokens:
                              minimum: 0
                              type: integer
                            tool_calls:
                              nullable: true
                              type: string
                            trace_id:
                              type: string
                            type:
                              type: string
                          required:
                            - id
                            - trace_id
                            - parent_id
                            - name
                            - status
                            - duration_ms
                            - timestamp
                            - type
                            - model
                            - input_tokens
                            - output_tokens
                            - tokens
                            - cost
                          type: object
                        type: array
                      start:
                        format: date-time
                        type: string
                      status:
                        enum:
                          - UNSET
                          - OK
                          - ERROR
                        type: string
                      tokens:
                        minimum: 0
                        type: integer
                    required:
                      - id
                      - name
                      - status
                      - start
                      - end
                      - latency_ms
                      - cost
                      - tokens
                      - spans
                    type: object
                required:
                  - data
                type: object
          description: The trace with its spans.
        '400':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Invalid request parameters (validation failed).
        '401':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Missing or invalid API key.
        '404':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Trace not found.
        '429':
          content:
            application/json:
              schema:
                properties:
                  error:
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                    type: object
                required:
                  - error
                type: object
          description: Rate limited.
components:
  securitySchemes:
    AppId:
      description: >-
        Application ID for tenant scoping. X-Outerlayer-App-Id is accepted as an
        equivalent header.
      in: header
      name: X-Agentmark-App-Id
      type: apiKey
    BearerAuth:
      description: API key (sk_agentmark_*)
      scheme: bearer
      type: http

````