# Export campaign performance as CSV

> POST /v1/properties/{propertyId}/reports/campaigns/export: Returns all the matching rows of the campaign report as one CSV file, in the property time zone, with no summary. The CSV columns are `name`, `refType`, `refId`, then the requested metrics. The request body is the same as for the campaign re

<div class="api-endpoint"><span class="api-method api-method--post">POST</span><span class="api-path">/v1/properties/<span class="api-path-param">&#123;propertyId&#125;</span>/reports/campaigns/export</span></div>

<p>Returns all the matching rows of the campaign report as one CSV file, in the property time zone, with no summary. The CSV columns are <code>name</code>, <code>refType</code>, <code>refId</code>, then the requested metrics. The request body is the same as for the campaign report, without <code>limit</code> and <code>cursor</code>. The file can be at most 1 MB (1,048,576 bytes). For a larger file, the API returns <code>500</code> with the code <code>response_too_large</code>: make the date range shorter or add filters.</p>

## Metrics

<p>Ask for metrics by name in <code>metrics</code>. Each metric becomes a CSV column after <code>name</code>, <code>refType</code>, and <code>refId</code>; dynamic names such as <code>events.Purchase</code> are column names. Unavailable values are empty CSV cells. Money metrics aggregate stored reporting values; the configured reporting currency belongs to the property. Date ranges cover at most 31 days.</p>

<table><thead><tr><th>Metric</th><th>Value</th><th>Source</th></tr></thead><tbody><tr><td><code>spend</code></td><td>Amount spent on the ads.</td><td>Ad platform</td></tr><tr><td><code>impressions</code></td><td>Number of times the ads were shown.</td><td>Ad platform</td></tr><tr><td><code>reach</code></td><td>Sum of ad-platform reach across the requested dates; a person may be counted on multiple days.</td><td>Ad platform</td></tr><tr><td><code>linkClicks</code></td><td>Number of clicks on the ad links.</td><td>Ad platform</td></tr><tr><td><code>results</code></td><td>Results that the ad platform attributes to the ads, for the campaign objective.</td><td>Ad platform</td></tr><tr><td><code>resultValues</code></td><td>Value of the results that the ad platform attributes to the ads.</td><td>Ad platform</td></tr><tr><td><code>sessions</code></td><td>Number of sessions that AnyTrack tracked.</td><td>AnyTrack</td></tr><tr><td><code>clients</code></td><td>Approximate number of distinct property-scoped client IDs (browsers).</td><td>AnyTrack</td></tr><tr><td><code>eventValues</code></td><td>Sum of the values of the conversion events.</td><td>AnyTrack</td></tr><tr><td><code>events.&#60;EventName></code></td><td>Number of events with this name, for example <code>events.Purchase</code>.</td><td>AnyTrack</td></tr><tr><td><code>frequency</code></td><td><code>impressions</code> ÷ <code>reach</code>.</td><td>Calculated</td></tr><tr><td><code>cpm</code></td><td>1,000 × <code>spend</code> ÷ <code>impressions</code>.</td><td>Calculated</td></tr><tr><td><code>cpc</code></td><td><code>spend</code> ÷ <code>linkClicks</code>.</td><td>Calculated</td></tr><tr><td><code>ctr</code></td><td><code>linkClicks</code> ÷ <code>impressions</code>, as a ratio: <code>0.02</code> is 2%.</td><td>Calculated</td></tr><tr><td><code>roas</code></td><td><code>eventValues</code> ÷ <code>spend</code>.</td><td>Calculated</td></tr><tr><td><code>cpe.&#60;EventName></code></td><td><code>spend</code> ÷ the number of events with this name.</td><td>Calculated</td></tr></tbody></table>
<p>A calculated metric is <code>null</code> when its divisor is zero, negative, or unavailable, or another required input is unavailable. Unavailable ad platform metrics are also <code>null</code>. AnyTrack gets spend, impressions, reach, link clicks, and results from Meta Ads, Google Ads, TikTok Ads, ChatGPT Ads, and Microsoft Ads. Taboola and Outbrain campaigns have no ad platform metrics.</p>

## Before you call

This endpoint needs IDs that other endpoints return:

