# Meta Ads plugin

The Meta Ads plugin lets a Vaubaan Gateway mission use Meta Ads without handing the agent a credential. Meta ads through the Marketing API: read campaigns, ad sets, ads and results, pause, change a daily budget or a bid within the ceiling the owner sets, create paused campaigns, and activate.

Version `0.1.0` · 5 permissions · 3 macro-actions · 13 tools · 0 gateways run this plugin (over the last 90 days).

## How Meta Ads is modelled

1 plane, 5 things. The things that exist at the service and how they nest. Every permission is written over these; a resource of an account is one of them, named by its ref.

- **Account** — One account is one System User token of your own Business Manager.
  - Plane `ads` — A Meta ad account: its campaigns, ad sets, ads and their results.
    - `account` (1 n; the resource; carries the environment, in the model only) — The resource: a Meta ad account, with its currency and the ceilings its owner set.
      - `campaign` (1 *) — A campaign: an objective and, possibly, a budget.
      - `adset` (1 *) — An ad set: a budget, a bid and an audience.
      - `ad` (1 *) — An ad of an ad set.
      - `insights` (1) — Synthetic: Meta's reporting over the account (spend, impressions, results).

Marks: 1 exactly one, named; n a finite, known set; * an unknown number, possibly all.

- **Account**: One account is one System User token of your own Business Manager.
- **Resource**: One resource is one ad account it was given. Each ad account carries two ceilings its owner sets, max\_daily\_budget and max\_bid, in major units of its currency (\['50'\] is 50 per day): no budget or bid change is accepted without them or above them, and an activation, which starts spending, is the highest permission.
- **Environment**: No permission of this service depends on an environment: each is held once, whatever the resource. Known: none. Carried by: `ads.account`, in the model only.

## What an agent does at Meta Ads: 3 macro-actions

A mission is made of them: the person ticks the ones the task needs and sets each to a trust level.

1. **Read ads and results** — Read ad accounts, campaigns, ad sets, ads and their results. Following how the ads do: what runs, what it costs, what it brings. Nothing changes in the ad account. (1 permission)
2. **Pause and adjust spend** — Pause what spends badly, change a budget or a bid within the ceiling. Cutting what does not work and shifting money to what does: pausing an ad set, lowering a budget, raising another. No budget or bid goes above the ceiling the owner set on the ad account, in major units of its currency. (2 permissions)
3. **Prepare and launch campaigns** — Create paused campaigns, and activate campaigns, ad sets and ads. Preparing a campaign that spends nothing, then switching ads on. An activation starts spending at once, publicly; it is the step that costs money. (2 permissions)

## The map

5 permissions of 3 macro-actions, in the four rows of the tree. For the chosen trust level, each cell gives yes, ask me or no, and the quota a day.

Careful ×1: Mild actions run freely; sensitive or costly ones ask first; irreversible ones are left out. Trusting ×3: Up to sensitive actions run freely; costly and irreversible ones ask first. Limits ×3. Autonomous ×10: Everything but irreversible actions runs freely; those ask first. Limits ×10.

yes: runs freely; ask me: ask me first; no: not included. A permission sits in the first row its facts answer: irreversible; costly to undo or unbounded cost; secret or personal data, whole account or bulk, moderate cost, public; otherwise harmless.

### Cannot be repaired

Careful: no. Trusting, Autonomous: ask me.

- Prepare and launch campaigns: Activate a campaign, an ad set or an ad `meta-ads.activate`, irreversible — Spending starts at once, at whatever budget the object carries, and the ads show publicly; money spent is not refunded. Careful: no · Trusting: ask me · 30 a day · Autonomous: ask me · 100 a day.

### Repairable, at a price

Careful, Trusting: ask me. Autonomous: runs freely.

- Pause and adjust spend: Change a daily budget or a bid, within the ceiling `meta-ads.budget-write`, costly to undo — Money is committed, up to the ceiling the owner set on the ad account; what is spent before it is changed back is spent. Careful: ask me · 20 a day · Trusting: ask me · 60 a day · Autonomous: yes · 200 a day.

### Worth a look

Careful: ask me. Trusting, Autonomous: runs freely.

None.

### Harmless

Runs freely at every level.

- Read ads and results: Read ad accounts, campaigns, ad sets, ads and results `meta-ads.read-ads` — Names, statuses, budgets and spend of the ad account come back to the agent. Nothing changes. Careful: yes · 1,000 a day · Trusting: yes · 3,000 a day · Autonomous: yes · 10,000 a day.
- Pause and adjust spend: Pause a campaign, an ad set or an ad `meta-ads.pause` — Spending stops and the ads stop showing; resuming them is an activation, under its own permission. Careful: yes · 50 a day · Trusting: yes · 150 a day · Autonomous: yes · 500 a day.
- Prepare and launch campaigns: Create a paused campaign `meta-ads.create-paused` — A campaign is created paused: it spends nothing until it is activated. Careful: yes · 10 a day · Trusting: yes · 30 a day · Autonomous: yes · 100 a day.

Careful: runs freely 3, ask me first 1, not included 1.
Trusting: runs freely 3, ask me first 2.
Autonomous: runs freely 4, ask me first 1.

Limits are counted over a mission's period: a day unless its creator picks another, or the mission's whole life for a one-off. The figures here are per day.

## A few calls, classified by the plugin

14 declared calls, run through the plugin's own classifier when this page was built; here one per macro-action and the first the catalog refuses at Careful. [The 14 calls, as code](https://github.com/vaubaan/gateway/blob/main/plugins/meta-ads/src/examples.ts).

