Actions
An action is what a rule does to an ad, an adset or a campaign on the ad's own platform when the condition is met; which platforms take the command — see Which networks the actions reach. Inside the checkAd(ad) function you have ready-made functions available: to pause and to return to work — at three levels: ad, adset and campaign. If none of them is called, the rule changes nothing.
For how to write the rule itself — Creating a rule. The full reference of functions and fields — Automated rules SDK.
Pause
Ad — pauseAd
Pauses the current ad (the one being checked right now).
pauseAd('24h', 'нет депов при расходе > 100');
- The first argument — the pause duration (
'6h','12h','24h','next_day_target_geo','next_day_ad_account','permanent','while_matches'). Read more — Scheduling and pauses. - The second argument — the reason (optional). If not specified — the rule name is substituted. Where the reason shows up — in the Pause section of the SDK reference.
Another ad — for example, a neighbour from the same adset — is paused by its identifier, in the object form; see the same section.
Adset — pauseAdset
Pauses an adset. An adset has no "own" current object, so the arguments are passed as an object, and the adsetId field is required:
pauseAdset({ adsetId: ad.adset_id, duration: '24h', reason: 'весь адсет в минус' });
Campaign — pauseCampaign
Pauses a campaign. The arguments are an object, the campaignId field is required:
pauseCampaign({ campaignId: ad.campaign_id, duration: 'permanent', reason: 'кампания убыточна' });
All three levels — pauseAd, pauseAdset and pauseCampaign — are applied automatically in the real check cycle, and are also checked on the Test tab.
Return to work
In most cases you do not need to return an ad manually: Britva does it itself — when the pause term expires or when the rule condition stops being met (for the "while the condition matches" pause type).
You can lift a pause by hand on the Paused tab — the Activate button.
The SDK also has return functions — activateAd and counterparts for the adset and campaign — that lift a hold from code in the real check cycle. They lift only a pause of the same rule, and the short form activateAd() lifts nothing; how to call them so that they work — Resume. In most cases you do not need them: ads are returned automatically when the pause expires or when the condition stops triggering, so rules with a pause are enough for normal operation.