facebookfacebook-graph-apifacebook-ads-apifacebook-marketing-api

Instagram custom audience source not prefilling via api


I can able to create instagram custom audience via Api,but the source field is not prefilled.if i manually creates from Ads ui in fb it works fine .please see what i have already tried

curl -X POST \
  -F 'name=My Test Engagement Custom Audience insta' \
  -F 'rule={
       "inclusions": {
         "operator": "or",
         "rules": [
           {
             "event_sources": [
               {
                 "id": business_profile_id,
                 "type": "ig_business"
               }
             ],
             "retention_seconds": 31536000,
             "filter": {
               "operator": "and",
               "filters": [
                 {
                   "field": "event",
                   "operator": "eq",
                   "value": "ig_business_profile_visit"
                 }
               ]
             }
           }
         ]
       }
     }' \
  -F 'prefill=1' \
  -F 'access_token=xxxxxxxxx' \
  https://graph.facebook.com/v10.0/act_xxxxxx/customaudiences

https://developers.facebook.com/docs/marketing-api/audiences/guides/engagement-custom-audiences I have taken the instagram_business_account id from me/accounts?fields=name,id,access_token,instagram_business_account{id} and use it inside event_sources id.No luck for me.Please help me.Thanks in advance


Solution

  • Finally i fix it.i was given instagram_business_account_id instead of instagram profile ID anybody who is facing the issue, if your instagram account is attached to a facebook page Instagram business profile ID can be found from here

    https://developers.facebook.com/docs/graph-api/reference/page/instagram_accounts/

    example

    {fb-page-id}/instagram_accounts?fields=id and access token used is fb page access token .Cheers,Happy coding!!