> For the complete documentation index, see [llms.txt](https://docs.heypoplar.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.heypoplar.com/api/endpoints/stats.md).

# Stats

The Stats API provides aggregated mailing performance data across your campaigns. Use these endpoints to pull circulation and spend metrics for reporting and analytics integrations.

### Fetch Campaign Stats

<mark style="color:blue;">`GET`</mark> `https://api.heypoplar.com/v1/stats/campaigns`

Returns aggregated stats across all campaigns for your organization, including total circulation, total spend, and a paginated list of per-campaign breakdowns. Optionally filter by date range.

**Headers**

<table><thead><tr><th width="178.80859375">Name</th><th width="193.61328125">Type</th><th>Description</th></tr></thead><tbody><tr><td>Authorization<mark style="color:red;">*</mark></td><td>string</td><td><em><mark style="color:blue;">Bearer ProductionAccessToken</mark></em></td></tr></tbody></table>

**Query Parameters**

<table><thead><tr><th width="178.77734375">Name</th><th width="189.578125">Type</th><th>Description</th></tr></thead><tbody><tr><td>start_date</td><td>string</td><td><p>ISO8601 date to limit results to campaigns with activity on or after this date</p><p>Example: <code>2024-01-01</code></p></td></tr><tr><td>end_date</td><td>string</td><td><p>ISO8601 date to limit results to campaigns with activity on or before this date</p><p>Example: <code>2024-03-31</code></p></td></tr><tr><td>page</td><td>number</td><td><p>Page of results to return</p><p>default: <code>1</code> maximum: <code>10000</code></p></td></tr><tr><td>per_page</td><td>number</td><td><p>Number of campaigns to return per page</p><p>default: <code>25</code> maximum: <code>30</code></p></td></tr></tbody></table>

{% tabs %}
{% tab title="200: OK Returns aggregated stats and campaign list" %}

```json
{
    "total_circulation": 45200,
    "total_spend": 29380.00,
    "total_campaign_count": 3,
    "start_date": "2024-01-01",
    "end_date": "2024-03-31",
    "page": 1,
    "total_pages": 1,
    "campaigns": [
        {
            "campaign_id": "25358f3d-121e-4b07-b2fa-4ed8c7054ac1",
            "campaign_name": "Prospecting USA Q1 2024",
            "circulation": 20000,
            "spend": 13000.00
        },
        {
            "campaign_id": "aef13242-e4a9-4494-857f-2acc1c3337f6",
            "campaign_name": "Retargeting Spring 2024",
            "circulation": 15200,
            "spend": 9880.00
        },
        {
            "campaign_id": "c4b37e00-9163-4b4e-be3e-65fea6f5a165",
            "campaign_name": "New Movers March 2024",
            "circulation": 10000,
            "spend": 6500.00
        }
    ]
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid date range" %}

```json
{
    "error": "ValidationError",
    "message": "start_date must be less than or equal to end_date"
}
```

{% endtab %}
{% endtabs %}

***

### Fetch Campaign Stats by ID

<mark style="color:blue;">`GET`</mark> `https://api.heypoplar.com/v1/stats/campaign/:id`

Returns circulation and spend stats for a single campaign.

**Headers**

<table><thead><tr><th width="173.5078125">Name</th><th width="196.8984375">Type</th><th>Description</th></tr></thead><tbody><tr><td>Authorization<mark style="color:red;">*</mark></td><td>string</td><td>Bearer <em><mark style="color:blue;">ProductionAccessToken</mark></em></td></tr></tbody></table>

**Path Parameters**

<table><thead><tr><th width="180.109375">Name</th><th width="193.85546875">Type</th><th>Description</th></tr></thead><tbody><tr><td>id<mark style="color:red;">*</mark></td><td>string</td><td>Campaign ID</td></tr></tbody></table>

**Query Parameters**

<table><thead><tr><th width="178.77734375">Name</th><th width="189.578125">Type</th><th>Description</th></tr></thead><tbody><tr><td>start_date</td><td>string</td><td><p>ISO8601 date to limit results to campaigns with activity on or after this date</p><p>Example: <code>2024-01-01</code></p></td></tr><tr><td>end_date</td><td>string</td><td><p>ISO8601 date to limit results to campaigns with activity on or before this date</p><p>Example: <code>2024-03-31</code></p></td></tr></tbody></table>

{% tabs %}
{% tab title="200: OK Returns stats for the campaign" %}

```json
{
    "campaign_id": "25358f3d-121e-4b07-b2fa-4ed8c7054ac1",
    "campaign_name": "Prospecting USA Q1 2024",
    "circulation": 20000,
    "spend": 13000.00
}
```

{% endtab %}

{% tab title="404: Not Found Campaign does not exist" %}

```json
{
    "error": "CampaignNotFound",
    "message": "Campaign does not exist"
}
```

{% endtab %}
{% endtabs %}

***

### Response Fields

#### Collection (stats/campaigns)

| Field                  | Type    | Description                                                      |
| ---------------------- | ------- | ---------------------------------------------------------------- |
| total\_circulation     | integer | Total number of pieces mailed across all campaigns in the result |
| total\_spend           | float   | Total spend in USD across all campaigns in the result            |
| total\_campaign\_count |         |                                                                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.heypoplar.com/api/endpoints/stats.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
