Retrieving Leads API docs by Facebook can be found here.
You can find your lead ads forms and form IDs here.
Rate Limits
200 multiplied by 24 multiplied by the number of leads created in the past 30 days for the Facebook page.
Custom Audience Uploads
You can find your Facebook ad account id on the page here. It is in the upper right or in the URL. You should replace it in the above URL with {{ ... }}. So a final URL can look like https://graph.facebook.com/v11.0/act_1234567890/ followed by the endpoint, customaudience
The Data Processing Terms need to be accepted to upload custom audiences: https://business.facebook.com/ads/manage/customaudiences/tos/?act=1234567890
1234567890 has to be replaced with the respective account id.
For app builders: Any app needs at least the scopes ads_management to have access.
1. Creating a custom audience with Curl
1
curl -X POST \
2
-D '{
3
"name":"My new Custom Audience 1",
4
"subtype":"CUSTOM",
5
"description":"People who purchased on my website",
6
"customer_file_source":"USER_PROVIDED_ONLY"
7
}' \
8
-H 'Content-Type: application/json' \
9
-H 'Authorization: Bearer {{ token }}' \
10
https://graph.facebook.com/v12.0/act_{{ my ad account id}}/customaudiences
Copied!
2. Adding mobile device data using Curl
1
curl -X POST \
2
-D '{
3
"payload":{
4
"schema":["MADID"],
5
"data":[
6
[
7
"{{ my mobile device id }}"
8
],
9
[
10
"{{ my mobile device id }}"
11
]
12
]
13
},
14
"session":{
15
"session_id":"{{ some session id }}",
16
"batch_seq":1,
17
"last_batch_flag": true,
18
"estimated_num_total":2
19
}}' \
20
-H 'Content-Type: application/json' \
21
-H 'Authorization: Bearer {{ token }}' \
22
https://graph.facebook.com/v12.0/{{ my audience id}}/users
If your JSON is malformatted, you will get this error: { "error": { "message" : "(#100) Invalid parameter", "type": "OAuthException", "code": 100,"fbtrace_id": "some id" } }
Endpoints
Creating a Custom audience based on CRM or similar data - Customer File Custom Audiences. Creating manually as a user, can be found here https://www.facebook.com/adsmanager/audiences?act=xxxxxaccount_id&tool=AUDIENCES&nav_source=business_manager In order to make this endpoint work, you need to connect it with a business.