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

# Retrieve a run trace

> Full trace — turns, tool calls, tokens, and outcomes. This is what "every run on a trace" means.




## OpenAPI

````yaml /openapi.yaml get /v1/loom/runs/{id}/trace
openapi: 3.1.0
info:
  title: Patchwork API
  version: 1.0.0
  description: >
    Public data-plane API. Two products today: Identify (bare account
    resolution) and Loom (threads, runs, and outcomes). Every response is a JSON
    envelope — `status: success` with `data`, or `status: error` with `error`.
  contact:
    url: https://usepatchwork.co
servers:
  - url: https://api.usepatchwork.co
security:
  - bearerAuth: []
tags:
  - name: Identify
    description: Resolve an account or wallet to the institution and rails behind it.
  - name: Loom
    description: Threads, messages, runs, and outcomes for an embedded agent.
paths:
  /v1/loom/runs/{id}/trace:
    get:
      tags:
        - Loom
      summary: Retrieve a run trace
      description: >
        Full trace — turns, tool calls, tokens, and outcomes. This is what
        "every run on a trace" means.
      operationId: retrieveRunTrace
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: '#/components/parameters/PatchworkSubject'
      responses:
        '200':
          description: The trace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvelopeTrace'
        '401':
          description: Missing or invalid credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Run not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    PatchworkSubject:
      name: Patchwork-Subject
      in: header
      required: false
      description: >
        Relay only. Opaque subject id for the acting user. Direct tokens carry
        `sub` instead — do not send this header on a session token.
      schema:
        type: string
  schemas:
    EnvelopeTrace:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          const: success
        data:
          $ref: '#/components/schemas/RunTrace'
    Error:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          required:
            - message
            - code
          properties:
            message:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable machine-readable code.
            details:
              description: Optional extra context.
    RunTrace:
      type: object
      properties:
        id:
          type: string
          format: uuid
        state:
          $ref: '#/components/schemas/RunState'
        cost_credits:
          type: number
        opened_at:
          type: string
          format: date-time
        closed_at:
          type: string
          format: date-time
        connection:
          $ref: '#/components/schemas/ConnectionRef'
        turns:
          type: array
          items:
            $ref: '#/components/schemas/Turn'
    RunState:
      type: string
      enum:
        - running
        - awaiting_input
        - awaiting_outcome
        - closed
        - failed
    ConnectionRef:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
    Turn:
      type: object
      properties:
        seq:
          type: integer
        model_class:
          type: string
        input_tokens:
          type: integer
        output_tokens:
          type: integer
        cost_credits:
          type: number
        request:
          type: object
        response:
          type: object
        tool_calls:
          type: array
          items:
            $ref: '#/components/schemas/ToolCall'
    ToolCall:
      type: object
      properties:
        patch_ref:
          type: string
        interaction:
          type: string
        status:
          type: string
        args:
          type: object
        result:
          type: object
        risk:
          type: string
        reliability:
          type: string
        cost_credits:
          type: number
        outcome:
          type: object
          properties:
            state:
              type: string
              enum:
                - occurred
                - failed
            detail:
              type: object
            created_at:
              type: string
              format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Identify accepts a workspace API key (`sk_…`). Loom accepts either a
        short-lived session token (direct) or a workspace API key (relay).

````