PeumeAPI

Ads

Get campaign tree

Shows your campaigns with their ad sets and ads nested inside, with spend and results rolled up at every level.

$0.002 per callRuns on an account you connect

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"
  }
}'

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

pageinteger

Page number (1-based)

Example: 1

limitinteger

Campaigns 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

platformstring

facebook · instagram · tiktok · linkedin · pinterest · google · twitter · openai · reddit · microsoft · amazon · tradedesk …

statusstring

Filter by derived campaign status (post-aggregation). `not_deleted` keeps every status except `cancelled`.

adAccountIdstring

One 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.

pageIdstring

Meta 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.

accountIdstring

Account ID

campaignIdstring

Restrict 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.

updatedSincestring

Returns 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).

searchstring

Case-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.

fromDatestring

Start 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.

toDatestring

End of metrics date range (YYYY-MM-DD). Defaults to today. Max 730-day range.

hasDeliveryboolean

Return 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.

minSpendnumber

Return 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.

sortstring

Campaign 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

timeIncrementinteger

Set 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

dailyLevelstring

Which 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

comparestring

Set 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

resultsboolean

Set 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.

modelstring

With `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

depthstring

How 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

Start free · $1 of calls included

Every API your product needs. One key.

7,267 endpoints, one bill, and you only pay for calls that work.