Add new ad rule

Value for parameter
Type
Required
Description

name

String

Yes

Ad Rules Library and minimally contain a name

status

String

Yes

The status of a rule determines whether the rule should be running. There are two statuses: ENABLED and DISABLED. To temporarily turn off a rule, edit the rule and set its status to DISABLED. To reactivate a rule, edit the rule and set its status back to ENABLED. To permanently remove a rule, delete it.

Param status must be one of {ENABLED, DISABLED, DELETED, HAS_ISSUES}

Value for parameter `Evaluation Spec`
Type
Description

evaluation_type

String

The evaluation_type determines the type of evaluation method and has the following options: SCHEDULE,

TRIGGER

filters

Array

The filters array contains a list of filter objects. These objects are dictionaries with keys of field, value, and operator:

Field must be a valid Insights filter

Example :

"filters": [
  {
    "field": "lifetime_impressions",
    "value": "8000",
    "operator": "GREATER_THAN"
  },
  {
    "field": "cost_per",
    "value": "10",
    "operator": "GREATER_THAN"
  },
  {
    "field": "entity_type",
    "value": "CAMPAIGN",
    "operator": "EQUAL"
  },
  {
    "field": "time_preset",
    "value": "MAXIMUM",
    "operator": "EQUAL"
  }
]

Below is a list of Insights filters and whether they are supported by Trigger Based Rules:

Value for parameter `Field`
Type
Description

mobile_app_purchase_roas

String

website_purchase_roas

impressions

unique_impressions

clicks

unique_clicks

spent

results

cost_per

cpc

cpm

ctr

cpa

cpp

reach

frequency

leadgen

link_ctr

cost_per_unique_click

result_rate

mobile_app_install

cost_per_mobile_app_install

app_custom_event

app_custom_event.fb_mobile_achievement_unlocked

app_custom_event.fb_mobile_activate_app

app_custom_event.fb_mobile_add_payment_info

app_custom_event.fb_mobile_add_to_cart

app_custom_event.fb_mobile_add_to_wishlist

app_custom_event.fb_mobile_complete_registration

app_custom_event.fb_mobile_content_view

app_custom_event.fb_mobile_initiated_checkout

app_custom_event.fb_mobile_level_achieved

app_custom_event.fb_mobile_purchase

app_custom_event.fb_mobile_rate

app_custom_event.fb_mobile_search

app_custom_event.fb_mobile_spent_credits

app_custom_event.fb_mobile_tutorial_completion

app_custom_event.other

cost_per_mobile_achievement_unlocked

cost_per_mobile_activate_app

cost_per_mobile_add_payment_info

cost_per_mobile_complete_registration

cost_per_mobile_content_view

cost_per_mobile_initiated_checkout

cost_per_mobile_level_achieved

cost_per_mobile_purchase

cost_per_mobile_rate

cost_per_mobile_search

cost_per_mobile_spent_credits

cost_per_mobile_tutorial_completion

offline_conversion

offline_conversion.add_payment_info

offline_conversion.add_to_cart

offline_conversion.add_to_wishlist

offline_conversion.complete_registration

offline_conversion.initiate_checkout

offline_conversion.lead

offline_conversion.other

offline_conversion.purchase

offline_conversion.search

offline_conversion.view_content

cost_per_offline_conversion

cost_per_offline_other

offsite_conversion

offsite_conversion.fb_pixel_add_payment_info

offsite_conversion.fb_pixel_add_to_cart

offsite_conversion.fb_pixel_add_to_wishlist

offsite_conversion.fb_pixel_complete_registration

offsite_conversion.fb_pixel_initiate_checkout

offsite_conversion.fb_pixel_lead

offsite_conversion.fb_pixel_purchase

offsite_conversion.fb_pixel_search

offsite_conversion.fb_pixel_view_content

offsite_conversion.fb_pixel_other

cost_per_add_payment_info_fb

cost_per_add_to_cart_fb

cost_per_add_to_wishlist_fb

cost_per_complete_registration_fb

cost_per_initiate_checkout_fb

cost_per_lead_fb

cost_per_purchase_fb

cost_per_search_fb

cost_per_view_content_fb

link_click

cost_per_link_click

like

offsite_engagement

post

post_comment

post_engagement

