Ads through the API
Read ad accounts, quote and start a boost, and hear about boosts, through the API, the command line and MCP.
You can do what the Ads guide does in the app from your own code: read ad accounts and their numbers, quote and start a boost, and hear about it by webhook. It works through the API, the SDKs, the command line and MCP.
Through the API
The ads group is under /api/v1/ads, and the paths below start there. Each operation needs the permission in its last column:
| Operation | Request | What it does | Needs |
|---|---|---|---|
ads.status |
GET / |
Says what the instance offers: off, read or spend, and the networks |
ads:read |
ads.listConnections |
GET /connections |
Lists the sign-ins to ad networks, never a token | ads:read |
ads.connect |
POST /connections/{network} |
Starts a sign-in, and answers the page to send the browser to | ads:manage, in person |
ads.completeConnect |
POST /connections/{network}/callback |
Completes it, and answers the ad accounts it reaches | ads:manage, in person |
ads.reachableAccounts |
GET /connections/{connectionId}/accounts |
Lists the ad accounts a sign-in reaches now | ads:manage, who signed in |
ads.connectAccounts |
POST /connections/{connectionId}/accounts |
Connects some of them, by externalIds |
ads:manage, who signed in |
ads.disconnect |
DELETE /connections/{connectionId} |
Removes a sign-in and the accounts it connects | ads:manage |
ads.listAccounts |
GET /accounts |
Lists the connected ad accounts | ads:read |
ads.getAccount |
GET /accounts/{accountId} |
Shows one, with what its boosts commit this month | ads:read |
ads.removeAccount |
DELETE /accounts/{accountId} |
Disconnects one | ads:manage |
ads.setSpending |
PUT /accounts/{accountId}/spending |
Turns its spending on or off, with a monthly ceiling | ads:authorize, in person |
ads.listCampaigns |
GET /accounts/{accountId}/campaigns |
Lists its campaigns, with what their ads did over some days | ads:read |
ads.listAds |
GET /accounts/{accountId}/ads |
Lists its ads, those of one campaign with campaignId |
ads:read |
ads.listInsights |
GET /accounts/{accountId}/insights |
Sums what its ads did each day | ads:read |
ads.postPerformance |
GET /posts/{postId} |
Shows a post’s organic and paid numbers, and its boosts | ads:read |
ads.quoteBoost |
POST /boosts/quote |
Checks a boost and says what it would commit, reserving nothing | ads:spend |
ads.createBoost |
POST /boosts |
Spends money. Boosts a published post. Answers 202 | ads:spend |
ads.listBoosts |
GET /boosts |
Lists the boosts, newest first, 50 a page, those of a post with postId |
ads:read |
ads.getBoost |
GET /boosts/{boostId} |
Shows a boost, with the journal of the requests sent for it | ads:read |
ads.pauseBoost |
POST /boosts/{boostId}/pause |
Pauses it | ads:spend or ads:manage |
ads.resumeBoost |
POST /boosts/{boostId}/resume |
Spends money. Runs a paused boost again | ads:spend |
ads.stopBoost |
POST /boosts/{boostId}/stop |
Stops it for good | ads:spend or ads:manage |
ads.auditTrail |
GET /audit |
Lists the audit trail, 100 lines a page | ads:authorize |
The three reports take from and to, calendar days of the account such as 2026-11-01. Both are included, at most 366 days apart, and you get the last 30 days when you leave them out. Campaigns and ads come a thousand at most. ads.listBoosts and ads.auditTrail answer a nextCursor, which you pass as cursor for the next page.
Each ad account says what its network allows in capabilities: ads, boosts, reach and results. Hide whatever is false. A Google Ads account (network is google) has all four false, because Peal only reads it:
- Its campaigns carry their own daily numbers, and a
kindsuch asSEARCHorPERFORMANCE_MAX. ads.listAdsanswers no ads for it.reachreads 0, andresultsis null.- Turning its spending on answers
AdSpendingUnavailable.
On a Google Ads account, reachedThrough names the manager account Peal reads it through.
The SDKs have the same operations in their ads group (peal.ads.quoteBoost, peal.ads.createBoost…). The command line has them under peal ads.
Quote, then boost
Ask for a quote, show it to whoever decides, then send the same body to create the boost. The quote reserves nothing. The CLI takes the budget in the currency’s units (--total 50), and the API in minor units (5000).
import { PealClient } from "@peal-social/sdk";
const peal = new PealClient({ token: process.env.PEAL_API_KEY });
const boost = {
accountId: "019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
postId: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
channelId: "019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90",
budget: { kind: "total" as const, amount: 5000 },
currency: "EUR",
endsAt: "2026-11-19T09:00:00.000Z",
audience: { countries: ["FR", "BE"], ageMin: 25, ageMax: 54 },
specialAdCategory: "none" as const,
beneficiary: "Example Bakery SAS",
payer: "Example Bakery SAS",
};
const quote = await peal.ads.quoteBoost(boost);import os
from peal import BoostAudience, BoostBudget, Peal
peal = Peal(token=os.environ["PEAL_API_KEY"])
boost = dict(
account_id="019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
post_id="019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
channel_id="019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90",
budget=BoostBudget(kind="total", amount=5000),
currency="EUR",
ends_at="2026-11-19T09:00:00.000Z",
audience=BoostAudience(countries=["FR", "BE"], age_min=25, age_max=54),
special_ad_category="none",
beneficiary="Example Bakery SAS",
payer="Example Bakery SAS",
)
quote = peal.ads.quote_boost(**boost)import (
"context"
"os"
peal "github.com/peal-social/peal/packages/peal-sdk/go"
"github.com/peal-social/peal/packages/peal-sdk/go/client"
"github.com/peal-social/peal/packages/peal-sdk/go/option"
)
// The client is named `client`, so that `peal` stays the package of the
// request types.
client := client.NewClient(option.WithToken(os.Getenv("PEAL_API_KEY")))
ctx := context.Background()
boost := &peal.NewBoost{
AccountID: "019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
PostID: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
ChannelID: "019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90",
Budget: &peal.BoostBudget{Kind: peal.BoostBudgetKindTotal, Amount: 5000},
Currency: "EUR",
EndsAt: "2026-11-19T09:00:00.000Z",
Audience: &peal.BoostAudience{Countries: []string{"FR", "BE"}, AgeMin: 25, AgeMax: 54},
SpecialAdCategory: peal.SpecialAdCategoryNone,
Beneficiary: peal.String("Example Bakery SAS"),
Payer: peal.String("Example Bakery SAS"),
}
quote, err := client.Ads.QuoteBoost(ctx, boost)require "peal"
peal = Peal::Client.new(token: ENV.fetch("PEAL_API_KEY"))
boost = {
account_id: "019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
post_id: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
channel_id: "019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90",
budget: { kind: "total", amount: 5000 },
currency: "EUR",
ends_at: "2026-11-19T09:00:00.000Z",
audience: { countries: ["FR", "BE"], ageMin: 25, ageMax: 54 },
special_ad_category: "none",
beneficiary: "Example Bakery SAS",
payer: "Example Bakery SAS"
}
quote = peal.ads.quote_boost(**boost)import java.util.List;
import social.peal.PealClient;
import social.peal.types.BoostAudience;
import social.peal.types.BoostBudget;
import social.peal.types.BoostBudgetKind;
import social.peal.types.BoostQuote;
import social.peal.types.NewBoost;
import social.peal.types.SpecialAdCategory;
PealClient peal = PealClient.builder()
.token(System.getenv("PEAL_API_KEY"))
.build();
NewBoost boost = NewBoost.builder()
.accountId("019a7902-1f4b-7a60-9c12-7d8e0f2a4b55")
.audience(BoostAudience.builder()
.ageMax(54)
.ageMin(25)
.countries(List.of("FR", "BE"))
.build())
.budget(BoostBudget.builder()
.amount(5000)
.kind(BoostBudgetKind.TOTAL)
.build())
.channelId("019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90")
.currency("EUR")
.endsAt("2026-11-19T09:00:00.000Z")
.postId("019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01")
.specialAdCategory(SpecialAdCategory.NONE)
.beneficiary("Example Bakery SAS")
.payer("Example Bakery SAS")
.build();
BoostQuote quote = peal.ads().quoteBoost(boost);<?php
use Peal\PealClient;
use Peal\Types\BoostAudience;
use Peal\Types\BoostBudget;
use Peal\Types\BoostBudgetKind;
use Peal\Types\NewBoost;
use Peal\Types\SpecialAdCategory;
$peal = new PealClient(token: getenv('PEAL_API_KEY'));
$boost = new NewBoost([
'accountId' => '019a7902-1f4b-7a60-9c12-7d8e0f2a4b55',
'postId' => '019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01',
'channelId' => '019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90',
'budget' => new BoostBudget(['kind' => BoostBudgetKind::Total->value, 'amount' => 5000]),
'currency' => 'EUR',
'endsAt' => '2026-11-19T09:00:00.000Z',
'audience' => new BoostAudience(['countries' => ['FR', 'BE'], 'ageMin' => 25, 'ageMax' => 54]),
'specialAdCategory' => SpecialAdCategory::None->value,
'beneficiary' => 'Example Bakery SAS',
'payer' => 'Example Bakery SAS',
]);
$quote = $peal->ads->quoteBoost($boost);using Peal;
var peal = new PealClient(Environment.GetEnvironmentVariable("PEAL_API_KEY")!);
var boost = new NewBoost
{
AccountId = "019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
PostId = "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
ChannelId = "019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90",
Budget = new BoostBudget { Kind = BoostBudgetKind.Total, Amount = 5000 },
Currency = "EUR",
EndsAt = "2026-11-19T09:00:00.000Z",
Audience = new BoostAudience
{
Countries = new List<string> { "FR", "BE" },
AgeMin = 25,
AgeMax = 54,
},
SpecialAdCategory = SpecialAdCategory.None,
Beneficiary = "Example Bakery SAS",
Payer = "Example Bakery SAS",
};
var quote = await peal.Ads.QuoteBoostAsync(boost);use peal_sdk::prelude::*;
let peal = PealClient::new(ClientConfig {
token: std::env::var("PEAL_API_KEY").ok(),
..Default::default()
})?;
let boost = NewBoost::builder()
.account_id("019a7902-1f4b-7a60-9c12-7d8e0f2a4b55")
.post_id("019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01")
.channel_id("019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90")
.budget(BoostBudget {
amount: 5000,
kind: BoostBudgetKind::Total,
})
.currency("EUR")
.ends_at("2026-11-19T09:00:00.000Z")
.audience(BoostAudience {
countries: vec!["FR".to_string(), "BE".to_string()],
age_min: 25,
age_max: 54,
})
.special_ad_category(SpecialAdCategory::None)
.beneficiary("Example Bakery SAS")
.payer("Example Bakery SAS")
.build()?;
let quote = peal.ads.quote_boost(&boost, None).await?;curl https://api.example.com/api/v1/ads/boosts/quote \
-H "Authorization: Bearer $PEAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accountId": "019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
"postId": "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"channelId": "019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90",
"budget": { "kind": "total", "amount": 5000 },
"currency": "EUR",
"endsAt": "2026-11-19T09:00:00.000Z",
"audience": { "countries": ["FR", "BE"], "ageMin": 25, "ageMax": 54 },
"specialAdCategory": "none",
"beneficiary": "Example Bakery SAS",
"payer": "Example Bakery SAS"
}'peal ads boost quote \
--account 019a7902-1f4b-7a60-9c12-7d8e0f2a4b55 \
--post 019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01 \
--channel 019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90 \
--total 50 --currency EUR \
--ends 2026-11-19T09:00:00Z \
--countries FR,BE --age-min 25 --age-max 54 \
--not-special-category \
--beneficiary "Example Bakery SAS" --payer "Example Bakery SAS"The quote answers these fields:
commitment, and thedaysthe run touches.- The
ceiling, and what the account’s other boosts already commit in the fullest month the run touches (committed). capRoom, which is null when the account has no cap of its own.startsAt,endsAt,currencyandminorUnitDigits.
Create the boost with the body you quoted and a new key:
const created = await peal.ads.createBoost({
"idempotency-key": "3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61",
body: boost,
});created = peal.ads.create_boost(
idempotency_key="3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61",
**boost,
)created, err := client.Ads.CreateBoost(ctx, &peal.CreateBoostAdsRequest{
IdempotencyKey: "3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61",
Body: boost,
})created = peal.ads.create_boost(
idempotency_key: "3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61",
**boost
)import social.peal.resources.ads.requests.CreateBoostAdsRequest;
import social.peal.types.Boost;
Boost created = peal.ads().createBoost(CreateBoostAdsRequest.builder()
.idempotencyKey("3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61")
.body(boost)
.build());use Peal\Ads\Requests\CreateBoostAdsRequest;
$created = $peal->ads->createBoost(new CreateBoostAdsRequest([
'idempotencyKey' => '3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61',
'body' => $boost,
]));var created = await peal.Ads.CreateBoostAsync(new CreateBoostAdsRequest
{
IdempotencyKey = "3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61",
Body = boost,
});// NewBoost has no field for the key: it goes in the request's headers.
let created = peal
.ads
.create_boost(
&boost,
Some(RequestOptions::new().additional_header(
"Idempotency-Key",
"3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61",
)),
)
.await?;curl https://api.example.com/api/v1/ads/boosts \
-H "Authorization: Bearer $PEAL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61" \
-d '{
"accountId": "019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
"postId": "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"channelId": "019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90",
"budget": { "kind": "total", "amount": 5000 },
"currency": "EUR",
"endsAt": "2026-11-19T09:00:00.000Z",
"audience": { "countries": ["FR", "BE"], "ageMin": 25, "ageMax": 54 },
"specialAdCategory": "none",
"beneficiary": "Example Bakery SAS",
"payer": "Example Bakery SAS"
}'peal ads boost create \
--account 019a7902-1f4b-7a60-9c12-7d8e0f2a4b55 \
--post 019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01 \
--channel 019a5d14-6a2c-7b85-8f3d-1e2c4a6b8d90 \
--total 50 --currency EUR \
--ends 2026-11-19T09:00:00Z \
--countries FR,BE --age-min 25 --age-max 54 \
--not-special-category \
--beneficiary "Example Bakery SAS" --payer "Example Bakery SAS" \
--idempotency-key 3c8e1f2a-6b4d-4e7a-9f10-2d5c7b9e4a61It answers 202 with the boost, requested. Read it again, or listen for its events, to learn whether it runs.
ads.getBoost answers its steps, the journal of what Peal sent the network. Each step says when, and how it ended: done, refused, or found, absent or unknown when a lost answer was looked up.
Errors
Errors come in the API’s format, each with a code in snake case next to its name (Errors). These are the ones ads add:
| Status | Error | When |
|---|---|---|
| 404 | AdsUnavailable |
Ads are off on the instance, or the network asked for is not set up on it. |
| 409 | AdSpendingUnavailable |
The instance offers ads for reading only. Nothing was spent or changed. |
| 422 | AdSignInFailed |
A sign-in did not come to a connection. reason: denied, expired, failed, or notConfigured when the instance has no key to encrypt with. |
| 404 | AdConnectionNotFound |
No such sign-in, or it is another member’s. |
| 404 | AdAccountNotFound |
No such ad account, or the sign-in does not reach the account asked for. |
| 404 | BoostNotFound |
No such boost. |
| 503 | AdNetworkUnavailable |
The network did not answer, asked to slow down, or could not confirm a change. Nothing is known to have changed. retryAfterSeconds says when to retry, if the network said. |
| 409 | AdAccountBusy |
boosts boosts of the account run, may run, are being made or, for a disconnection, are paused: stop them first. |
| 409 | AdAccountUnusable |
The account cannot take a boost now. reason: status, reconnectNeeded or permission. |
| 409 | AdSpendingNotEnabled |
No owner allowed this ad account to spend through Peal. |
| 409 | SpendCeilingExceeded |
The boost would pass the monthly ceiling: ceiling, committed, requested, in minor units of currency. |
| 409 | AdAccountSpendCapExceeded |
The account’s own cap leaves room, and the boost would commit requested. |
| 422 | CeilingCurrencyMismatch |
The ceiling is not in the account’s currency, which accountCurrency gives. |
| 422 | BoostInvalid |
The boost breaks Peal’s rules. violations lists every one (see the next table). |
| 422 | PostNotPromotable |
The post cannot be boosted there. reason: notPublished, platform, or connection for an Instagram account connected with Instagram Login. |
| 409 | BoostStateConflict |
The boost’s state does not allow this: one that failed, ended or was stopped does not run again, and only a paused one resumes. |
| 409 | BoostKeyReused |
The Idempotency-Key already names a boost that asked for something else. |
A BoostInvalid error lists these violations:
violations |
What is wrong |
|---|---|
currencyMismatch |
The budget’s currency is not the ad account’s. |
budgetEmpty |
The budget is zero. |
endsBeforeStart |
The run ends before it starts, or has ended. |
runTooShort |
The run is shorter than a day, or, with a daily budget, not longer than one. |
runTooLong |
The run is longer than 90 days. |
startsTooFarAhead |
The run starts more than 30 days ahead. |
ageRange |
The youngest age is above the oldest. |
specialCategory |
The ad is of a special category, which Peal does not boost. |
beneficiaryRequired |
The audience is in the European Union, and the beneficiary or the payer is missing. |
The API reference lists each endpoint’s parameters and answers.
Webhook events
A webhook endpoint can subscribe to eight boost events. They all carry the same data: ids, amounts and where the boost stands, never its audience.
| Event | When |
|---|---|
boost.started |
A boost runs on its ad network, and may spend |
boost.paused |
A member paused a boost |
boost.resumed |
A member ran a paused boost again |
boost.stopped |
A member stopped a boost for good |
boost.ended |
A boost’s end date passed |
boost.failed |
A boost could not be made, and nothing ran |
boost.unconfirmed |
Peal cannot tell whether a boost runs: it may be spending |
boost.budget_reached |
A boost spent its whole total budget |
Here’s a boost.started delivery:
{
"id": "019a6f40-2f6b-7a1c-9d2e-5b4c3a2f1e10",
"type": "boost.started",
"version": 1,
"timestamp": "2026-11-12T09:00:41.000Z",
"workspaceExternalId": null,
"data": {
"workspaceId": "7b1f6c1e-2d4a-4f0b-9c3e-5a8d2e6f1b90",
"postId": "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"boostId": "019a7a10-5c3e-7d21-8b40-2e6f9a1c3d01",
"adAccountId": "019a7902-1f4b-7a60-9c12-7d8e0f2a4b55",
"budget": {
"amount": 5000,
"kind": "total"
},
"committed": 5000,
"currency": "EUR",
"endsAt": "2026-11-19T09:00:00.000Z",
"state": "active",
"reason": null
}
}
Webhooks describes each field, and has an example of each of the eight.
Command line and MCP
The command line has the ads commands under peal ads. Run peal ads --help for the list.
AI assistants have ads tools, which follow the same permissions and the same rules. A tool that spends says so in its description, and needs the application to hold workspace:publish and workspace:ads.
Neither one signs in to an ad network, turns spending on or changes a ceiling. A person does those in the web app.
The MCP tools leave Google Ads accounts out, as Google’s policy for tools asks of an MCP server. They list Meta’s accounts only, and refuse a Google Ads account with the reason. The command line shows both.