# Flexible live insights query

Returns the flexible live insights query, one page at a time. Works with Meta Ads, Google Ads and TikTok Ads.

```http
GET https://api.pozy.ai/v1/ads/insights
```

- Area: Ads / Ad Insights
- Auth: Authorization: Bearer pz_live_...

## Query parameters

- `accountId` (string, required)
- `objectId` (string)
- `query` (string)
- `adAccountId` (string)
- `reportType` (string): one of BASIC, AUDIENCE
- `dataLevel` (string): one of AUCTION_ADVERTISER, AUCTION_CAMPAIGN, AUCTION_ADGROUP, AUCTION_AD
- `dimensions` (string)
- `metrics` (string)
- `page` (integer)
- `pageSize` (integer)
- `customerId` (string)
- `pageToken` (string)
- `level` (string): one of ad, adset, campaign, account
- `fields` (string)
- `breakdowns` (string)
- `actionBreakdowns` (string)
- `actionAttributionWindows` (string)
- `actionReportTime` (string)
- `useUnifiedAttributionSetting` (boolean)
- `filtering` (string)
- `datePreset` (string)
- `fromDate` (string (date))
- `toDate` (string (date))
- `timeIncrement` (string)
- `limit` (integer)
- `after` (string)

## Example request

```bash
curl -X GET "https://api.pozy.ai/v1/ads/insights?accountId=696e0b682d0a31188e7a2ba9&limit=25" \
  -H "Authorization: Bearer $POZY_API_KEY"
```

```ts
const res = await fetch("https://api.pozy.ai/v1/ads/insights?accountId=696e0b682d0a31188e7a2ba9&limit=25", {
  headers: { Authorization: `Bearer ${process.env.POZY_API_KEY}` },
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.get(
    "https://api.pozy.ai/v1/ads/insights",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    params={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "limit": 25,
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `objectId`, string
- `adAccountId`, string
- `customerId`, string
- `fieldMask`, string: Can be null
- `data`, array of object
- `paging`, object
  - `after`, string: Can be null
  - `nextPageToken`, string: Can be null
  - `page`, integer
  - `pageSize`, integer
  - `totalRows`, integer
  - `totalPages`, integer

```json
{
  "objectId": "6cd1b53a19a7e157d2d46b68",
  "adAccountId": "666219aad7bab67ace411e4f",
  "customerId": "691909ff82eb5ed7c816716d",
  "fieldMask": "string",
  "data": [
    {}
  ],
  "paging": {
    "after": "string",
    "nextPageToken": "string",
    "page": 1,
    "pageSize": 1,
    "totalRows": 42,
    "totalPages": 42
  }
}
```
