> 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 full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt.
> 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/api-reference/analytics/attempts

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: agents
  version: 1.0.0
paths:
  /analytics/v1/{org_id}/{workspace_id}/{app_id}/attempts:
    get:
      operationId: getPaginatedAttemptsApi
      summary: Get attempts
      description: Fetch paginated attempts with filtering and sorting options
      tags:
        - external_endpoints
      parameters:
        - name: org_id
          in: path
          description: Organization ID
          required: true
          schema:
            type: string
        - name: workspace_id
          in: path
          description: Workspace ID
          required: true
          schema:
            type: string
        - name: app_id
          in: path
          description: Agent ID
          required: true
          schema:
            type: string
        - name: sort_by
          in: query
          description: Field to sort by
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: sort_order
          in: query
          description: Sort order (asc or desc)
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: start_datetime
          in: query
          description: Filter start datetime in UTC (ISO8601)
          required: true
          schema:
            type: string
            format: date-time
        - name: end_datetime
          in: query
          description: Filter end datetime in UTC (ISO8601)
          required: true
          schema:
            type: string
            format: date-time
        - name: limit
          in: query
          description: Max number of records to return
          required: false
          schema:
            type: integer
            default: 20
        - name: offset
          in: query
          description: Number of records to skip
          required: false
          schema:
            type: integer
            default: 0
        - name: filter_conditions
          in: query
          description: >-
            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"}]
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: X-API-Key
          in: header
          required: false
          schema:
            type:
              - string
              - 'null'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PaginatedResponse_ExternalAttemptsAPIResponse_
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
servers:
  - url: https://apps.sarvam.ai/api
    description: Production
components:
  schemas:
    ExternalAttemptsAPIResponse:
      type: object
      properties:
        attempt_id:
          type:
            - string
            - 'null'
        interaction_id:
          type:
            - string
            - 'null'
        user_identifier:
          type:
            - string
            - 'null'
        connectivity_status:
          type:
            - string
            - 'null'
        failure_reason:
          type:
            - string
            - 'null'
        ended_by:
          type:
            - string
            - 'null'
        duration_in_seconds:
          type:
            - number
            - 'null'
          format: double
          default: 0
        start_datetime:
          type:
            - string
            - 'null'
          format: date-time
        end_datetime:
          type:
            - string
            - 'null'
          format: date-time
        language_name:
          type:
            - string
            - 'null'
        num_messages:
          type:
            - integer
            - 'null'
        average_agent_response_time_in_seconds:
          type:
            - number
            - 'null'
          format: double
        average_user_response_time_in_seconds:
          type:
            - number
            - 'null'
          format: double
        user_contact_masked:
          type:
            - string
            - 'null'
        channel_direction:
          type:
            - string
            - 'null'
        retry_attempt:
          type:
            - integer
            - 'null'
        campaign_id:
          type:
            - string
            - 'null'
        cohort_id:
          type:
            - string
            - 'null'
        user_contact_hashed:
          type:
            - string
            - 'null'
        is_debug_call:
          type:
            - integer
            - 'null'
        audio_url:
          type:
            - string
            - 'null'
        server_retry_attempt:
          type:
            - integer
            - 'null'
        has_log_issues:
          type:
            - integer
            - 'null'
        channel_provider:
          type:
            - string
            - 'null'
        channel_protocol:
          type:
            - string
            - 'null'
        channel_type:
          type:
            - string
            - 'null'
        agent_variables:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
      description: >-
        Event data for engagement fact events.

        Validates and converts data types to match ClickHouse EngagementFacts
        schema.
      title: ExternalAttemptsAPIResponse
    PaginatedResponse_ExternalAttemptsAPIResponse_:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/ExternalAttemptsAPIResponse'
        total:
          type: integer
        limit:
          type: integer
        offset:
          type: integer
        next_page_uri:
          type:
            - string
            - 'null'
        prev_page_uri:
          type:
            - string
            - 'null'
      required:
        - items
        - total
        - limit
        - offset
      title: PaginatedResponse_ExternalAttemptsAPIResponse_
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

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