operation_status will return 471 to signal if your custom audiences have been flagged.subtype=CUSTOM and customer_file_source in your API call.curl -X POST \
-F 'name="My new Custom Audience"' \
-F 'subtype="CUSTOM"' \
-F 'description="People who purchased on my website"' \
-F 'customer_file_source="USER_PROVIDED_ONLY"' \
-F 'audience_labels=["HIGH_VALUE_CUSTOMERS"]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/act_<AD_ACCOUNT_ID>/customaudiences
| Name | Description |
|---|---|
customer_file_sourceenum string | Describes how the customer information in your Custom Audience was originally collected. Values:
|
namestring | Custom Audience name |
descriptionstring | Custom Audience description |
subtypestring | Type of Custom Audience |
audience_labelsstring | Choose a label that describes this audience. Labels may be used to find audiences for your ads more effectively. About audience labels. Engaged audiences:
Customers:
|
POST API call to the /{audience_id}/users endpoint to specify the list of users you want to add to your Custom Audience.| Name | Description |
|---|---|
sessionJSON Object | Required Use the session parameter to track if a specific batch of users has been uploaded.If you have an upload with more than 10,000 users, you need to split it into separate batches; each request can take up to 10,000 users. Example |
payloadJSON Object | Required Includes schema and data.Example |
LDU for the record, you can either send an empty data_processing_options array or remove the field in the payload. Example of an empty array:{
"payload": {
"schema": [
"EMAIL",
"DATA_PROCESSING_OPTIONS"
],
"data": [
[
"<HASHED_DATA>
",
[]
]
]
}
}
LDU, and have Meta perform geolocation (by not including state and country of the given record), specify an array containing LDU for each record:{
"payload": {
"schema": [
"EMAIL",
"DATA_PROCESSING_OPTIONS"
],
"data": [
[
"<HASHED_DATA>
",
["LDU"]
]
]
}
}
{
"customer_consent": true,
"payload": {
"schema": [
"EMAIL",
"DATA_PROCESSING_OPTIONS",
"DATA_PROCESSING_OPTIONS_COUNTRY",
"DATA_PROCESSING_OPTIONS_STATE"
],
"data": [
[
"<HASHED_DATA>",
["LDU"],
1,
1000
]
]
}
}
session fields| Name | Description |
|---|---|
session_idpositive 64-bit integer | Required Identifier used to track the session. This number must be generated by the advertiser and unique within a specific ad account. |
batch_seqpositive integer | Required Number to identify the request listed in the current session. This number must be sequential and start from 1. |
last_batch_flagboolean | Required Indicate to our systems that all batches for the ongoing Replace session have been provided. When set to true, the current request is the last one from the current session, and we don’t accept any further batches for that session. If you don’t send this flag, we automatically terminate the session 90 minutes after we receive your first batch. Any batch received after 90 minutes is also discarded.
You must mark the last request to let Meta know that this is the last batch. |
estimated_num_totalinteger | Optional Estimated total number of users to be uploaded in this session. This field is used to improve this session’s processing. |
| Name | Description |
|---|---|
audience_idnumeric string | Audience identifier |
session_idinteger | Session ID you passed in |
num_receivedinteger | Total number of users received in this session so far |
num_invalid_entriesinteger | Number of entries sent with incorrect hashing. Those entries did not return a match and are not added to the custom audience. This is not an exact number, but it represents the number range of users that did not match. |
invalid_entry_samplesJSON Array of String or Map {string: string} | Up to 100 samples of invalid entries found in the current request |
| Error Code | Error Subcode | Description | Resolution |
|---|---|---|---|
1 | Please reduce the amount of data you’re asking for, then retry your request | This relates to the limit of data to return in an API response. Whilst there is no specific maximum limit, the best practice is to use a limit of 20 with pagination. | |
100 | 1713098 | Invalid rule JSON format | Check the JSON format and parameters for issues, and retry the call. |
200 | 1870050 | Permissions error | Check that the ad account is linked to the Meta Business Suite account. |
200 | 1870090 | Custom Audience Terms Not Accepted | Follow the Terms of Service guidelines for custom audiences, specifically for the business the account is acting on behalf of or a shared ad account.
To sign the contracts for the original business, a user has to switch to an ad account not acting on behalf of or owned by the business they need to accept. |
DELETE API call to the /{audience_id}/users endpoint to specify the list of users you want to remove from your Custom Audience.curl -X DELETE \
--data-urlencode 'payload={
"schema": "EMAIL_SHA256",
"data": [
"<HASHED_DATA>",
"<HASHED_DATA>",
"<HASHED_DATA>"
]
}' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<VERSION>/<CUSTOM_AUDIENCE_ID>/users
method parameter and set it to DELETE in the POST request used to add audience members.EXTERN_ID, if available.curl -X DELETE \
--data-urlencode 'payload={
"schema": "EXTERN_ID",
"data": [
"<ID>",
"<ID>",
"<ID>"
]
}' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<VERSION>/<CUSTOM_AUDIENCE_ID>/users
HTTP DELETE call to:https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/usersofanyaudience
EXTERN_ID, LN, FN, EMAIL]. While you don’t need to hash EXTERN_ID, you must hash all personally identifying information, such as emails and names. For details, see Hashing and Normalizing Data.curl \
-F 'payload={
"schema": [
"FN",
"LN",
"EMAIL"
],
"data": [
[
"<HASH>",
"<HASH>",
"<HASH>"
],
[
"<HASH>",
"<HASH>",
"<HASH>"
]
]
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<VERSION>/<CUSTOM_AUDIENCE_ID>/users
PAGEUIDPAGEUID key, you must also include a list of page IDs. You can only send us one PAGEUID, which should be an array with one element.curl -X POST \
-F 'payload={
"schema": [
"PAGEUID"
],
"is_raw": "true",
"page_ids": [
"<PAGE_IDs>"
],
"data": [
[
"<HASH>",
"<ID>",
"<ID>",
"<VALUE>"
],
[
"<HASH>",
"<ID>",
"<ID>",
"<VALUE>"
],
[
"<HASH>",
"<ID>",
"<ID>",
"<VALUE>"
]
]
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<VERSION>/<CUSTOM_AUDIENCE_ID>/users
SHA256; we don’t support other hashing mechanisms. This is required for all data except External Identifiers, App User IDs, Page Scoped User IDs and Mobile Advertiser IDs.FN) and Last Name (LN) support special characters and non-Roman alphabets. For the best match results, provide the Roman alphabet translation with no special characters.| Key | Guidelines |
|---|---|
EMAILcriteria: email addresses | Hashing required Trim leading and trailing white space, and convert all characters to lowercase. |
PHONEcriteria: phone numbers | Hashing required Remove symbols, letters, and any leading zeroes. You should prefix the country code if the COUNTRY field is not specified. |
GENcriteria: gender | Hashing required Use these values: m for male, f for female. |
DOBYcriteria: birth year | Hashing required Use the YYYY format: 1900 to the current year. |
DOBMcriteria: birth month | Hashing required Use the MM format: 01 to 12. |
DOBDcriteria: birthday | Hashing required Use the DD format: 01 to 31. |
LN and FNcriteria: last and first names | Hashing required Use a-z only. Lowercase only, no punctuation. Special characters in UTF-8 format. |
FIcriteria: first name initial | Hashing required Use a-z only. Lowercase only. Special characters in UTF-8 format. |
STcriteria: US states | Hashing required Use the 2-character ANSI abbreviation code, lowercase. Normalize states outside the US in lowercase, with no punctuation, no special characters, and no white space. |
CTcriteria: city | Hashing required Use a-z only. Lowercase only, with no punctuation, no special characters, and no white space. |
ZIPcriteria: zip code | Hashing required Use lowercase, and no white space. For the US, use only the first 5 digits. For the UK, use the Area/District/Sector format. |
COUNTRYcriteria: country code | Hashing required Use lowercase, 2-letter country codes in ISO 3166-1 alpha-2. |
MADIDcriteria: mobile advertiser ID | Do not hash Use all lowercase, and keep hyphens. |
SHA256 values for normalized keys and HEX representations of this value, using lowercase for A through F. The hash function in PHP converts normalized emails and phone numbers.| Example | Result |
|---|---|
hash("sha256", "mary@example.com") | f1904cf1a9d73a55fa5de0ac823c4403ded71afd4c3248d00bdcd0866552bb79 |
hash("sha256", "15559876543") | 1ef970831d7963307784fa8688e8fce101a15685d62aa765fed23f3a2c576a4e |
EXTERN_ID). This can be any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs.EXTERN_IDs.EXTERN_ID, we give EXTERN_ID lower precedence when we match them with people on Facebook.EXTERN_ID is 90 days.EXTERN_ID mapping to build customer file custom audiences within a single ad account.EXTERN_ID fields in your ad account, create a new audience with just these identifiers.curl \
-F 'payload={"schema":"EXTERN_ID","data":["<ID>","<ID>"]}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<VERSION>/<CUSTOM_AUDIENCE_ID>/users
EXTERN_ID and with multi-key matching.curl \
-F 'payload={
"schema": [
"EXTERN_ID",
"FN",
"EMAIL",
"LN"
],
"data": [
[
"<ID>",
"<HASH>",
"<HASH>",
"<HASH>"
],
[
"<ID>",
"<HASH>",
"<HASH>",
"<HASH>"
],
[
"<ID>",
"<HASH>",
"<HASH>",
"<HASH>"
]
]
}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/<VERSION>/<CUSTOM_AUDIENCE_ID>/users
EXTERN_ID parameters for individual ad accounts. We cannot use values from one ad account for any other ad accounts, even if the accounts belong to the same entity./<CUSTOM_AUDIENCE_ID>/usersreplace endpoint allows you to perform 2 actions with one API call:/<CUSTOM_AUDIENCE_ID>/usersreplace endpoint allows you to automatically delete all existing users rather than having to upload a list of users you want to delete. This endpoint does not reset your ad set’s learning phase when an audience is part of active ad sets unlike POST or DELETE API calls to the /<CUSTOM_AUDIENCE_ID>/users endpoint./<CUSTOM_AUDIENCE_ID>/users endpoint to add and remove users.CUSTOM.operation_status is Normal./<CUSTOM_AUDIENCE_ID>/users during an ongoing replace operation via /<CUSTOM_AUDIENCE_ID>/usersreplace. If you try performing a second replace operation before the first is completed, you will receive a message indicating a replace operation is already in progress./<CUSTOM_AUDIENCE>/users endpoint’s add operation for the rest of your uploads.POST call to /<CUSTOM_AUDIENCE_ID>/usersreplace.operation_status switches to replace_in_progress.operation_status switches to replace_error.operation_status of 471 is returned, the custom audience has been flagged for integrity reasons.curl POST \
--data '{
"session": {
"session_id":9778993,
"batch_seq":10,
"last_batch_flag":true,
"estimated_num_total":99996
},
"payload": {
"schema": ["EMAIL","DATA_PROCESSING_OPTIONS"],
"data": [
["<HASHED_DATA>"], ["<HASHED_DATA>"]
]
},
}'
https://graph.facebook.com/v25.0/<CUSTOM_AUDIENCE_ID>/usersreplace?access_token=<ACCESS_TOKEN>
POST call to /<CUSTOM_AUDIENCE_ID>/usersreplace:| Name | Description |
|---|---|
session
JSON object
| Required. Used to track if a specific batch of users has been uploaded. Must include a session ID and batch information. See Session Fields. You can add up to 10,000 people to an audience at a given time. If you have more than 10,000 people, split your session into multiple batches, which should all have 1 session ID. Example:
|
payload
JSON object
| Required. Used to provide the information you want to be uploaded to your audience. Must include schema and data. See Payload Fields for more information.Example:
|
session object fields| Name | Description |
|---|---|
session_id
64-bit integer
| Required. Used to track the session. You must generate this identifier and the number must be unique within the same ad account. |
batch_seq
integer
| Required. Must start at 1.A new replace session starts when we receive a batch_seq of 1. We recommend not sending duplicate batches with a sequence of 1 for a given session_id.Labeling the first batch is important; the rest of the batches of a session can be duplicates or any number except 1 because we use this parameter to identify the start of the session. All non-first batches for a session should be sent after the first batch. Consider the first batch as a trigger/pre-step for the replace operation. |
last_batch_flag
Boolean
| Optional. Indicates all batches for the ongoing replace session have been provided. When set to true, no further batches are accepted for that session. If you do not set this flag, the session is automatically terminated 90 minutes after the first batch is received. Any batch received after 90 minutes is also discarded. |
estimated_num_total
integer
| Optional. Estimated total number of users to be uploaded in this session. Used by our system to improve a session’s processing. |
payload object fields| Name | Description |
|---|---|
schema
string or JSON string array
| Required. Specify what type of information you will provide. It can be a single key or multi-key from this list:
Example:
|
data
JSON array
| Required. List of data corresponding to the schema. Examples:
|
POST request, you get a response with the following fields:| Name | Description |
|---|---|
account_id
integer
| Account identifier. |
session_id
integer
| Session ID you have previously provided. |
num_received
integer
| Total number of users received in this session so far. |
num_invalid_entries
integer
| Total number of users with an invalid format or unable to be decoded. If this number is not zero, recheck your data. |
invalid_entry_samples
JSON string array
| Up to 100 samples of invalid entries in current request. Recheck your data. |
/{custom-sudience-id}/usersreplace endpoint have the error code 2650. Here are some of the most common error subcodes returned, as well as guidance on how to resolve them.| Error SubCode | Description | What To Do |
|---|---|---|
1870145 | Audience Update In Progress | You can’t replace a customer list custom audience that is in the process of being updated. Wait for the audience availability to become “Normal” and try again. |
1870158 | Replace Session Timed Out | You’ve reached the 90-minute time limit for your replace batch session. Your customer list custom audience will be replaced with what you’ve uploaded so far. To add more to the custom audience, wait until the replace process is finished, and then use the ADD operation. |
1870147 | Invalid Upload Batch for Replace | The first batch_seq was not detected. You must start your batch_seq at integer 1. |
1870159 | Replace Session Finished | This replace operation is already finished because you uploaded a batch with last_batch_flag==true. To add additional batches to the custom audience, wait until the replace process is finished, and then use the ADD operation. |
1870148 | Something Went Wrong | Your customer list was not fully updated. If your audience size is significantly differ than expected, consider trying again. |
1870144 | DFCA Size Not Supported For Replace | You can’t replace a customer list customer audience that has a size of 100 million or more. |
limit field is the maximum number of objects that may be returned in an API call. There is no specific maximum value of the limit parameter when querying the custom audience endpoints.customer_file_source field when creating a custom audience using the Marketing API.