OverviewProductsPlatformsAPI ReferenceResources
Automated Rules

Update an ad rule

PATCHhttps://zernio.com/api/v1/ads/rules/{ruleId}

Changes any field of a rule except its connection and ad account. Send campaignIds: null to check the whole ad account again. Changing the schedule, or enabling a disabled rule, moves the next run; re-sending enabled: true on an enabled rule does not.

PlatformsMetaGoogleTikTokLinkedInPinterestXReddit

Authentication

AuthorizationBearer tokenRequired

API key authentication: send your Zernio API key in the Authorization header, prefixed with Bearer.

Path parameters

ruleIdstringRequired

Body

application/json
Optional parameters11 fields
namestring, max 200
levelstringOne of campaign | adset | ad | keyword | search_term

Whether the rule checks campaigns, ad sets, single ads, Google keywords or Google search terms. Each one is evaluated on its own.

keyword and search_term read Google Search, on Google Ads accounts only. A keyword's id is <adGroupId>~<criterionId>, as PATCH /v1/ads/keywords/{keywordId} takes it. A search term is one per ad group, its id <adGroupId>~<term>.

  • They read a daily history Zernio fetches from Google. A day keeps its 50,000 rows that spent most.
  • Every daily window works, today included: today is refreshed at most once an hour.
  • A new rule's first runs load its days a few at a time, and fail until all are in.
  • A keyword rule judges every serving keyword, one with no traffic at zero. Paused keywords are not judged.
  • Google lists only search terms that showed at least once, so a search term rule takes impressions with > or >=, never < or <=.

They take spend, impressions, clicks, conversions, ctr, cpc, cpm, cpa and roas over whole days, no usual, of, top or bottom, and compareTo only as campaign. A keyword rule can notify or pause; a search term rule only notifies.

campaignIdsarray or null
filtersarray of one of 9 objects

Narrows the objects the rule checks. Every filter must hold. A campaign rule reads name, campaign_id, goal, days_live, days_since_change, budget_level and channel_type; an ad set rule all but days_since_change, plus campaign_name and adset_id; an ad rule also adset_name and ad_id.

A keyword rule reads name (the keyword text), campaign_name, adset_name, campaign_id, adset_id, match_type and blocked_by_negative. A search term rule reads those (name is the term) plus search_term_status.

groupsobject

Null removes the groups; each campaign is then judged on its own.

lifecycleone of 2 types

Null removes it; every matching run then acts and notifies again.

conditionsone of 2 objects

A group: all (every item must hold) or any (one is enough). An item is a condition or another group, nested up to 3 levels, with at most 10 conditions in total. A rate with no denominator (a CPA with no conversions) never matches.

actionsarray of AdRuleAction

Each type at most once, and at most one of pause, activate, adjust_budget, adjust_bid, adjust_target, reallocate_budget, duplicate and edit_name.

scheduleAdRuleSchedule

Either everyMinutes or times. Sending a schedule replaces the rule's whole timing. Without one, a new rule runs every 60 minutes.

cooldownMinutesinteger
enabledboolean

Responses

Success· the request worked

Errors· the request failed

PATCH/v1/ads/rules/{ruleId}
import Zernio from '@zernio/node';const zernio = new Zernio({ apiKey: process.env.ZERNIO_API_KEY });const { data } = await zernio.adrules.updateAdRule({  body: {    name: 'Example',    level: 'campaign',    campaignIds: {},  },});console.log(data);
{  "rule": {    "id": "string",    "name": "string",    "accountId": "string",    "platform": "string",    "adAccountId": "string",    "level": "campaign",    "campaignIds": [      "string"    ],    "filters": [      {        "field": "name",        "op": "contains",        "value": "string"      }    ],    "groups": [      {        "name": "string",        "filters": [          {            "field": "name",            "op": "contains",            "value": "string"          }        ]      }    ],    "lifecycle": {      "confirmChecks": 1,      "hold": {        "all": [          {            "metric": "spend",            "window": "today",            "op": ">",            "value": 0,            "compareTo": "string",            "of": "usual"          }        ]      },      "critical": {        "all": [          {            "metric": "spend",            "window": "today",            "op": ">",            "value": 0,            "compareTo": "string",            "of": "usual"          }        ]      }    },    "conditions": {      "all": [        {          "metric": "spend",          "window": "today",          "op": ">",          "value": 0,          "compareTo": "string",          "of": "usual"        }      ]    },    "actions": [      {        "type": "notify",        "send": [          {            "accountId": "string",            "channelId": "string"          }        ]      }    ],    "schedule": {      "everyMinutes": 15,      "times": [        {          "days": [            "mon"          ],          "at": "string"        }      ],      "startsAt": "2019-08-24T14:15:22Z",      "endsAt": "2019-08-24T14:15:22Z",      "quietHours": {        "from": "string",        "to": "string"      }    },    "cooldownMinutes": 0,    "enabled": true,    "lastRunAt": "2019-08-24T14:15:22Z",    "nextRunAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  }}
OpenAPI specification
Was this page helpful?