# getTeamCallStats

Per-member CALL COUNTS AND TALK TIME in a time window: one call, exact, live (not a nightly snapshot). The answer to "break down team talk time this week" and "who made the most calls". WINDOW: startDate (inclusive) and endDate (exclusive) as ISO datetimes WITH an offset: resolve "this week"/"since 9/28" in the USER's timezone yourself (getMyProfile.resolvedTimezone, or the organization timezone) before calling. At most 93 calendar days; a wider window is REFUSED with a message. WHAT IS COUNTED, per member, over the organization's calls created in the window and handled by that member: outboundCalls and inboundCalls (every status, missed and unanswered included); connectedCalls = status COMPLETED, the same "connects" the team analytics pages count as completedCalls; conversationCalls = connected AND (lasted at least 120 seconds, or a transcript or AI summary exists), team analytics' conversationCalls; talkSeconds = summed duration of the connected calls (a connected call with no recorded duration adds 0): divide by 60 or 3600 yourself. A call an AI EMPLOYEE handled is not counted for any member, even when it carries one (a screened call the AI took over), and calls with no member at all (imported dialer history) are not counted: so these are human calling numbers, and can be lower than the analytics pages, which credit AI-handled calls to the member. byUser is ranked by talkSeconds (name null when the user is gone); totals sums the rows. On an org-wide read only members with at least one call appear; every member you NAME in userIds appears (zeros included). VISIBILITY (the inbox rule): with no userIds, a key owner who may read teammates (VIEW_TEAM_CALLS_TEXTS or VIEW_ALL_PHONES; admins) gets every member; anyone else gets ONLY THEIR OWN row: say so rather than presenting it as the team. Naming a teammate in userIds without either is REFUSED (an error, not zeros). getMyCapabilities says which the key owner holds. Teammate ids come from listTeammates.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "getTeamCallStats", "variables": {...} }`
- Scope: `READ`
- Type: query
- Idempotency: a read; rejects `Idempotency-Key`
- Rate-limited: no

## Variables

- `startDate`: `DateTime!` (required)
- `endDate`: `DateTime!` (required)
- `userIds`: `[ID!]`

## Response (data, an example)

```json
{
  "teamAnalyticsQuery": {
    "callStats": {
      "startDate": "2026-01-01T00:00:00.000Z",
      "endDate": "2026-01-01T00:00:00.000Z",
      "totals": {
        "outboundCalls": 0,
        "inboundCalls": 0,
        "connectedCalls": 0,
        "conversationCalls": 0,
        "talkSeconds": 0
      },
      "byUser": [
        {
          "userId": "<ID>",
          "name": "…",
          "outboundCalls": 0,
          "inboundCalls": 0,
          "connectedCalls": 0,
          "conversationCalls": 0,
          "talkSeconds": 0
        }
      ]
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operationId": "getTeamCallStats",
    "variables": {
      "startDate": "2026-01-01T00:00:00.000Z",
      "endDate": "2026-01-01T00:00:00.000Z"
    }
  }'
```
