> This page is for Voice Agents.

> 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 attempts

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

Fetch paginated attempts with filtering and sorting options

Reference: https://docs.sarvam.ai/voice-agents/api/analytics/attempts

## Request

### Path parameters

- `org_id` (string, required) — Organization ID
- `workspace_id` (string, required) — Workspace ID
- `app_id` (string, required) — Agent ID

### Query parameters

- `sort_by` (string, optional, nullable) — Field to sort by
- `sort_order` (string, optional, nullable) — Sort order (asc or desc)
- `start_datetime` (datetime, required) — Filter start datetime in UTC (ISO8601)
- `end_datetime` (datetime, required) — Filter end datetime in UTC (ISO8601)
- `limit` (integer, optional, default: 20) — Max number of records to return
- `offset` (integer, optional, default: 0) — Number of records to skip
- `filter_conditions` (string, optional, nullable) — JSON array of filter conditions. Each condition has: id (string), field (from available fields), operator (equals/not\_equals/includes/starts\_with/ends\_with for strings; equals/not\_equals/greater\_than/less\_than for numbers), value. Example: \[\{"id":"1","field":"interaction\_id","operator":"equals","value":"abc123"}]

### Headers

- `X-API-Key` (string, optional, nullable)

## Response

### 200

Successful Response

- `items` (list of ExternalAttemptsAPIResponse, required)
- `total` (integer, required)
- `limit` (integer, required)
- `offset` (integer, required)
- `next_page_uri` (string, optional, nullable)
- `prev_page_uri` (string, optional, nullable)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ExternalAttemptsAPIResponse

Event data for engagement fact events. Validates and converts data types to match ClickHouse EngagementFacts schema.

- `attempt_id` (string, optional, nullable)
- `interaction_id` (string, optional, nullable)
- `user_identifier` (string, optional, nullable)
- `connectivity_status` (string, optional, nullable)
- `failure_reason` (string, optional, nullable)
- `ended_by` (string, optional, nullable)
- `duration_in_seconds` (double, optional, nullable, default: 0)
- `start_datetime` (datetime, optional, nullable)
- `end_datetime` (datetime, optional, nullable)
- `language_name` (string, optional, nullable)
- `num_messages` (integer, optional, nullable)
- `average_agent_response_time_in_seconds` (double, optional, nullable)
- `average_user_response_time_in_seconds` (double, optional, nullable)
- `user_contact_masked` (string, optional, nullable)
- `channel_direction` (string, optional, nullable)
- `retry_attempt` (integer, optional, nullable)
- `campaign_id` (string, optional, nullable)
- `cohort_id` (string, optional, nullable)
- `user_contact_hashed` (string, optional, nullable)
- `is_debug_call` (integer, optional, nullable)
- `audio_url` (string, optional, nullable)
- `server_retry_attempt` (integer, optional, nullable)
- `has_log_issues` (integer, optional, nullable)
- `channel_provider` (string, optional, nullable)
- `channel_protocol` (string, optional, nullable)
- `channel_type` (string, optional, nullable)
- `agent_variables` (map from string to any, optional, nullable)

### ValidationError

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

### ValidationErrorLocItems

## Examples

**Response**

```json
{
  "items": [
    {
      "attempt_id": "string",
      "interaction_id": "string",
      "user_identifier": "string",
      "connectivity_status": "string",
      "failure_reason": "string",
      "ended_by": "string",
      "duration_in_seconds": 1.1,
      "start_datetime": "2024-01-15T09:30:00Z",
      "end_datetime": "2024-01-15T09:30:00Z",
      "language_name": "string",
      "num_messages": 1,
      "average_agent_response_time_in_seconds": 1.1,
      "average_user_response_time_in_seconds": 1.1,
      "user_contact_masked": "string",
      "channel_direction": "string",
      "retry_attempt": 1,
      "campaign_id": "string",
      "cohort_id": "string",
      "user_contact_hashed": "string",
      "is_debug_call": 1,
      "audio_url": "string",
      "server_retry_attempt": 1,
      "has_log_issues": 1,
      "channel_provider": "string",
      "channel_protocol": "string",
      "channel_type": "string",
      "agent_variables": {}
    }
  ],
  "total": 1,
  "limit": 1,
  "offset": 1,
  "next_page_uri": "string",
  "prev_page_uri": "string"
}
```

**SDK Code**

```python
import requests

url = "https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts"

querystring = {"end_datetime":"end_datetime","start_datetime":"start_datetime"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts?end_datetime=end_datetime&start_datetime=start_datetime';
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
package main

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

func main() {

	url := "https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts?end_datetime=end_datetime&start_datetime=start_datetime"

	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
require 'uri'
require 'net/http'

url = URI("https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts?end_datetime=end_datetime&start_datetime=start_datetime")

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
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts?end_datetime=end_datetime&start_datetime=start_datetime")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts?end_datetime=end_datetime&start_datetime=start_datetime');

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

```csharp
using RestSharp;

var client = new RestClient("https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts?end_datetime=end_datetime&start_datetime=start_datetime");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://apps.sarvam.ai/api/analytics/v1/org_id/workspace_id/app_id/attempts?end_datetime=end_datetime&start_datetime=start_datetime")! 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()
```