Get campaign tree
Returns a nested Campaign > Ad Set > Ad hierarchy with rolled-up metrics at each level. Uses a two-stage aggregation: ads are grouped into ad sets, then ad sets into campaigns. Metrics are computed over an optional date range, then rolled up from ad level to ad set and campaign levels. Pagination is at the campaign level. Ads without a campaign or ad set ID are grouped into synthetic "Ungrouped" buckets. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max.
API key authentication - use your Zernio API key as a Bearer token
In: header
Query Parameters
Page number (1-based)
11 <= valueCampaigns per page
201 <= value <= 100all (default) returns both Zernio-created ads and those discovered from the platform's ad manager — matches the web UI's default view. Pass zernio to restrict to isExternal=false only. Status is NOT filtered by default — use the status param for that.
"all""zernio" | "all""facebook" | "instagram" | "tiktok" | "linkedin" | "pinterest" | "google" | "twitter"Filter by derived campaign status (post-aggregation)
"active" | "paused" | "pending_review" | "rejected" | "completed" | "cancelled" | "error"Platform ad account ID
Social account ID
Profile ID
Start of metrics date range (YYYY-MM-DD). Defaults to 90 days ago.
dateEnd of metrics date range (YYYY-MM-DD). Defaults to today. Max 730-day range.
dateCampaign-level sort order. newest (default) / oldest order by the campaign's newest-ad createdAt. spend_desc / spend_asc order by aggregated spend in the requested date range; campaigns with no spend land at the end.
"newest""newest" | "oldest" | "spend_desc" | "spend_asc"Response Body
application/json
application/json
import Zernio from '@zernio/node';const zernio = new Zernio({ apiKey: process.env.ZERNIO_API_KEY });const { data } = await zernio.adcampaigns.getAdTree();console.log(data);{
"campaigns": [
{
"platformCampaignId": "string",
"platform": "facebook",
"campaignName": "string",
"status": "active",
"reviewStatus": "in_review",
"platformCampaignStatus": "string",
"campaignIssuesInfo": [
{}
],
"adCount": 0,
"adSetCount": 0,
"budget": {
"amount": 0,
"type": "daily"
},
"campaignBudget": {
"amount": 0,
"type": "daily"
},
"budgetLevel": "campaign",
"isBudgetScheduleEnabled": false,
"currency": "string",
"metrics": {
"spend": 0,
"impressions": 0,
"reach": 0,
"clicks": 0,
"ctr": 0,
"cpc": 0,
"cpm": 0,
"engagement": 0,
"conversions": 0,
"costPerConversion": 0,
"actions": {
"link_click": 160,
"post_engagement": 300,
"offsite_conversion.fb_pixel_purchase": 42
},
"actionValues": {
"offsite_conversion.fb_pixel_purchase": 2456.78,
"offsite_conversion.fb_pixel_add_to_cart": 980.5
},
"purchaseValue": 0,
"roas": 0,
"lastSyncedAt": "2019-08-24T14:15:22Z"
},
"platformAdAccountId": "string",
"platformAdAccountName": "string",
"accountId": "string",
"profileId": "string",
"platformObjective": "string",
"optimizationGoal": "string",
"bidStrategy": "LOWEST_COST_WITHOUT_CAP",
"bidAmount": 0,
"roasAverageFloor": 0,
"promotedObject": {
"custom_event_type": "string",
"pixel_id": "string",
"page_id": "string"
},
"adSets": [
{
"platformAdSetId": "string",
"adSetName": "string",
"status": "active",
"adCount": 0,
"budget": {
"amount": 0,
"type": "daily"
},
"adSetBudget": {
"amount": 0,
"type": "daily"
},
"metrics": {
"spend": 0,
"impressions": 0,
"reach": 0,
"clicks": 0,
"ctr": 0,
"cpc": 0,
"cpm": 0,
"engagement": 0,
"conversions": 0,
"costPerConversion": 0,
"actions": {
"link_click": 160,
"post_engagement": 300,
"offsite_conversion.fb_pixel_purchase": 42
},
"actionValues": {
"offsite_conversion.fb_pixel_purchase": 2456.78,
"offsite_conversion.fb_pixel_add_to_cart": 980.5
},
"purchaseValue": 0,
"roas": 0,
"lastSyncedAt": "2019-08-24T14:15:22Z"
},
"optimizationGoal": "string",
"bidStrategy": "LOWEST_COST_WITHOUT_CAP",
"bidAmount": 0,
"roasAverageFloor": 0,
"promotedObject": {
"custom_event_type": "string",
"pixel_id": "string",
"page_id": "string"
},
"ads": [
{
"_id": "string",
"name": "string",
"platform": "facebook",
"status": "active",
"adType": "boost",
"goal": "engagement",
"isExternal": true,
"budget": {
"amount": 0,
"type": "daily"
},
"metrics": {
"spend": 0,
"impressions": 0,
"reach": 0,
"clicks": 0,
"ctr": 0,
"cpc": 0,
"cpm": 0,
"engagement": 0,
"conversions": 0,
"costPerConversion": 0,
"actions": {
"link_click": 160,
"post_engagement": 300,
"offsite_conversion.fb_pixel_purchase": 42
},
"actionValues": {
"offsite_conversion.fb_pixel_purchase": 2456.78,
"offsite_conversion.fb_pixel_add_to_cart": 980.5
},
"purchaseValue": 0,
"roas": 0,
"lastSyncedAt": "2019-08-24T14:15:22Z"
},
"platformAdId": "string",
"platformAdAccountId": "string",
"platformCampaignId": "string",
"platformAdSetId": "string",
"campaignName": "string",
"adSetName": "string",
"platformObjective": "OUTCOME_SALES",
"optimizationGoal": "OFFSITE_CONVERSIONS",
"platformAdAccountName": "Zernio - previously Late",
"platformCreatedAt": "2019-08-24T14:15:22Z",
"bidStrategy": "LOWEST_COST_WITHOUT_CAP",
"bidAmount": 5,
"roasAverageFloor": 2,
"promotedObject": {
"custom_event_type": "PURCHASE",
"pixel_id": "string",
"page_id": "string",
"application_id": "string",
"product_set_id": "string"
},
"creative": {
"thumbnailUrl": "string",
"imageUrl": "string",
"videoId": "string",
"videoUrl": "string",
"objectType": "string",
"objectStoryId": "string",
"effectiveObjectStoryId": "string",
"effectiveInstagramMediaId": "string",
"instagramUserId": "string",
"instagramPermalinkUrl": "string",
"mediaUrls": [
"string"
],
"body": "string",
"googleHeadline": "string",
"googleDescription": "string",
"linkUrl": "string",
"pinterestImageUrl": "string",
"pinterestTitle": "string",
"pinterestDescription": "string"
},
"targeting": {},
"schedule": {
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z"
},
"rejectionReason": "string",
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z"
}
]
}
]
}
],
"pagination": {
"page": 0,
"limit": 0,
"total": 0,
"pages": 0
}
}{
"error": "Unauthorized"
}List campaigns GET
Returns campaigns as virtual aggregations over ad documents grouped by platform campaign ID. Metrics (spend, impressions, clicks, etc.) are summed across all ads in each campaign. Campaign status is derived from child ad statuses (active > pending_review > paused > error > completed > cancelled > rejected).
Get daily aggregate ad metrics for an account GET
Returns daily aggregate metrics across all ads in a SocialAccount as a single time series — one row per calendar day in the requested range. Use this for dashboards that draw a daily-spend or daily-conversions chart, instead of calling `/v1/ads/tree` once per day. `accountId` is required. The lookup is sibling-expanded so passing the `metaads` ID also includes ads under the linked `facebook` / `instagram` posting account (and vice-versa) — same convention as `/v1/ads/tree` and `/v1/ads`. Date range defaults to the last 90 days. Capped at 730 days. Ranges older than the 90-day cache window trigger an on-demand backfill from the platform before returning.