Locoia
Search…
Facebook Marketing
Facebook custom audiences
  • API Versions - latest v11.0 as of August 2021.
  • Permissions and Scopes.
  • Base URL: https://graph.facebook.com/<VERSION>/
  • Test Facebook Graph API Playground: https://developers.facebook.com/tools/explorer?method=GET&path=me%3Ffields%3Did%2Cname&version=v12.0

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
Copied!
Error explanation page can be found here.
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.
Last modified 26d ago