1. Call [List the account properties](/api/reference/v1/list-properties). Copy the `id` of the property: it is the `propertyId`.
2. Call this endpoint with these IDs.

## Authentication

**bearerAuth**: API key created in the dashboard (<code>atk&#95;...</code>). Send it in the `Authorization: Bearer YOUR_API_KEY` header.

## Path parameters

<div class="api-fields">
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">propertyId</code><span class="api-field-type">string</span><span class="api-badge api-badge--required">required</span></div>
<div class="api-field-desc">ID of the property. Get it from <code>listProperties</code> (<code>id</code>).</div>
</div>
</div>

## Request body

<div class="api-media"><span class="api-media-type">application/json</span><span class="api-badge api-badge--required">required</span></div>

<div class="api-schema">
<div class="api-fields">
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">from</code><span class="api-field-type">string · date</span><span class="api-badge api-badge--required">required</span></div>
<div class="api-field-desc">First day of the report, included, in the property time zone. The range covers at most 31 days.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Format</span> YYYY-MM-DD, e.g. <code>2026-01-31</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">to</code><span class="api-field-type">string · date</span><span class="api-badge api-badge--required">required</span></div>
<div class="api-field-desc">Last day of the report, included, in the property time zone. <code>to</code> must be on or after <code>from</code>.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Format</span> YYYY-MM-DD, e.g. <code>2026-01-31</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">attribution</code><span class="api-field-type">string</span></div>
<div class="api-field-desc">Attribution model. <code>last-ad-click</code> gives the credit to the last ad click before the conversion. <code>first-ad-click</code> gives the credit to the first ad click.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Allowed values</span> <code>last-ad-click</code> <code>first-ad-click</code></span><span class="api-fact"><span class="api-fact-label">Default</span> <code>last-ad-click</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">groupBy</code><span class="api-field-type">string</span></div>
<div class="api-field-desc">Level of each row: <code>campaign</code>, <code>adset</code> (ad set), or <code>ad</code>.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Allowed values</span> <code>campaign</code> <code>adset</code> <code>ad</code></span><span class="api-fact"><span class="api-fact-label">Default</span> <code>campaign</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">metrics</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">Metrics to return as CSV columns. Use the metric names in the Metrics section, <code>events.&#60;EventName&#62;</code>, or <code>cpe.&#60;EventName&#62;</code>. AnyTrack removes duplicate names.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>20</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>80</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">conversionEvents</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">Events that count as conversions for <code>eventValues</code> and <code>roas</code>. Defaults to the property conversion events, or <code>Purchase</code> if none are configured. Other named event metrics are independent of this selection.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>20</code></span><span class="api-fact"><span class="api-fact-label">Item min length</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>64</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">filters</code><span class="api-field-type">object</span></div>
<div class="api-field-desc">Filters for the rows. A row must match every filter that you send. A row matches a filter when it matches one of its values.</div>
<details class="api-children">
<summary>Show 6 child attributes</summary>
<div class="api-fields">
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">channel</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">Channels to include. Use the <code>channel</code> values of the report rows. With this filter, rows that have spend but no tracked event are not included.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>50</code></span><span class="api-fact"><span class="api-fact-label">Item min length</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>256</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">platform</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">Platforms to include. With this filter, rows that have spend but no tracked event are not included.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>50</code></span><span class="api-fact"><span class="api-fact-label">Item min length</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>256</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">adNetwork</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">Ad networks to include. Use the <code>adNetwork</code> values of the report rows.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>50</code></span><span class="api-fact"><span class="api-fact-label">Item min length</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>256</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">campaignIds</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">IDs of the campaigns to include. Use the <code>id</code> of rows grouped by <code>campaign</code>.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>50</code></span><span class="api-fact"><span class="api-fact-label">Item min length</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>256</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">adsetIds</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">IDs of the ad sets to include. Use the <code>id</code> of rows grouped by <code>adset</code>.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>50</code></span><span class="api-fact"><span class="api-fact-label">Item min length</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>256</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">adIds</code><span class="api-field-type">array of string</span></div>
<div class="api-field-desc">IDs of the ads to include. Use the <code>id</code> of rows grouped by <code>ad</code>.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Min items</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Max items</span> <code>50</code></span><span class="api-fact"><span class="api-fact-label">Item min length</span> <code>1</code></span><span class="api-fact"><span class="api-fact-label">Item max length</span> <code>256</code></span></div>
</div>
</div>
</details>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">sort</code><span class="api-field-type">object</span></div>
<div class="api-field-desc">Sort order of the rows.</div>
<details class="api-children">
<summary>Show 2 child attributes</summary>
<div class="api-fields">
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">metric</code><span class="api-field-type">string</span><span class="api-badge api-badge--required">required</span></div>
<div class="api-field-desc">Metric to sort by. Use one of the fixed metric names. You cannot sort by <code>events.&#60;EventName&#62;</code> or <code>cpe.&#60;EventName&#62;</code>.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Allowed values</span> <code>spend</code> <code>impressions</code> <code>reach</code> <code>frequency</code> <code>linkClicks</code> <code>sessions</code> <code>clients</code> <code>eventValues</code> <code>results</code> <code>resultValues</code> <code>cpm</code> <code>cpc</code> <code>ctr</code> <code>roas</code></span></div>
</div>
<div class="api-field">
<div class="api-field-head"><code class="api-field-name">direction</code><span class="api-field-type">string</span></div>
<div class="api-field-desc"><code>desc</code>: highest value first. <code>asc</code>: lowest value first.</div>
<div class="api-field-facts"><span class="api-fact"><span class="api-fact-label">Allowed values</span> <code>asc</code> <code>desc</code></span><span class="api-fact"><span class="api-fact-label">Default</span> <code>desc</code></span></div>
</div>
</div>
</details>
</div>
</div>
</div>

## Responses

Every response field is present unless it shows **optional**. A type that ends in `| null` can be `null`.

### 200 Successful response

<div class="api-media"><span class="api-media-type">text/csv</span></div>

<div class="api-schema">
<div class="api-schema-type"><span class="api-field-type">string</span></div>
</div>

### Errors

Every error returns the [error object](/api/reference/v1#errors).

| Status | Description and action |
| --- | --- |
| `400` | <code>invalid&#95;request</code>, <code>invalid&#95;cursor</code>: A parameter or a body field is not valid, or the cursor belongs to a different query. Correct the request. <code>error.details</code>, when present, names invalid fields. Do not reuse a cursor with a different query. |
| `401` | <code>unauthenticated</code>: Missing, invalid or deleted API key. Send a valid key in <code>Authorization: Bearer</code>. MCP uses an OAuth access token, which may also expire or be revoked. |
| `403` | <code>api&#95;access&#95;unavailable</code>: API access is disabled for this account. Contact AnyTrack support. OAuth requests also require the <code>anytrack:read</code> scope (<code>insufficient&#95;scope</code>). |
| `404` | <code>not&#95;found</code>: An ID does not exist, or it belongs to a different account. The API gives the same error for both. Check the IDs. Get them again from the list endpoints. |
| `413` | <code>payload&#95;too&#95;large</code>: The request body is larger than 16 KB. Send a smaller request body. |
| `429` | <code>rate&#95;limited</code>: The account sent more than 60 requests in one minute. Wait for the number of seconds in the <code>Retry-After</code> header, then retry. |
| `500` | <code>response&#95;too&#95;large</code>, <code>internal&#95;error</code>: The response is larger than 1 MB, or the API has an internal error. For <code>response&#95;too&#95;large</code>, ask for fewer rows or metrics. For <code>internal&#95;error</code>, contact AnyTrack support with the <code>requestId</code>. |
| `503` | <code>service&#95;unavailable</code>: The service is not available for a short time. Retry later, and wait longer after each failed retry. |
| `504` | <code>upstream&#95;timeout</code>: A downstream request timed out (the report client timeout is 65 seconds). Narrow the date range, then retry with backoff. |

## Request example

Command template. Replace the path placeholders. Put the request body in request-body.json, as in the schema above. Add the query parameters that you need. This is not a recorded request or response.

```sh
curl --request POST 'https://api.anytrack.io/v1/properties/{propertyId}/reports/campaigns/export' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data @request-body.json
```

[Download the OpenAPI contract](/api/openapi.json).
