# Meta Ads

> The Meta Graph API connection AdOps evaluates rules against: it reads campaign entities and batched Insights, and writes campaign status, budget and name.

Source: https://adops.id/integrations/meta-ads/
Last updated: 2026-08-20
Publisher: AdOps (https://adops.id) — an independent product, not affiliated with Meta Platforms, Inc.

---

## Key facts

- **Graph API version:** Read from the FACEBOOK_VERSION setting, with v18.0 as the in-code fallback (Meta's paging cursors are re-pinned to the configured version before they are re-issued.)
- **Entities per page:** 1,000, with automatic cursor paging until the account is exhausted
- **Entity fetch retries:** 3 attempts in total, waiting 1 second then 2 seconds
- **Insights cost per campaign:** 1 batched request covering every reporting period in the rule
- **HTTP timeout:** 30 seconds per Graph API call
- **Write level:** Conditions evaluate at campaign or ad set level; every write action is campaign-shaped

**AdOps reads:** Campaign or ad set entities from the ad account's edge, requesting only the name and created time fields; Server-side filtering on campaign ID, campaign name and campaign effective status, so Meta narrows the account before it answers; Up to 1,000 entities per page, following Meta's own paging cursor until the list is exhausted; Insights, batched into a single Graph request carrying one relative URL per reporting period the rule uses; Only the Insights fields a rule's conditions actually name, de-duplicated across those conditions; Single-object reads for daily budget, name, remaining budget and lifetime budget, issued only when a rule asks for them; The /me endpoint for token verification and /me/adaccounts for ad-account discovery

**AdOps writes:** Campaign status: ACTIVE to start, PAUSED to pause, DELETED to delete; Daily budget: increase, decrease or set, written as a whole number and clamped to the rule's maximum or minimum cap; Campaign name: append rendered text, remove a substring, or replace one substring with another; A deep copy of a campaign, submitted as an async batch job against the campaign's copies edge

AdOps connects to Meta Ads through the Marketing (Graph) API using an access token created when the ad account is connected. It reads campaign entities and batched Insights to evaluate a rule's conditions, then writes four things back: campaign status, daily budget, campaign name, and a deep copy of a campaign.

## What does AdOps read from Meta Ads?

Two kinds of data. First, entities. AdOps lists the ad account's campaigns or ad sets, asking for only the name and created time fields, and pushes the rule's pre-filters into the request so Meta narrows the account before answering. Campaign ID, campaign name and campaign effective status are all filterable server-side. Pages come back 1,000 entities at a time and AdOps follows Meta's own paging cursor until there are no more.

Second, Insights. Rather than one call per condition, AdOps groups every condition by its reporting period, unions and de-duplicates the fields each period needs, then sends the whole set as one Graph batch request per campaign. A rule comparing today against the last 7 days and the last 30 days costs one round trip, not three. That batched request is issued with the unified attribution setting, so the numbers a rule evaluates use the attribution window configured on the ad set.

A handful of values are not Insights fields and are fetched separately, on demand only. Daily budget, remaining budget and lifetime budget are read from the campaign object, and AdOps issues that extra call only when a rule actually references one of them.

## What does AdOps write back?

Four write paths, all at campaign level. Status changes post `ACTIVE`, `PAUSED` or `DELETED`. Budget actions increase, decrease or set the daily budget, computed as a flat amount, a percentage of the current budget, or a custom-metric result; the projected figure is floored to a whole number and clamped, so a rule that would cross its maximum cap writes exactly the cap instead. Name actions append rendered text, strip a substring or replace one substring with another. Duplication submits an async batch job against the campaign's copies edge with deep copy enabled.

Before a budget write, AdOps re-reads the live daily budget from Meta; before a name write, it re-reads the live name. Neither is taken from the copy carried in the job, so an edit made in Ads Manager between the fetch and the write is not silently overwritten with a stale figure. Budget and name changes record the value before and the value after on the rule result.

## How does AdOps keep the API cost down?

By asking for less. The Insights field list per period is derived from the rule's own conditions rather than requesting the full Insights surface, and metrics that are not Insights fields at all, such as time-of-day conditions and custom metrics, are filtered out of the request entirely. Entity fetches request two fields. Object reads are conditional.

## What happens when the Graph API fails?

Fetching an account's entities is retried, 3 attempts in total with 1-second then 2-second waits, and an account that still fails is skipped so the rest of the sweep continues. Parsing a batched Insights response is retried up to 3 attempts before the failure is logged with its full request context. Every write goes through one instrumented wrapper that captures the function, the message, the request body and Meta's own error response into a deduplicated error log, so a recurring API fault appears once with a count rather than as thousands of identical lines.

AdOps is an independent product and is not affiliated with Meta Platforms. Meta, Facebook and Ads Manager are trademarks of Meta Platforms, Inc.
