> ## Documentation Index
> Fetch the complete documentation index at: https://docs.operata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get detailed contact stats (v2)

> Get the per-second network trace for one contact under the v2 path. The response is identical to the v1 endpoint.

Returns the per-second network trace for one contact. This endpoint and [Get detailed contact stats](https://docs.operata.com/docs/api-contact-stats.md) run the same code and return the same response. Use whichever path matches the rest of your integration.

## Endpoint

```http theme={null}
GET https://api.operata.io/v2/data/calls/{contactId}/details
```

## Parameters

### Path

| Name | Type | Required | Description |
| - | - | - | - |
| `contactId` | string | yes | Amazon Connect contact ID. |

## Response

`200 OK` with a JSON array of per-second rows for the contact. The `RecordCount` response header holds the number of rows. The array is empty when Operata has per-second files for the contact but they hold no rows for it.

Rows aren't sorted. Sort by `timestamp` if you need them in order.

```json theme={null}
[
  {
    "agent": "agent_42",
    "contactId": "56f36f8c-463e-44fe-aff7-54ea7533cec1",
    "agentStatus": "Talk",
    "jitter": 2,
    "mos": 4.41,
    "packetsReceived": 50,
    "packetsSent": 50,
    "packetsLost": 0,
    "rtt": 32,
    "timestamp": "2020-06-16T01:15:40.123Z",
    "cpuAvailable": 69.93,
    "memoryAvailable": 41.2,
    "packetsLostFraction": 0,
    "outboundPacketsLost": 0,
    "outboundPacketsLostPercentage": 0,
    "inbound": {
      "packetsLost": 0,
      "packetsCount": 50,
      "audioLevel": 3168,
      "mos": 4.41,
      "jitterBufferMillis": 0
    },
    "outbound": {
      "packetsLost": 0,
      "packetsCount": 50,
      "audioLevel": 1064.75,
      "mos": 4.43,
      "jitterBufferMillis": 24
    }
  },
  {
    "agent": "agent_42",
    "contactId": "56f36f8c-463e-44fe-aff7-54ea7533cec1",
    "agentStatus": "Talk",
    "jitter": 2,
    "mos": 4.41,
    "packetsReceived": 50,
    "packetsSent": 50,
    "packetsLost": 0,
    "rtt": 32,
    "timestamp": "2020-06-16T01:15:41.123Z",
    "packetsLostFraction": 0,
    "outboundPacketsLost": 0,
    "outboundPacketsLostPercentage": 0,
    "inbound": {
      "packetsLost": 0,
      "packetsCount": 50,
      "audioLevel": 3168,
      "mos": 4.41,
      "jitterBufferMillis": 0
    },
    "outbound": {
      "packetsLost": 0,
      "packetsCount": 50,
      "audioLevel": 1064.75,
      "mos": 4.43,
      "jitterBufferMillis": 24
    }
  }
]
```

| Field | Type | Description |
| - | - | - |
| `agent` | string | Agent username. |
| `contactId` | string | Amazon Connect contact ID. |
| `agentStatus` | string | Agent state for this second, for example `Talk` or `Mute`. |
| `timestamp` | string | Time of the reading, in UTC. |
| `jitter` | number | Jitter, in milliseconds. |
| `rtt` | number | Round-trip time (RTT), in milliseconds. |
| `mos` | number | Mean opinion score (MOS). Omitted when `0`. |
| `packetsReceived`, `packetsSent`, `packetsLost` | number | Packet counts. |
| `packetsLostFraction` | number | Inbound packets-lost fraction. |
| `outboundPacketsLost`, `outboundPacketsLostPercentage` | number | Outbound packet loss as a count and a percentage. |
| `cpuAvailable`, `memoryAvailable` | number | Machine CPU and memory readings. Omitted when the Agent Collector had no reading. |
| `inbound`, `outbound` | object | Per-direction `packetsLost`, `packetsCount`, `audioLevel`, `mos`, and `jitterBufferMillis`. |

Fields other than `mos`, `cpuAvailable`, and `memoryAvailable` are always present. A field without a stored value comes back as an empty string or `0`.

## Example

```bash curl theme={null}
curl -u "$OPERATA_GROUP_ID:$OPERATA_API_TOKEN" \
  "https://api.operata.io/v2/data/calls/e5c6ca6a-a061-42e8-989d-a06d7cb09cbb/details"
```

```python Python theme={null}
import os, requests

contact_id = "e5c6ca6a-a061-42e8-989d-a06d7cb09cbb"
response = requests.get(
    f"https://api.operata.io/v2/data/calls/{contact_id}/details",
    auth=(os.environ["OPERATA_GROUP_ID"], os.environ["OPERATA_API_TOKEN"]),
)
response.raise_for_status()
rows = sorted(response.json(), key=lambda row: row["timestamp"])
```

## Errors

Errors match [Get detailed contact stats](https://docs.operata.com/docs/api-contact-stats.md#errors).

## Related

* [Get a contact summary (v2)](https://docs.operata.com/docs/api-v2-call-summary.md): the whole-contact summary for the same contact.
* [Get detailed contact stats](https://docs.operata.com/docs/api-contact-stats.md): the same data under the v1 path.


## OpenAPI

````yaml GET /v2/data/calls/{contactId}/details
openapi: 3.0.3
info:
  title: operata-api
  version: '1'
servers:
  - url: https://api.operata.io/
security:
  - sec0: []
paths:
  /v2/data/calls/{contactId}/details:
    get:
      summary: Detailed Contact Stats (v2)
      description: >-
        Returns per-second WebRTC metrics for one contact. v1 and v2 return the
        same response.
      operationId: detailed-operata-stats-v2
      parameters:
        - name: contactId
          in: path
          required: true
          description: Amazon Connect contact ID.
          schema:
            type: string
      responses:
        '200':
          description: >-
            Per-second rows for the contact, unsorted. An empty array when the
            stored files hold no rows for it.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    agent:
                      type: string
                    contactId:
                      type: string
                    agentStatus:
                      type: string
                    jitter:
                      type: number
                    mos:
                      type: number
                    packetsReceived:
                      type: number
                    packetsSent:
                      type: number
                    packetsLost:
                      type: number
                    rtt:
                      type: number
                    timestamp:
                      type: string
                    cpuAvailable:
                      type: number
                    memoryAvailable:
                      type: number
                    packetsLostFraction:
                      type: number
                    outboundPacketsLost:
                      type: number
                    outboundPacketsLostPercentage:
                      type: number
                    inbound:
                      type: object
                      properties:
                        packetsLost:
                          type: number
                        packetsCount:
                          type: number
                        audioLevel:
                          type: number
                        mos:
                          type: number
                        jitterBufferMillis:
                          type: number
                    outbound:
                      type: object
                      properties:
                        packetsLost:
                          type: number
                        packetsCount:
                          type: number
                        audioLevel:
                          type: number
                        mos:
                          type: number
                        jitterBufferMillis:
                          type: number
              example:
                - agent: agent_42
                  contactId: 56f36f8c-463e-44fe-aff7-54ea7533cec1
                  agentStatus: Talk
                  jitter: 2
                  mos: 4.41
                  packetsReceived: 50
                  packetsSent: 50
                  packetsLost: 0
                  rtt: 32
                  timestamp: '2020-06-16T01:15:40.123Z'
                  cpuAvailable: 69.93
                  memoryAvailable: 41.2
                  packetsLostFraction: 0
                  outboundPacketsLost: 0
                  outboundPacketsLostPercentage: 0
                  inbound:
                    packetsLost: 0
                    packetsCount: 50
                    audioLevel: 3168
                    mos: 4.41
                    jitterBufferMillis: 0
                  outbound:
                    packetsLost: 0
                    packetsCount: 50
                    audioLevel: 1064.75
                    mos: 4.43
                    jitterBufferMillis: 24
                - agent: agent_42
                  contactId: 56f36f8c-463e-44fe-aff7-54ea7533cec1
                  agentStatus: Talk
                  jitter: 2
                  mos: 4.41
                  packetsReceived: 50
                  packetsSent: 50
                  packetsLost: 0
                  rtt: 32
                  timestamp: '2020-06-16T01:15:41.123Z'
                  packetsLostFraction: 0
                  outboundPacketsLost: 0
                  outboundPacketsLostPercentage: 0
                  inbound:
                    packetsLost: 0
                    packetsCount: 50
                    audioLevel: 3168
                    mos: 4.41
                    jitterBufferMillis: 0
                  outbound:
                    packetsLost: 0
                    packetsCount: 50
                    audioLevel: 1064.75
                    mos: 4.43
                    jitterBufferMillis: 24
          headers:
            RecordCount:
              description: Number of rows returned.
              schema:
                type: string
        '400':
          description: OpenSearch returned a response the API couldn't decode.
          content:
            text/plain:
              schema:
                type: string
        '401':
          description: >-
            Missing or invalid credentials. The gateway returns an HTML `401
            Authorization Required` page.
          content:
            text/html:
              schema:
                type: string
        '404':
          description: >-
            No per-second data is indexed for this contact: `no matching records
            found`.
          content:
            text/plain:
              schema:
                type: string
        '500':
          description: OpenSearch or the stored files couldn't be read.
          content:
            text/plain:
              schema:
                type: string
components:
  securitySchemes:
    sec0:
      type: http
      scheme: basic

````

## Related topics

- [Get a contact summary (v2)](https://docs.operata.com/docs/api-v2-call-summary.md)
- [List contact summaries (v2)](https://docs.operata.com/docs/api-v2-contact-summary.md)
- [Versioning](https://docs.operata.com/docs/api-versioning.md)
