Zernio
APIFor you
Zernio
APIFor you
API Reference

Automated Rules

Rules

List ad rulesGETCreate an ad rulePOSTGet an ad ruleGETUpdate an ad rulePATCHDelete an ad ruleDELETE

Preview and History

Preview an ad rulePOSTList an ad rule's runsGET
Dashboard
OverviewPlatformsAPI ReferenceResources
Automated Rules

Get an ad rule

Returns one ad rule.


PlatformsMetaGoogleTikTokLinkedInPinterestX
GET
/v1/ads/rules/{ruleId}

Authorization

bearerAuth
AuthorizationBearer <token>

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

In: header

Path Parameters

ruleId*string

Response Body

application/json

application/json

application/json

application/json

application/json

import Zernio from '@zernio/node';const zernio = new Zernio({ apiKey: process.env.ZERNIO_API_KEY });const { data } = await zernio.adrules.getAdRule();console.log(data);
{  "rule": {    "id": "string",    "name": "string",    "accountId": "string",    "platform": "string",    "adAccountId": "string",    "level": "campaign",    "campaignIds": [      "string"    ],    "conditions": {      "all": [        {          "metric": "spend",          "window": "today",          "op": ">",          "value": 0        }      ]    },    "actions": [      {        "type": "notify"      }    ],    "schedule": {      "everyMinutes": 60    },    "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"  }}
Was this page helpful?

Create an ad rule

Creates a rule that checks the campaigns or ad sets of one ad account on a schedule and acts on each one that meets every condition. Rules support Meta, Google, TikTok, LinkedIn, Pinterest, X and Reddit ads connections. Each campaign or ad set is evaluated on its own, over the ad account's calendar days, from the metrics Zernio syncs. A rule can notify (the `ad_rule.triggered` webhook), and take at most one of `pause`, `activate` and `adjust_budget`. After acting on an object, the rule leaves that object alone for `cooldownMinutes`; a rule that pauses, activates or adjusts budgets needs a cooldown at least as long as its schedule. `activate` only reactivates objects a rule paused, never ones you paused yourself, and only once the cooldown has passed since that pause. If you reactivate and pause such an object yourself between two runs of a rule, Zernio cannot tell your pause from the rule's, and an `activate` rule may reactivate it. Use `POST /v1/ads/rules/{ruleId}/preview` to see what a rule would match before enabling it.

Update an ad rule

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.