Meta Ads

Meta Ads

Meta Ads uses a long-lived access token tied to your ad account. You generate the token once in Meta's developer tools and it lasts 60 days. adduck can remind you when it's about to expire.

Required credentials

FieldDescription
accessTokenA long-lived user access token with ads_read and ads_management permissions.
adAccountIdYour Meta ad account ID in the format act_XXXXXXXXXX.

Step 1: Create a Meta app

Go to developers.facebook.com/apps and create an app.

Step 2: Generate an access token

Go to developers.facebook.com/tools/explorer.

Select your app, click "Generate Access Token", and grant the ads_read and ads_management permissions. This gives you a short-lived token (1 hour).

To convert it to a long-lived token (60 days), call:

curl -X GET \
  "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&fb_exchange_token=YOUR_SHORT_TOKEN"

Use the access_token value from the response.

Step 3: Find your ad account ID

In Ads Manager, click the account name dropdown at the top. Your account ID is the number shown -- prefix it with act_ for adduck.

Example: if your account ID is 123456789, use act_123456789.

Step 4: Connect to adduck

adduck auth login meta

Manual config

{
  "accounts": {
    "meta": {
      "accessToken": "EAAxxxxxxxxxxxxxxxxxxxxx",
      "adAccountId": "act_123456789"
    }
  }
}

Token refresh

Long-lived tokens last 60 days. adduck checks the token expiry on startup and warns you when it's within 7 days of expiring. When it expires, run adduck auth login meta to replace it.

For fully automated setups (no human present to re-auth), use a system user token from Meta Business Manager, which has no expiry. See Meta's documentation on system users.

Multiple ad accounts

Configure as an array to connect multiple Meta ad accounts:

{
  "accounts": {
    "meta": [
      { "accessToken": "EAAaaa...", "adAccountId": "act_111" },
      { "accessToken": "EAAbbb...", "adAccountId": "act_222" }
    ]
  }
}