cost_per_post_engagement

post_like

post_reaction

view_content

video_play

vote

unique_clicks

reach

lifetime_impressions

lifetime_spent

today_spent

yesterday_spent

Value for parameter `Execution Spec`
Type
Description

execution_type

String

must be one of the following values: PING_ENDPOINT, NOTIFICATION, PAUSE, REBALANCE_BUDGET, CHANGE_BUDGET, CHANGE_BID, ROTATE, UNPAUSE, CHANGE_CAMPAIGN_BUDGET, ADD_INTEREST_RELAXATION, ADD_QUESTIONNAIRE_INTERESTS, INCREASE_RADIUS, UPDATE_CREATIVE, UPDATE_LAX_BUDGET, UPDATE_LAX_DURATION, AUDIENCE_CONSOLIDATION, AUDIENCE_CONSOLIDATION_ASK_FIRST

execution_options

Array

The array contains a list of execution_option objects, which are dictionaries with keys of field, value, and operator just like Evaluation Spec's filter objects.

Example :

"execution_options": [
  {
    "field": "user_ids",
    "value": [
      "3305578009767732"
    ],
    "operator": "EQUAL"
  }
]
Value for parameter `schedule_spec`
Type
Description

schedule_type

String

schedule_spec[schedule_type] must be one of the following values: DAILY, HOURLY, SEMI_HOURLY, CUSTOM"

schedule

Array

If schedule_type is CUSTOM, you must also specify the list of custom schedules, or times when the rule should run. In the schedule list, each individual specification can be composed of a combination of the following fields. The only requirement is that at least one of start_minute or days must exist in each entry.

Example

If schedule_type is CUSTOM

 "schedule": [
   {
      "start_minute": 0,
     "days": [2, 5]
   }
 ]

POST https://us-central1-appgregator.cloudfunctions.net/facebook/adrules/

Query Parameters

Name
Type
Description

name*

String

ft-4

connection_name*

String

fbads-01

adaccount_id*

String

act_1514519918873559

Headers

Name
Type
Description

x-api-key*

String

U2Fsd...

{
    "id": "23852206730700549"
}
Body JSON
{
  "name": "Rules-7",
  "status": "DISABLED",
  "evaluation_spec": {
    "evaluation_type": "SCHEDULE",
    "filters": [
      {
        "field": "lifetime_impressions",
        "value": "8000",
        "operator": "GREATER_THAN"
      },
      {
        "field": "cost_per",
        "value": "10",
        "operator": "GREATER_THAN"
      },
      {
        "field": "entity_type",
        "value": "CAMPAIGN",
        "operator": "EQUAL"
      },
      {
        "field": "time_preset",
        "value": "MAXIMUM",
        "operator": "EQUAL"
      }
    ]
  },
  "execution_spec": {
    "execution_type": "PAUSE",
    "execution_options": [
      {
        "field": "user_ids",
        "value": [
          "3305578009767732"
        ],
        "operator": "EQUAL"
      }
    ]
  },
  "schedule_spec": {
    "schedule_type": "DAILY"
  }
}
curl --location --request POST 'https://us-central1-appgregator.cloudfunctions.net/facebook/adrules?name=ft-4&connection_name=fbads-01&adaccount_id=act_1514519918873559' \
--header 'x-api-key: U2Fsd...' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "Rules-7",
  "status": "DISABLED",
  "evaluation_spec": {
    "evaluation_type": "SCHEDULE",
    "filters": [
      {
        "field": "lifetime_impressions",
        "value": "8000",
        "operator": "GREATER_THAN"
      },
      {
        "field": "cost_per",
        "value": "10",
        "operator": "GREATER_THAN"
      },
      {
        "field": "entity_type",
        "value": "CAMPAIGN",
        "operator": "EQUAL"
      },
      {
        "field": "time_preset",
        "value": "MAXIMUM",
        "operator": "EQUAL"
      }
    ]
  },
  "execution_spec": {
    "execution_type": "PAUSE",
    "execution_options": [
      {
        "field": "user_ids",
        "value": [
          "3305578009767732"
        ],
        "operator": "EQUAL"
      }
    ]
  },
  "schedule_spec": {
    "schedule_type": "DAILY"
  }
}'

Last updated