Quick reference
| Property | Value |
|---|---|
| Platform value | metaads |
| One connected account | One Meta ad account. |
| Supported | Read ad account, campaigns, ad sets, ads and daily account/campaign/ad-set/ad insights; guarded existing-entity pause/enable |
| Features | Ads ✓ |
| Provider approval | Marketing API ads_read for reports; separately approved ads_management for writes; advertiser authorization and live verification pending |
| Token | Long-lived (about 60 days); Reconnect when it expires |
Before you start
The person connecting needs:
- Access to the Meta ad account in Business Manager.
You (the platform owner) need:
- Create a Business app at developers.facebook.com and copy its App ID and App Secret (App settings → Basic).
- Add the Marketing API and request ads_read (ads_management only for reviewed write workflows).
- Facebook Login → Settings → Valid OAuth Redirect URIs: https://YOUR_DOMAIN/auth/callback/metaads
- The connecting user needs access to the ad account in Meta Business Manager.
Permissions (scopes)
Techrace puts these permissions in the login link. The person approves them on the provider's own screen; only approved permissions are granted.
| Permission | Requested by default | Used for |
|---|---|---|
ads_read | Yes | Read the ad account, campaigns, ad sets, ads and insights |
ads_management | Optional | Create paused ads, upload creatives, change status, budgets and bids |
pages_manage_ads | Optional | Boost Page posts (with ads_management and pages_show_list) |
Connect an account
/api/v1/projects/{project_id}/connect-sessionsconnections:writeCreate a connect link with provider "metaads" and send the person's browser to the returned url. return_url is the page in your app where they land afterwards (https, or http://localhost while testing).
curl -X POST "https://YOUR_DOMAIN/api/v1/projects/$TECHRACE_PROJECT_ID/connect-sessions" \
-H "Authorization: Bearer $TECHRACE_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<EOF
{
"customer_id": "$CUSTOMER_ID",
"provider": "metaads",
"return_url": "https://your-app.com/integrations/done"
}
EOFAfter approval the person lands on your return_url with ?connected=metaads&customer_id=…&connection_id=…, or ?error=access_denied|expired|failed&provider=metaads. Your webhook also receives account.connected. Keep the connection_id: every call below uses it.
Read campaigns and insights
/api/v1/projects/{project_id}/ads/queryads:read| resource | Returns |
|---|---|
account | Ad account details |
campaigns | Campaigns |
ad_groups | Ad sets |
ads | Ads |
insights | Metrics; set level (account, campaign, ad_group, ad) and optionally breakdown |
curl -X POST "https://YOUR_DOMAIN/api/v1/projects/$TECHRACE_PROJECT_ID/ads/query" \
-H "Authorization: Bearer $TECHRACE_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<EOF
{
"customer_id": "$CUSTOMER_ID",
"connection_id": "$CONNECTION_ID",
"resource": "insights",
"level": "campaign",
"since": "2026-11-01",
"until": "2026-11-07"
}
EOFMake changes
/api/v1/projects/{project_id}/ads/operationsads:writeEach action has its own required fields (see the Ads group in the API reference). New ads and campaigns are always created paused.
curl -X POST "https://YOUR_DOMAIN/api/v1/projects/$TECHRACE_PROJECT_ID/ads/operations" \
-H "Authorization: Bearer $TECHRACE_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: unique-key-per-change" \
--data @- <<EOF
{
"customer_id": "$CUSTOMER_ID",
"connection_id": "$CONNECTION_ID",
"action": "archive_meta_entity",
"resource": "ad",
"entity_id": "120210000000000045",
"expected_status": "paused",
"confirm_archive": true,
"confirm_ads_may_be_affected": true
}
EOFLimitations
- Reports are read-only by default; writes need ads_management approval from Meta.
- Activating ads (spend) is a separate, explicitly enabled step.
Common errors
| Error | Meaning | Fix |
|---|---|---|
ads_read permission missing | ads_read was not granted. | Reconnect and approve. |
ads_writes_paused / ads_creation_paused | Changes are paused on the server. | Set the matching server switch to false. |
ads_spend_disabled | The change affects spend. | Enable ADS_SPEND_ENABLED and use a key with ads:spend. |