# getPipelineAnalytics

Per-pipeline TRENDS for a rolling period (SEVEN_DAYS | FOURTEEN_DAYS | THIRTY_DAYS | YEAR_TO_DATE; THIRTY_DAYS is the last 30 days, not this month) from a NIGHTLY snapshot (asOfDate): stage duration, stage mix, won/lost/active. wonDeals / lostDeals count EVENTS (moves into a won or lost stage in the window, archived deals included) and miss moves since the snapshot, so they can disagree with the deals as they stand: for "how many won", a win rate or money use findDeals `totals` (outcome WON / LOST, a stageChanged window). Requires the ADMIN scope.

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

## Variables

- `period`: `AgentAnalyticsPeriod` (default `THIRTY_DAYS`, one of `SEVEN_DAYS`, `FOURTEEN_DAYS`, `THIRTY_DAYS`, `SIXTY_DAYS`, `THIS_MONTH`, `YEAR_TO_DATE`)

## Response (data, an example)

```json
{
  "teamAnalyticsQuery": {
    "agentPipelineInventory": {
      "asOfDate": "…",
      "period": "SEVEN_DAYS",
      "reportingPeriod": "…",
      "startDate": "…",
      "endDate": "…",
      "pipelines": [
        {
          "pipelineId": "<ID>",
          "pipelineName": "…",
          "wonDeals": 0,
          "lostDeals": 0,
          "activeDealsCount": 0,
          "avgStageDurationDays": 0,
          "currentStageMix": [
            {
              "stageName": "…",
              "dealCount": 0
            }
          ]
        }
      ]
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operationId": "getPipelineAnalytics",
    "variables": {}
  }'
```
