This guide walks you through setting up Facebook Lead Generation API integration for your application.
- Facebook App with Lead Generation permissions
- Page Admin access to the Facebook Page
- App ID and App Secret from your Facebook App
- Navigate to Facebook Graph API Explorer
- Generate a User access token with permissions for Page + App
Make a GET request to retrieve your page access token:
GET /me/accounts
Copy the Page Access Token and Page ID from the response.
Subscribe your app to the page for lead generation events:
POST /PAGEID/subscribed_apps?access_token={TOKEN}&subscribed_fields=leadgen
Replace:
PAGEID
with your Page ID{TOKEN}
with your Page Access Token
Check that your app is properly subscribed:
GET /PAGEID/subscribed_apps
Convert your short-lived token to a long-lived token for production use:
GET https://graph.facebook.com/v22.0/oauth/access_token?grant_type=fb_exchange_token&client_id={FB_APP_ID}&client_secret={FB_APP_SECRET}&fb_exchange_token={CURRENT_TOKEN}
Replace:
{FB_APP_ID}
with your Facebook App ID{FB_APP_SECRET}
with your Facebook App Secret{CURRENT_TOKEN}
with your current access token
- Access Token Debugger: https://developers.facebook.com/tools/debug/accesstoken/
- Lead Ads Testing Tool: https://developers.facebook.com/tools/lead-ads-testing
📝 Make sure your app has the necessary permissions for lead generation before proceeding with the setup.