ad_id or campaign_id, you will need:ads_management permissionpages_read_engagement permissionpages_show_list permissionpages_manage_metadata permission - if using webhooksads_management permissionleads_retrieval permissionpages_show_list permissionpages_read_engagement permissionpages_manage_ads permissionGET request to the /ads/lead_gen/export_csv/ endpoint where date formats are either POSIX or UNIX timestamps.curl -i -X GET "https://www.facebook.com/ads/lead_gen/export_csv/
?id=<FORM_ID>
&type=form
&from_date=1482698431
&to_date=1482784831"
from_date is not set or is less than the form creation time, the form creation time is used.to_date is not set or is greater than the present time, current time is used.is_organic in the TSV displays 1; otherwise, the value is 0.array( "object" => "page", "entry" => array( "0" => array( "id" => 153125381133, "time" => 1438292065, "changes" => array( "0" => array( "field" => "leadgen", "value" => array( "leadgen_id" => 123123123123, "page_id" => 123123123, "form_id" => 12312312312, "adgroup_id" => 12312312312, "ad_id" => 12312312312, "created_time" => 1440120384 ) ), "1" => array( "field" => "leadgen", "value" => array( "leadgen_id" => 123123123124, "page_id" => 123123123, "form_id" => 12312312312, "adgroup_id" => 12312312312, "ad_id" => 12312312312, "created_time" => 1440120384 ) ) ) ) ) )
leadgen_id to retrieve data associated with the lead:curl -X GET \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<LEAD_ID>
{ "created_time": "2015-02-28T08:49:14+0000", "id": "<LEAD_ID>", "ad_id": "<AD_ID>", "form_id": "<FORM_ID>", "field_data": [{ "name": "car_make", "values": [ "Honda" ] }, { "name": "full_name", "values": [ "Joe Example" ] }, { "name": "email", "values": [ "joe@example.com" ] }, { "name": "selected_dealer", "values": [ "99213450" ] }], ... }
leads_retrieval permission is required to read leads.leads exists on both ad group and form nodes. This returns all data associated with their respective objects. Because a form can be re-used for many ads, your form could contain far more leads than an ad using it.curl -X GET \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<AD_ID>/leads
curl -G \
-d 'access_token=<ACCESS_TOKEN>' \
-d 'fields=created_time,id,ad_id,form_id,field_data' \
https://graph.facebook.com/<API_VERSION>/<FORM_ID>/leads
{
"data": [
{
"created_time": "2018-02-28T08:49:14+0000",
"id": "<LEAD_ID>",
"ad_id": "<AD_ID>",
"form_id": "<FORM_ID>",
"field_data": [
{
"name": "car_make",
"values": [
"Honda"
]
},
{
"name": "full_name",
"values": [
"Joe Example"
]
},
{
"name": "email",
"values": [
"joe@example.com"
]
},
],
...
}
],
"paging": {
"cursors": {
"before": "OTc2Nz3M8MTgyMzU1NDMy",
"after": "OTcxNjcyOTg8ANTI4NzE4"
}
}
}
selected_dealer as the field ID. To fetch the leads in bulk, you can call:curl -G \
-d 'access_token=<ACCESS_TOKEN>' \
-d 'fields=created_time,id,ad_id,form_id,field_data' \
https://graph.facebook.com/<API_VERSION>/<FORM_ID>/leads
{
"data": [
{
"created_time": "2018-02-28T08:49:14+0000",
"id": "<LEAD_ID>",
"ad_id": "<AD_ID>",
"form_id": "<FORM_ID>",
"field_data": [
{
"name": "car_make",
"values": [
"Honda"
]
},
{
"name": "full_name",
"values": [
"Joe Example"
]
},
{
"name": "email",
"values": [
"joe@example.com"
]
},
{
"name": "selected_dealer",
"values": [
"99213450"
]
}
],
...
}
],
"paging": {
"cursors": {
"before": "OTc2Nz3M8MTgyMzU1NDMy",
"after": "OTcxNjcyOTg8ANTI4NzE4"
}
}
}
field_data does not contain the responses to optional custom disclaimer check boxes that the user would have filled out. To retrieve the responses, use the custom_disclaimer_responses field.curl -X GET \
"https://graph.facebook.com/<API_VERSION>/<LEADGEN_ID>?
fields=custom_disclaimer_responses"
{
"custom_disclaimer_responses": [
{
"checkbox_key": "optional_1",
"is_checked": "1"
},
{
"checkbox_key": "optional_2",
"is_checked": ""
}
],
"id": "1231231231"
}
curl -X GET \
-d 'filtering=[
{
"field": "time_created",
"operator": "GREATER_THAN",
"value": 1761945743
}
]' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<AD_ID>/leads
operator has one of the following values.| Operator | Meaning |
|---|---|
LESS_THAN | Filters for values less than the timestamp. |
GREATER_THAN | Filters for values greater than the timestamp. |
GREATER_THAN_OR_EQUAL | Filters for values greater than or equal to the timestamp. |