How do I know when a custom audience has finished processing customers?
1

I'm working on a process where our platform creates a custom audience (Audience A) based on our users. After that, we're trying to generate a lookalike audience (Audience B) using Audience A as the source. However, when creating the lookalike audience, process fails due to Audience A not being ready yet.

Say mi code looks like this:

session = FacebookAds::Session.new(access_token: 'TOKEN', app_secret: 'SECRET')
ad_account = FacebookAds::AdAccount.get('act_1234567890', session)
custom_audience = ad_account.customaudiences.create({
  name: "Seed Audience #{Time.now.to_i}",
  subtype: 'CUSTOM',
  description: 'Custom audience for creating lookalike',
  customer_file_source: 'USER_PROVIDED_ONLY',
  payload: {
    data: User.first(500).pluck(:email, :first_name, :last_name, :country).prepare_for_meta,
    schema: ['EMAIL', 'FN', 'LN', 'COUNTRY']
  }
})
ad_account.customaudiences.create({
  name: "Lookalike Audience #{Time.now.to_i}",
  subtype: 'LOOKALIKE',
  origin_audience_id: custom_audience.id,
  lookalike_spec: {
    type: 'similarity',
    country: 'US',
    ratio: 0.01
  }
}) # fails since custom_audience users are not ready immediatly

If I try to create the lookalike audience immediately, I get the following error from the API: Audience can't be created: Your lookalike source needs to include at least 100 people in the same country in your audience location. Please choose a different audience location or lookalike source.

According to the documentation, updates to custom audiences (such as adding users) can take up to 24 hours to process. The specific wording is: Changes to your Custom Audiences don't happen immediately and usually take up to 24 hours. Custom Audience Users docs

My question is: how can I determine when Audience A is ready and meets the requirements for creating a lookalike audience?

I don't see any attribute in the API that explicitly indicates when the audience is ready for use: Custom Audience docs

Miguel
Posée il y a un mois environ