> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://respan.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/docs/_mcp/server.

# Get a public trace

GET https://api.respan.ai/api/{unique_organization_id}/traces/{trace_unique_id}/

The trace must first be shared via `PATCH /api/traces/{trace_unique_id}/`. No authentication is required. Metadata keys beginning with `_` are reserved for platform use and omitted from span and trace read responses.

Reference: https://respan.ai/docs/apis/traces/get-public-trace

## Request

### Path parameters

- `unique_organization_id` (string, required) — Organization unique ID used in a public trace share link.
- `trace_unique_id` (string, required) — Unique trace identifier.

## Response

### 200

Trace detail with span tree.

- `id` (string, optional) — Trace identifier.
- `trace_unique_id` (string, optional) — Unique trace identifier.
- `root_span_unique_id` (string, optional) — Root span ID for the trace.
- `unique_organization_id` (string, optional) — Organization unique ID.
- `organization_id` (string, optional) — Alias of `unique_organization_id`.
- `organization_name` (string, optional) — Organization name when available.
- `organization_key_id` (string, optional) — API key identifier used to create the trace.
- `environment` (string, optional) — Environment for the trace.
- `customer_identifier` (string, optional) — Customer or user identifier.
- `start_time` (datetime, optional) — When the trace started.
- `end_time` (datetime, optional) — When the trace ended.
- `duration` (double, optional) — Total duration in seconds.
- `span_count` (integer, optional) — Total spans in the trace.
- `llm_call_count` (integer, optional) — Number of LLM-call spans.
- `total_cost` (double, optional) — Total cost in USD.
- `total_prompt_tokens` (integer, optional) — Sum of prompt tokens.
- `total_completion_tokens` (integer, optional) — Sum of completion tokens.
- `total_tokens` (integer, optional) — Sum of all tokens.
- `error_count` (integer, optional) — Number of error spans.
- `name` (string, optional) — Root span name.
- `input` (string, optional) — Root span input. API key responses may include full storage-enriched content.
- `output` (string, optional) — Root span output. API key responses may include full storage-enriched content.
- `metadata` (ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaMetadata, optional) — Customer metadata. Keys beginning with `_` are reserved and omitted from customer-facing responses.
- `trace_group_identifier` (string, optional) — Workflow or trace-group identifier.
- `session_identifier` (string, optional) — Session identifier when present.
- `model` (string, optional) — Primary/root model used.
- `storage_object_key` (string, optional) — Storage object key for the root span payload when present.
- `span_tree` (list of ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaSpanTreeItems, optional) — Hierarchical span tree for the trace.

## Errors

### 404 Not Found Error

Not Found

- `detail` (string, optional)

### 429 Too Many Requests Error

Rate Limited

- `detail` (string, optional)

## Types

### ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaMetadata

Customer metadata. Keys beginning with `_` are reserved and omitted from customer-facing responses.

### ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaSpanTreeItems

- `id` (string, optional) — Span identifier.
- `unique_id` (string, optional) — Underlying log unique ID.
- `span_unique_id` (string, optional) — Unique span identifier within the trace.
- `span_name` (string, optional) — Span name.
- `span_parent_id` (string, optional, nullable) — Parent span ID.
- `trace_unique_id` (string, optional) — Trace ID.
- `customer_identifier` (string, optional) — Customer identifier.
- `thread_identifier` (string, optional) — Thread identifier when present.
- `session_identifier` (string, optional) — Session identifier when present.
- `organization_key_id` (string, optional) — API key identifier.
- `organization_id` (string, optional) — Organization unique ID.
- `environment` (string, optional) — Environment.
- `log_type` (string, optional) — Span/log type.
- `timestamp` (datetime, optional) — Span end time.
- `start_time` (datetime, optional) — Span start time.
- `end_time` (datetime, optional) — Alias of `timestamp`.
- `prompt_tokens` (integer, optional) — Prompt tokens for this span.
- `completion_tokens` (integer, optional) — Completion tokens for this span.
- `total_request_tokens` (integer, optional) — Total tokens for this span.
- `cost` (double, optional) — Span cost in USD.
- `model` (string, optional) — Model used by the span.
- `latency` (double, optional) — Span duration in seconds.
- `status_code` (integer, optional) — Status code recorded for the span.
- `status` (string, optional) — Span status.
- `input` (string, optional) — Span input.
- `output` (string, optional) — Span output.
- `metadata` (ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaSpanTreeItemsMetadata, optional) — Customer metadata. Keys beginning with `_` are reserved and omitted from customer-facing responses.
- `span_links` (string, optional) — Serialized OTEL span links when present.
- `storage_object_key` (string, optional) — Backing storage object key when present.
- `span_workflow_name` (string, optional) — Workflow name when present.
- `children` (list of ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaSpanTreeItemsChildrenItems, optional) — Nested child spans.

### ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaSpanTreeItemsMetadata

Customer metadata. Keys beginning with `_` are reserved and omitted from customer-facing responses.

### ApiUniqueOrganizationIdTracesTraceUniqueIdGetResponsesContentApplicationJsonSchemaSpanTreeItemsChildrenItems

## Examples

**Response**

```json
{
  "id": "trace_abc123",
  "trace_unique_id": "trace_abc123",
  "root_span_unique_id": "span_root_123",
  "unique_organization_id": "org_xyz789",
  "organization_id": "org_xyz789",
  "organization_name": "Acme Inc",
  "environment": "prod",
  "customer_identifier": "user@example.com",
  "start_time": "2024-01-15T10:30:00Z",
  "end_time": "2024-01-15T10:30:02.500000Z",
  "duration": 2.5,
  "span_count": 3,
  "llm_call_count": 2,
  "total_cost": 0.00345,
  "total_prompt_tokens": 150,
  "total_completion_tokens": 75,
  "total_tokens": 225,
  "error_count": 0,
  "name": "chat_completion",
  "input": "[{\"role\": \"user\", \"content\": \"Explain quantum computing\"}]",
  "output": "{\"role\": \"assistant\", \"content\": \"Quantum computing is a revolutionary technology...\"}",
  "metadata": {
    "user_id": "user123"
  },
  "trace_group_identifier": "workflow_v1",
  "session_identifier": "session456",
  "model": "gpt-4",
  "span_tree": [
    {
      "id": "log_root_1",
      "unique_id": "log_root_1",
      "span_unique_id": "span_root_123",
      "span_name": "chat_completion",
      "span_parent_id": null,
      "trace_unique_id": "trace_abc123",
      "log_type": "chat",
      "timestamp": "2024-01-15T10:30:02Z",
      "start_time": "2024-01-15T10:30:00Z",
      "prompt_tokens": 50,
      "completion_tokens": 75,
      "cost": 0.00345,
      "model": "gpt-4",
      "latency": 2,
      "status_code": 200,
      "status": "success",
      "input": "[{\"role\": \"user\", \"content\": \"Explain quantum computing\"}]",
      "output": "{\"role\": \"assistant\", \"content\": \"Quantum computing is a revolutionary technology...\"}",
      "children": []
    }
  ]
}
```

**SDK Code**

```python Traces_retrievePublicTrace_example
import requests

url = "https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/"

response = requests.get(url)

print(response.json())
```

```javascript Traces_retrievePublicTrace_example
const url = 'https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Traces_retrievePublicTrace_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Traces_retrievePublicTrace_example
require 'uri'
require 'net/http'

url = URI("https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java Traces_retrievePublicTrace_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/")
  .asString();
```

```php Traces_retrievePublicTrace_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/');

echo $response->getBody();
```

```csharp Traces_retrievePublicTrace_example
using RestSharp;

var client = new RestClient("https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift Traces_retrievePublicTrace_example
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/unique_organization_id/traces/trace_unique_id/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```