- `meta_ads__list_ad_accounts {}`
  - the plugin sees: `meta-ads.account[*].R`
  - the catalog answers: Read ad accounts, campaigns, ad sets, ads and results `meta-ads.read-ads`
  - a Careful mission: yes
- `meta_ads__pause {"level":"adset","id":"120200000000000002"}`
  - the plugin sees: `meta-ads.account[1234567890].adset[120200000000000002].pause.W`
  - the catalog answers: Pause a campaign, an ad set or an ad `meta-ads.pause`
  - a Careful mission: yes
- `meta_ads__activate {"level":"ad","id":"120200000000000003"}`
  - the plugin sees: `meta-ads.account[1234567890].ad[120200000000000003].activate.W`
  - the catalog answers: Activate a campaign, an ad set or an ad `meta-ads.activate`
  - a Careful mission: no

## Anything else

A call no permission covers touches `meta-ads.uncategorized-write` instead of slipping through. No macro-action holds it; a person ticks it knowingly.

| Permission | Risk | Careful ×1 | Trusting ×3 | Autonomous ×10 |
| --- | --- | --- | --- | --- |
| Uncategorized write `meta-ads.uncategorized-write`: Catch-all for writes without a dedicated entry. No tool of this plugin reaches it; seeing it means an entry is missing. | Repairable, at a price (costly to undo) | ask me · 50 a day | ask me · 150 a day | yes · 500 a day |

## Tools

13 tools. A tool's permissions depend on its arguments, so a mission is made of the macro-actions above, not of tools.

| Tool | What it does | Usually touches |
| --- | --- | --- |
| `meta_ads__list_ad_accounts` | List ad accounts | `meta-ads.read-ads` |
| `meta_ads__list_campaigns` | List campaigns | `meta-ads.read-ads` |
| `meta_ads__get_campaign` | Read a campaign | `meta-ads.read-ads` |
| `meta_ads__list_ad_sets` | List ad sets | `meta-ads.read-ads` |
| `meta_ads__get_ad_set` | Read an ad set | `meta-ads.read-ads` |
| `meta_ads__list_ads` | List ads | `meta-ads.read-ads` |
| `meta_ads__get_ad` | Read an ad | `meta-ads.read-ads` |
| `meta_ads__get_insights` | Read ad results | `meta-ads.read-ads` |
| `meta_ads__pause` | Pause ads | `meta-ads.pause` |
| `meta_ads__activate` | Activate ads | `meta-ads.activate` |
| `meta_ads__set_daily_budget` | Change a daily budget | `meta-ads.budget-write` |
| `meta_ads__set_bid` | Change a bid | `meta-ads.budget-write` |
| `meta_ads__create_campaign` | Create a paused campaign | `meta-ads.create-paused` |

## Connecting an account

**1 of 3 · a key you create and paste** — `System User token`

A System User token the person creates at Meta Ads and pastes once; nobody declares anything beforehand.

**Ad accounts** — The ad accounts the agents work on, with ads\_read and ads\_management. This gateway gives a mission only the ad accounts and permissions it names, and refuses any budget or bid above the ceiling the owner sets on each ad account, in major units of its currency.

1. Sign in to Meta Business Settings as an admin of the business that owns the ad accounts.
2. **Business Settings › Users › System users › Add** — Open the system users page and add a system user for this gateway. ([open](https://business.facebook.com/settings/system-users))
3. **Assign assets › Ad accounts › Manage campaigns** — Add the ad accounts the agents will work on to it, with the permission to manage campaigns.
4. **Generate new token › Permissions › Token expiration** — Generate a token for an app of your business, tick the two permissions below, and choose Never for the expiry.
5. Copy the token and paste it here, then set each ad account's ceilings on its page: max\_daily\_budget and max\_bid, as \["50"\] for 50 in the account's currency.

| Permission at Meta Ads | Access |
| --- | --- |
| ads\_read | read |
| ads\_management | read-write |

Where: [https://business.facebook.com/settings/system-users](https://business.facebook.com/settings/system-users)

Expiry: A system user token set to never expire lasts until it is revoked: remove the system user or its token in Business Settings to end this account.

The connect page asks: System User token (secret).

The service's documentation: [https://developers.facebook.com/documentation/ads-commerce/marketing-api/get-started/authorization](https://developers.facebook.com/documentation/ads-commerce/marketing-api/get-started/authorization)

Disconnecting: In Meta Business Settings, open Users, then System users, and remove the system user or revoke its token.

## Health

0 gateways run this plugin (over the last 90 days).

No version of this plugin has reported a call or a gateway yet.

A version is marked validated by the community with at least 200 reports and a success rate of at least 90 %, over the last 90 days; a gateway shows that mark on the accounts of this service. The figures are refreshed at most hourly ([what they mean](/plugins/health)). It is a community signal, not a security guarantee.

Calls are counted over the last 90 days from the instances that share plugin health. Gateways are counted over the same window among the instances that also share usage statistics, so they are a lower bound. The success rate leaves out calls refused for a rejected credential: a revoked token is the user's configuration, not the plugin.

## Links

- [Connect a Meta Ads account](/plugins/meta-ads#connect)
- [How Meta Ads is modelled](https://github.com/vaubaan/gateway/blob/main/docs/handbook/services/meta-ads.md)
- [The catalog, as code](https://github.com/vaubaan/gateway/blob/main/plugins/meta-ads/src/risk-catalog.yaml)
- [The plugin source](https://github.com/vaubaan/gateway/tree/main/plugins/meta-ads)
- The page: [/plugins/meta-ads](/plugins/meta-ads)
