Call it
curl https://api.peume.com/v1/call/connect-ads-for-a-platform \
-H "Authorization: Bearer $PEUME_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"identityProvider": "microsoft",
"loginMode": "classic",
"permissionLevel": "full",
"headless": false,
"force": false,
"platform": "facebook"
}
}'const res = await fetch("https://api.peume.com/v1/call/connect-ads-for-a-platform", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PEUME_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"input": {
"identityProvider": "microsoft",
"loginMode": "classic",
"permissionLevel": "full",
"headless": false,
"force": false,
"platform": "facebook"
}
}),
});
const { output, cost_usd } = await res.json();import os, requests
res = requests.post(
"https://api.peume.com/v1/call/connect-ads-for-a-platform",
headers={"Authorization": f"Bearer {os.environ['PEUME_API_KEY']}"},
json={
"input": {
"identityProvider": "microsoft",
"loginMode": "classic",
"permissionLevel": "full",
"headless": False,
"force": False,
"platform": "facebook"
}
},
)
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: connect-ads-for-a-platform.
Parameters
identityProviderstringMicrosoft Ads only. How the user signs in to: `google` for a login that is a Google account. `google` on any other platform returns 400 `invalid_field_value`.
microsoft · google
Example: microsoft
loginModestringauthorization mode. Business login is opt-in for Facebook and Instagram; classic preserves the posting-account flow.
classic · business
Example: classic
permissionLevelstringBusiness login only. Ad-account permission the connection's system user will hold. - `full`: asks the owner for Full control (MANAGE). Required to create pixels and other account-level assets through. - `advertise`: asks for Manage campaigns (ADVERTISE), enough for campaigns, ad sets, creatives, ads, media and reporting. For owners who will not grant billing-level control to an integration. Either way, Meta only lets a business admin complete the grant. 503 if the advertise configuration is not set up.
full · advertise
Example: full
scopesstring`ads_read` connects read-only: every ad write through the connection answers 403 `ads_connection_read_only`, and reads and insights work as usual. - facebook, linkedin and pinterest: the platform is asked only for its ads read scopes (Meta `ads_read`, LinkedIn `r_ads` and `r_ads_reporting`, Pinterest `ads:read` and `pins:read`). - googleads, microsoftads, snapchatads, tiktok and twitter have no read-only OAuth scope: the consent screen is the same as for `ads`, and only enforces read-only. For Amazon Ads pass `scopes=ads_read` on `GET /v1/connect/amazonads`. - 400 `INVALID_FIELD_VALUE`
ads · ads_read
pageIdstringBusiness login only. Facebook Page ID to select from the token grants for ad creatives and lead forms.
accountIdstringExisting SocialAccount ID. - `twitter` (X Ads): required. - `tiktok`: optional. Omit it for ads-only mode (no TikTok posting account linked; ad creation uses a Brand Identity instead of a TT_USER). - Same-token platforms (`facebook`, `instagram`, `linkedin`, `pinterest`): picks which posting account the ads connection uses when the profile holds several of that platform. With one, it can be omitted. - Standalone platforms (`googleads`, `redditads`, `microsoftads`, `snapchatads`): ignored. On same-token platforms, an id that names no active account of the platform on the profile is ignored. E
redirect_urlstringCustom URL the browser is sent to once the OAuth flow finishes. When omitted, the browser lands on the dashboard. Honored on every ads platform, including the separate-token (`tiktok`, `twitter`) and standalone (`googleads`, `redditads`, `microsoftads`) flows. MUST be an absolute http(s) URL or a custom app scheme for mobile deeplinks (e.g. myapp://callback). A relative path is rejected with 400 INVALID_REDIRECT_URL. On success: - `tiktok`: lands on the URL unchanged. - `twitter`, `googleads`, `redditads`, `microsoftads` and `snapchatads`: append `connected` (the ads platform id: `xa
headlessbooleanEnable headless mode (same-token platforms only)
Example: false
forcebooleanForce a fresh OAuth even when an account already exists. Normally the endpoint returns `alreadyConnected: true` whenever a connected account is found, keyed off its active state rather than token liveness. Set `force=true` to bypass that and always receive an `authUrl`. Completing the returned OAuth refreshes the stored token on the existing posting and ads accounts in place. An `alreadyConnected` response re-runs ad discovery and webhook subscriptions in the background at most once every 15 minutes per ads account (always when the call changes the ad-account scope), so it is not a sync trig
Example: false
adAccountIdstringScopes ad sync to a single platform ad account. Without it, sync covers every ad account the connected token can see. For multiple accounts use `adAccountIds` instead. Supported on: - `facebook`/`instagram` (Meta): `act_<digits>`. - `linkedin`: bare numeric sponsored-account id. - `googleads`: bare customer id digits. - `redditads`: Reddit ad account id, `a2_<id>` or `t2_<id>`. - `microsoftads`: bare numeric account id (the Id, not the account number). - `snapchatads`: Snapchat ad account UUID. - `twitter` (X Ads): base36 account id. - `tiktok`: numeric advertiser id. `pinteres
adAccountIdsarrayScope ad sync to multiple platform ad accounts (same platform support and id shapes as `adAccountId`). Repeat the param (`?adAccountIds=act_1&adAccountIds=act_2`) or comma-separate (`?adAccountIds=act_1,act_2`). - Persisted server-side. On a connection not split into one account per ad account, the latest call wins, and de-scoped ad accounts have their synced ads, campaigns, ad sets and keywords removed. - Where ad accounts are already split into one account each, the call only adds accounts for new ids and never removes one (disconnect that account instead). - At most 25 ids per call; more r
welcomebooleanWhen `true`, `authUrl` opens on the -hosted welcome screen with your brand, as on GET /v1/connect/{platform}, naming the ads platform ("<brandName> wants to connect to your "). - With no `redirect_url`, the flow ends on the branded result page instead of the dashboard. - Shown only with `welcome=true`: the workspace's saved "on by default" (`PUT /v1/connect/welcome-screen`) applies to GET /v1/connect/{platform} only, so ads links behave as before unless you opt in. The saved brand still fills in what the call leaves out. - Without `adAccountId` or `adAccountIds`, on Meta,
brandNamestringWelcome screen only: your product name in its heading. Same rules as on GET /v1/connect/{platform}.
logoUrlstringWelcome screen only: https URL of your square logo. Rejected with 400 `INVALID_FIELD_VALUE` when the welcome screen is not shown.
primaryColorstringWelcome screen only: hex colour (`#RRGGBB`) of its button.
welcomeThemestringWelcome screen only: a URL-encoded JSON object restyling and rewording the welcome screen and the result page, with the keys documented on GET /v1/connect/{platform}. Rejected when the welcome screen is not shown.
platformRequiredstringPlatform to connect ads for. Only platforms with ads support are accepted. In classic mode, `instagram` requires an Instagram account connected with loginMethod=facebook_login whose token carries ads_management and ads_read. With an account connected through the default instagram_login flow no ads account can be created; do not use this value for those accounts.
facebook · instagram · linkedin · tiktok · twitter · pinterest · googleads · redditads · microsoftads · snapchatads
