# Retrieve a campaign's results

`GET https://api.morevoice.ai/v1/campaigns/{id}/stats`

Returns the campaign's results so far: contacts per status, dial attempts per result with talk and ring time, the dispositions recorded, and the contacts compliance checks skipped, by reason.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `campaigns_stats`.

## Parameters

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A campaign ID (`cmp_…`). |

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |

## Responses

### 200 OK

OK Returns `CampaignResults`.

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"campaign_stats"` | — |
| `campaign_id` | `string` | A campaign ID (prefix `cmp_`). |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `contacts` | `CampaignStats` | Contact counts per status and the calls in progress. |
| `contacts.total` | `integer` | Contacts in the campaign. |
| `contacts.finished` | `integer` | Contacts that will not be dialled again (done, failed, do-not-call, skipped, invalid, cancelled). |
| `contacts.by_status` | `object` | Contacts per status. |
| `contacts.live` | `object` | Calls in progress right now (this server's dialer). |
| `attempts` | `object` | — |
| `attempts.total` | `integer` | Dial attempts made. |
| `attempts.talk_seconds` | `integer` | Total talk time. |
| `attempts.average_ring_seconds` | `number \| null` | Average ringing time of the attempts. |
| `attempts.by_result` | `Record<string, integer>` | Attempts per result (answered, no_answer, busy, voicemail, …). |
| `outcomes` | `Record<string, integer>` | Contacts per recorded disposition (interested, not-interested, …). |
| `skip_reasons` | `Record<string, integer>` | Contacts the compliance checks or a user took out, per reason (dnc_import, registry, no_consent, …). |

Example:

```json
{
  "attempts": {
    "average_ring_seconds": 11.4,
    "by_result": {
      "answered": 128,
      "busy": 22,
      "no_answer": 140,
      "voicemail": 20
    },
    "talk_seconds": 9120,
    "total": 310
  },
  "campaign_id": "cmp_2Yb7mCq9aPLk",
  "contacts": {
    "by_status": {
      "callback": 3,
      "cancelled": 0,
      "dialing": 5,
      "dnc": 9,
      "done": 120,
      "failed": 6,
      "invalid": 1,
      "pending": 812,
      "scheduled": 40,
      "skipped": 4
    },
    "finished": 140,
    "live": {
      "connected": 1,
      "dialing": 2,
      "ringing": 2
    },
    "total": 1000
  },
  "livemode": true,
  "object": "campaign_stats",
  "outcomes": {
    "interested": 41,
    "not-interested": 60
  },
  "skip_reasons": {
    "dnc_import": 7,
    "no_consent": 4,
    "registry": 2
  }
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 404 Not Found

No object with this ID (in the path or the body) exists in this organisation and mode. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const campaignResults = await mv.campaigns.stats("cmp_7Hk2Lm9Qp");
console.log(campaignResults);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

campaign_results = client.campaigns.stats("cmp_7Hk2Lm9Qp")
print(campaign_results)
```

**cURL**

```sh
curl https://api.morevoice.ai/v1/campaigns/cmp_7Hk2Lm9Qp/stats \
  -H "Authorization: Bearer $MOREVOICE_API_KEY"
```
