Call it
curl https://api.peume.com/v1/call/get-campaign-tree \
-H "Authorization: Bearer $PEUME_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"page": 1,
"limit": 20,
"source": "all",
"sort": "newest",
"dailyLevel": "campaign",
"model": "last_click"
}
}'const res = await fetch("https://api.peume.com/v1/call/get-campaign-tree", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PEUME_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"input": {
"page": 1,
"limit": 20,
"source": "all",
"sort": "newest",
"dailyLevel": "campaign",
"model": "last_click"
}
}),
});
const { output, cost_usd } = await res.json();import os, requests
res = requests.post(
"https://api.peume.com/v1/call/get-campaign-tree",
headers={"Authorization": f"Bearer {os.environ['PEUME_API_KEY']}"},
json={
"input": {
"page": 1,
"limit": 20,
"source": "all",
"sort": "newest",
"dailyLevel": "campaign",
"model": "last_click"
}
},
)
print(res.json()["output"])Answer: {"id": "run_…", "status": "completed", "cost_usd": …, "output": {…}}. Long jobs answer 202 with a run id to read later. From an AI agent, connect the MCP server and ask for this by name: get-campaign-tree.
Parameters
pageintegerPage number (1-based)
Example: 1
limitintegerCampaigns per page
Example: 20
sourcestring`all` (default) returns both -created ads and those discovered from the platform's ad manager. Matches the web UI's default view. Pass `` to restrict to isExternal=false only. Status is NOT filtered by default; use the `status` param for that.
peume · all
Example: all
platformstringfacebook · instagram · tiktok · linkedin · pinterest · google · twitter · openai · reddit · microsoft · amazon · tradedesk …
statusstringFilter by derived campaign status (post-aggregation). `not_deleted` keeps every status except `cancelled`.
adAccountIdstringOne or more platform ad account IDs to scope the tree to (agency profiles connect a whole Business Manager, but a team usually cares about a subset). - Comma-separate for multiple (`?adAccountId=act_1,act_2,act_3`); a single value keeps its old shape. - Max 50 accounts per request. - The plural aliases `adAccountIds` and `platformAdAccountIds` are rejected with a 400, so they cannot silently return the unfiltered fleet.
pageIdstringMeta only: Facebook Page ID. Prunes the tree to ads whose creative is backed by this Page: campaigns and ad sets with no ad on the Page drop out, and rolled-up metrics cover only the Page's ads. Mirrors the same filter on /v1/ads and /v1/ads/campaigns.
accountIdstringAccount ID
campaignIdstringRestrict the tree to one or more campaigns by platform campaign id (the id the platform assigns, e.g. Meta's numeric campaign id). Comma-separate up to 100 ids (`?campaignId=123,456`). Filters the campaign set itself, so it works regardless of account size and pagination. Use it when you already hold campaign ids (e.g. from an `ad.status_changed` webhook) instead of paging the whole tree.
updatedSincestringReturns only campaigns with a change stored since this time (ISO 8601 with offset, e.g. `2026-09-30T10:00:00Z`). Each matching campaign comes back whole (every ad set and ad). - A change is a new ad, or a change to any ad's status, review status, name, budget or creative. - Metrics are not a change: to refresh numbers, filter with `hasDelivery=true` and a date range instead. - Combines with every other filter (with `hasDelivery`/`minSpend` a campaign must match both).
searchstringCase-insensitive substring match on campaign, ad set and ad names (`_`, `%` and spaces match literally), or an exact platform campaign, ad set or ad id. - A campaign whose name matches returns with all its ad sets and ads. - A match on an ad set or ad name returns only the matching branch. - Filters the campaign set itself, so `pagination.total` counts only matching campaigns.
fromDatestringStart of the METRICS date range (YYYY-MM-DD). On its own it affects only the spend/impression numbers overlaid on each node, not which campaigns are returned. Pass `hasDelivery` or `minSpend` to also filter the campaign set to this window. Defaults to 90 days ago.
toDatestringEnd of metrics date range (YYYY-MM-DD). Defaults to today. Max 730-day range.
hasDeliverybooleanReturn only campaigns that delivered between `fromDate` and `toDate`: spend above zero, or impressions served at zero spend. Unlike `status`, which reads a campaign's CURRENT state, this filters on what happened inside the window, so a campaign that spent then and is paused today is still returned. It filters the campaign set itself, so `pagination.total` counts only matching campaigns.
minSpendnumberReturn only campaigns whose spend between `fromDate` and `toDate` reaches this amount. Expressed in each campaign's OWN currency (the `currency` field on the campaign node): spend is stored per ad account in its native currency and one response can span several. Implies `hasDelivery`; `minSpend=0` applies no filter.
sortstringCampaign order. `newest` (default) / `oldest`: by the newest ad's createdAt. `spend_*`: by spend in the date range. `results_*` / `cost_per_result_*`: by results, or spend per result, for each campaign's objective (reach summed across its ads); no-result campaigns end a cost order.
newest · oldest · spend_desc · spend_asc · results_desc · results_asc · cost_per_result_asc · cost_per_result_desc
Example: newest
timeIncrementintegerSet to `1` to also return a daily breakdown (mirrors Meta Insights' `time_increment=1`). Only `1` (daily) is supported. See `dailyLevel` to control which levels carry it. Each node gains a `daily[]` array of per-day metrics (same fields as the aggregated `metrics`) next to the range total, so you get per-entity daily trends in ONE call instead of one tree call per day. The daily series covers the same date range and source data as `metrics`, except `reach` on Meta and TikTok: the range total is the platform's de-duplicated value, so daily reach does not sum to it.
1
dailyLevelstringWhich tree levels get the `daily[]` series when `timeIncrement=1`. Ignored when `timeIncrement` is unset. - `campaign` (default): on campaign nodes only. The common per-campaign-trend case, and the smallest payload. - `adset`: on ad sets too. - `ad`: on every ad in `ads[]` as well. Heaviest (a long range × up to 100 ads per ad set); scope with `campaignId` to keep responses small.
campaign · adset · ad
Example: campaign
comparestringSet to `previous` to also read the period of the same length that ends the day before `fromDate`. Every campaign, ad set and ad gains `previousMetrics` (same fields as `metrics`) and the response gains `previousRange`, so a table can show the change against the previous period in one call.
previous
resultsbooleanSet to `true` to add your own results (see [Campaign results](/guides/campaign-results)): every campaign gains `results`, the values you sent for the range plus each formula they allow, and the response gains `resultMetrics` to label them.
modelstringWith `results=true`: the attribution model your stored sales and leads count under in `results`. Uploaded values are the same under every model.
last_click · first_touch · last_non_direct · linear · position_based · time_decay · w_shaped
Example: last_click
depthstringHow deep the tree goes. Metrics always roll up over every ad, whatever the depth. - `ad` (default): campaigns, their ad sets and each ad set's ads. - `adset`: campaigns and ad sets; every `ads[]` is empty and `adCount` still counts the ads. - `campaign`: campaigns only; every `adSets[]` is empty and `adSetCount` / `adCount` still count them.
campaign · adset · ad
Example: ad
