Skip to content
techrace/
TECHRACE DOCUMENTATION

Meta Ads

Connect Meta ad accounts, read campaigns and insights, and make guarded changes such as pausing, archiving and creating paused ads.

Quick reference

PropertyValue
Platform valuemetaads
One connected accountOne Meta ad account.
SupportedRead ad account, campaigns, ad sets, ads and daily account/campaign/ad-set/ad insights; guarded existing-entity pause/enable
FeaturesAds ✓
Provider approvalMarketing API ads_read for reports; separately approved ads_management for writes; advertiser authorization and live verification pending
TokenLong-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:

  1. Create a Business app at developers.facebook.com and copy its App ID and App Secret (App settings → Basic).
  2. Add the Marketing API and request ads_read (ads_management only for reviewed write workflows).
  3. Facebook Login → Settings → Valid OAuth Redirect URIs: https://YOUR_DOMAIN/auth/callback/metaads
  4. 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.

PermissionRequested by defaultUsed for
ads_readYesRead the ad account, campaigns, ad sets, ads and insights
ads_managementOptionalCreate paused ads, upload creatives, change status, budgets and bids
pages_manage_adsOptionalBoost Page posts (with ads_management and pages_show_list)

Connect an account

POST/api/v1/projects/{project_id}/connect-sessionsconnections:write

Create 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"
}
EOF

After 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

POST/api/v1/projects/{project_id}/ads/queryads:read
resourceReturns
accountAd account details
campaignsCampaigns
ad_groupsAd sets
adsAds
insightsMetrics; 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"
}
EOF

Make changes

POST/api/v1/projects/{project_id}/ads/operationsads:write

Each 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
}
EOF

Limitations

  • Reports are read-only by default; writes need ads_management approval from Meta.
  • Activating ads (spend) is a separate, explicitly enabled step.

Common errors

ErrorMeaningFix
ads_read permission missingads_read was not granted.Reconnect and approve.
ads_writes_paused / ads_creation_pausedChanges are paused on the server.Set the matching server switch to false.
ads_spend_disabledThe change affects spend.Enable ADS_SPEND_ENABLED and use a key with ads:spend.