> This page is for API Reference.

> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt. For a section index, append `/llms.txt` to any section URL (for example https://docs.sarvam.ai/voice-agents/llms.txt).
> Building a voice agent for customers in India? Start with Sarvam Voice Agents, a managed platform with Indian-language speech, telephony, testing, and analytics from ₹3 per minute: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Get traces

GET https://apps.sarvam.ai/api/analytics/v1/{org_id}/{workspace_id}/{app_id}/traces/{interaction_id}

Returns the event trace of an interaction: each turn with its speech recognition (ASR), LLM, translation, text-to-speech (TTS) and tool-call events, plus interaction-level events such as conversation start and end and post-call analysis. `input` and `output` vary by `event_type`. A trace can include personal data: the user's contact details, agent variables and the transcript. Returns `404` if no trace exists.

```bash
curl "https://apps.sarvam.ai/api/analytics/v1/$ORG_ID/$WORKSPACE_ID/$APP_ID/traces/$INTERACTION_ID" \
  -H "X-API-Key: $SARVAM_API_KEY"
```

Reference: https://docs.sarvam.ai/api-reference/analytics/traces

## Request

### Path parameters

- `org_id` (string, required) — Organization ID.
- `workspace_id` (string, required) — Workspace ID.
- `app_id` (string, required) — Agent ID. Copy it from the agent's **···** menu in the dashboard (**Copy agent ID**).
- `interaction_id` (string, required) — From List interactions, in the form `<YYYYMMDD>/<id>`, e.g. `20261007/9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14`. Send the slash as is or as `%2F`.

### Headers

- `X-API-Key` (string, required) — Your workspace API key.

## Response

### 200

The interaction's event trace.

- `interaction_id` (string, required) — The interaction this trace belongs to.
- `lifecycle_events` (list of ExternalTraceEvent, optional) — Interaction-level events: conversation start and end, their logs, post-call analysis, and errors.
- `turns` (list of ExternalTraceTurn, optional) — The conversation's turns, in order, each with its events.

## Errors

### 400 Bad Request Error

`interaction_id` is not in the `<YYYYMMDD>/<id>` format.

- `detail` (string, required) — Human-readable description of the error.

### 401 Unauthorized Error

The `X-API-Key` header is missing or malformed, or the key does not belong to this organization.

- `detail` (string, required) — Human-readable description of the error.

### 403 Forbidden Error

The API key is valid but not authorized for this organization or workspace.

- `detail` (string, required) — Human-readable description of the error.

### 404 Not Found Error

No trace exists for this interaction. Check the `interaction_id`, and that it belongs to this `app_id`.

- `detail` (string, required) — Human-readable description of the error.

### 422 Unprocessable Entity Error

A required path parameter is missing or malformed. `detail` is a list of validation errors.

- `detail` (AnalyticsValidationErrorResponseDetail, required) — The validation failure.

### 429 Too Many Requests Error

Rate limit exceeded for this API key. Wait for the number of seconds in the `Retry-After` header before retrying.

- `detail` (string, required) — Human-readable description of the error.

### 500 Internal Server Error

The trace could not be retrieved. Retry with backoff; contact support if it persists.

- `detail` (string, required) — Human-readable description of the error.

### 503 Service Unavailable Error

The trace could not be read from storage, or the authentication service is temporarily unavailable. Retry with backoff.

- `detail` (string, required) — Human-readable description of the error.

## Types

### ExternalTraceEvent

One event in an interaction's trace.

- `event_type` (string, required) — Event type, e.g. `ServerASREvent`, `ServerChatLLMEvent.assistant`, `ServerTTSEvent` or `ServerToolEvent.<tool_name>`.
- `display_name` (string, required) — Readable label for the event, e.g. `ASR`, `Chat LLM`, `TTS` or `Conversation Started`.
- `status` (enum, optional, nullable) — `success` or `error`.
  - Allowed values: `success`, `error`
- `input` (map from string to any, optional, nullable) — What went into the event. Fields vary by `event_type`.
- `output` (map from string to any, optional, nullable) — What the event produced. Fields vary by `event_type`; for a failed event, the error.

### ExternalTraceTurn

One conversation turn and its events, in order.

- `turn_id` (integer, required) — Turn number, in conversation order.
- `is_merged` (boolean, optional, default: false) — `true` when the next turn absorbed this turn's speech, for example when the user kept talking.
- `events` (list of ExternalTraceEvent, optional) — The turn's events, in order: speech recognition, LLM, tool calls, translation and text-to-speech.

### AnalyticsValidationErrorResponseDetail

The validation failure.

- list of ValidationError
- string
- SortOrderErrorDetail: SortOrderErrorDetail

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### SortOrderErrorDetail

`detail` shape returned for an invalid `sort_order`.

- `error` (string, required) — Always `Validation error`.
- `message` (string, required) — What was wrong and the allowed values.

### ValidationErrorLocItems

- string
- integer

## Examples

**Response**

```json
{
  "interaction_id": "20261007/9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14",
  "lifecycle_events": [
    {
      "event_type": "ServerToolEvent.on_start",
      "display_name": "Conversation Started",
      "status": "success",
      "input": {
        "user_information": {
          "identifier": "+919876543210",
          "user_identifier_type": "phone"
        }
      },
      "output": {
        "agent_variables": {
          "customer_name": "Priya",
          "loan_status": "overdue"
        },
        "initial_bot_message": "Namaste Priya, this is Asha from Acme Finance."
      }
    },
    {
      "event_type": "ServerToolEvent.on_end",
      "display_name": "Conversation Ended",
      "status": "success",
      "input": {
        "agent_variables": {
          "customer_name": "Priya",
          "loan_status": "overdue",
          "payment_date": "2026-10-12"
        }
      },
      "output": {}
    }
  ],
  "turns": [
    {
      "turn_id": 1,
      "is_merged": false,
      "events": [
        {
          "event_type": "ServerASREvent",
          "display_name": "ASR",
          "status": "success",
          "input": {
            "audio_duration": 2.4,
            "language_tag": "hi-IN",
            "model_name": "saarika:v2.5",
            "prompt": ""
          },
          "output": {
            "language_prob": 0.97,
            "language_tag": "hi-IN",
            "text": "Haan, boliye."
          }
        },
        {
          "event_type": "ServerChatLLMEvent.assistant",
          "display_name": "Chat LLM",
          "status": "success",
          "input": {
            "text": "Haan, boliye."
          },
          "output": {
            "text": "Your EMI of ₹4,500 is overdue. When can you make the payment?"
          }
        },
        {
          "event_type": "ServerToolEvent.update_variables",
          "display_name": "Update Variables",
          "status": "success",
          "input": {
            "args": {
              "call_stage": "payment_reminder"
            }
          },
          "output": {
            "text": "Variables updated."
          }
        },
        {
          "event_type": "ServerTTSEvent",
          "display_name": "TTS",
          "status": "success",
          "input": {
            "assistant_text": "Aapki ₹4,500 ki EMI baaki hai. Aap payment kab kar payenge?",
            "language_tag": "hi-IN",
            "speaker_id": "anushka"
          },
          "output": {
            "language_tag": "hi-IN",
            "voice_settings": {
              "pace": 1,
              "pitch": 0,
              "speed": 1,
              "style": 0
            }
          }
        }
      ]
    }
  ]
}
```

**SDK Code**

```python A trace (abridged to one turn)
import requests

url = "https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14"

headers = {"X-API-Key": "<your-api-key>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript A trace (abridged to one turn)
const url = 'https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14';
const options = {method: 'GET', headers: {'X-API-Key': '<your-api-key>'}};

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

```go A trace (abridged to one turn)
package main

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

func main() {

	url := "https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14"

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

	req.Header.Add("X-API-Key", "<your-api-key>")

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

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

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

}
```

```ruby A trace (abridged to one turn)
require 'uri'
require 'net/http'

url = URI("https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14")

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

request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<your-api-key>'

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

```java A trace (abridged to one turn)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14")
  .header("X-API-Key", "<your-api-key>")
  .asString();
```

```php A trace (abridged to one turn)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14', [
  'headers' => [
    'X-API-Key' => '<your-api-key>',
  ],
]);

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

```csharp A trace (abridged to one turn)
using RestSharp;

var client = new RestClient("https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14");
var request = new RestRequest(Method.GET);
request.AddHeader("X-API-Key", "<your-api-key>");
IRestResponse response = client.Execute(request);
```

```swift A trace (abridged to one turn)
import Foundation

let headers = ["X-API-Key": "<your-api-key>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://apps.sarvam.ai/api/analytics/v1/acme-corp-7c2e9f/support-ws-4b1d8a/support-bot-3f9a1c2e-7b4d/traces/20261007%2F9f1c2a7e-4b3d-4e8a-a1f0-6c2d9b7e5a14")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```