---
title: "Export Trace"
method: GET
path: "/api/v1/public/traces/{trace_id}/export"
tags: ["Traces"]
---

# Export Trace

`GET /api/v1/public/traces/{trace_id}/export`

## Request

- Base URL: `https://app.traceroot.ai`
- URL: `https://app.traceroot.ai/api/v1/public/traces/{trace_id}/export`
- Auth: HTTP bearer

Export the V1 bundle (trace + spans + git_context + manifest) for the caller's project.

Defaults to the `full` projection — an export is explicit intent to take the
complete trace, so per-span input/output/metadata are included unless the
caller narrows `fields`. `bundle.trace` equals the `traces get` payload at the
same projection.

Rate limited on its own `export` bucket because it builds and serializes the
full bundle.

Args:
    auth (DualStampedAuth): Resolved credential context (API key or user
        session token); scopes the read to its project and stamps the
        rate-limit identity.
    trace_id (str): Trace to export.
    fields (str | None): Comma-separated projection groups or an alias
        (``skeleton``/``full``). ``None`` selects the default `full`
        projection.

Returns:
    PublicTraceExportResponse: The V1 export bundle (manifest, trace, spans,
        git_context) at the requested projection.

Raises:
    HTTPException: 400 if `fields` is invalid, 404 if the trace is missing
        or outside the key's project, 500 on a reader failure.

## Path parameters

- `trace_id` string, required

## Query parameters

- `fields` string, nullable: Comma-separated field groups to include: 'core' (tree/timing/status, always included), 'usage' (tokens/cost), 'io' (per-span input/output), 'metadata' (per-span metadata). Aliases: 'skeleton' (core,usage), 'full' (everything). Unknown groups return 400.
- `project_id` string, nullable: Target project for the request. Required when authenticating with a user session token (a user credential is only meaningful scoped to a project); for an API key it is optional and, if given, must match the key's project.

## Response `200`

Successful Response

- PublicTraceExportResponse: V1 export bundle: trace (== `traces get`) + spans + git_context + manifest.
  - `git_context` GitContext, required: git_context.json: repo/ref + per-span source locations.
    - `git_ref` string, nullable, required
    - `git_repo` string, nullable, required
    - `sources` GitSource[], required
      - `file` string, nullable, required
      - `function` string, nullable, required
      - `line` integer, nullable, required
      - `span_id` string, required
  - `manifest` ExportManifest, required: manifest.json: index of the bundle's parts.
    - `bundle_version` string, required
    - `files` string[], required
    - `project_id` string, required
    - `trace_id` string, required
  - `spans` SpanResponse[], required
    - `cost` number, nullable, required
    - `cost_details` object
    - `error_type` string
    - `git_source_file` string, nullable
    - `git_source_function` string, nullable
    - `git_source_line` integer, nullable
    - `input` string, nullable
    - `input_tokens` integer, nullable, required
    - `metadata` string, nullable
    - `model_name` string, nullable, required
    - `name` string, required
    - `output` string, nullable
    - `output_tokens` integer, nullable, required
    - `parent_span_id` string, nullable, required
    - `span_end_time` string, date-time, nullable, required
    - `span_id` string, required
    - `span_kind` string, required
    - `span_start_time` string, date-time, required
    - `status` string, required
    - `status_message` string, nullable, required
    - `total_tokens` integer, nullable, required
    - `trace_id` string, required
    - `usage_details` object
  - `trace` PublicTraceDetailResponse, required: Full trace payload plus a backend-built link to its UI detail view.
    - `git_ref` string, nullable, required
    - `git_repo` string, nullable, required
    - `input` string, nullable, required
    - `metadata` string, nullable, required
    - `name` string, required
    - `output` string, nullable, required
    - `project_id` string, required
    - `session_id` string, nullable, required
    - `spans` SpanResponse[], required
      - `cost` number, nullable, required
      - `cost_details` object
      - `error_type` string
      - `git_source_file` string, nullable
      - `git_source_function` string, nullable
      - `git_source_line` integer, nullable
      - `input` string, nullable
      - `input_tokens` integer, nullable, required
      - `metadata` string, nullable
      - `model_name` string, nullable, required
      - `name` string, required
      - `output` string, nullable
      - `output_tokens` integer, nullable, required
      - `parent_span_id` string, nullable, required
      - `span_end_time` string, date-time, nullable, required
      - `span_id` string, required
      - `span_kind` string, required
      - `span_start_time` string, date-time, required
      - `status` string, required
      - `status_message` string, nullable, required
      - `total_tokens` integer, nullable, required
      - `trace_id` string, required
      - `usage_details` object
    - `trace_id` string, required
    - `trace_start_time` string, date-time, required
    - `trace_url` string, required
    - `user_id` string, nullable, required

## Other responses

- `400`: Invalid fields parameter
- `401`: Authentication failed
- `404`: Trace not found
- `422`: Validation Error
- `500`: Failed to get trace
- `503`: Authentication service unavailable

---

[API](https://skmtc.dev/traceroot/apis/traceroot-public-api.md) - [All operations](https://skmtc.dev/traceroot/apis/traceroot-public-api/llms.txt) - [OpenAPI document](https://skmtc.dev/traceroot/apis/traceroot-public-api/revisions/ce6aef96c0d6?raw)
