Update an ad rule
curl --request PATCH \
--url https://api.aisa.one/apis/v1/ads/rules/{ruleId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.aisa.one/apis/v1/ads/rules/{ruleId}"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.aisa.one/apis/v1/ads/rules/{ruleId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/ads/rules/{ruleId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/ads/rules/{ruleId}"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.aisa.one/apis/v1/ads/rules/{ruleId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/ads/rules/{ruleId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"rule": {
"actions": [
{
"type": "notify"
}
],
"adAccountId": "<string>",
"campaignIds": [
"<string>"
],
"conditions": {
"all": [
{}
]
},
"cooldownMinutes": 123,
"createdAt": "2023-11-07T05:31:56Z",
"enabled": true,
"id": "<string>",
"lastRunAt": "2023-11-07T05:31:56Z",
"level": "campaign",
"name": "<string>",
"nextRunAt": "2023-11-07T05:31:56Z",
"platform": "<string>",
"schedule": {
"everyMinutes": 60
},
"updatedAt": "2023-11-07T05:31:56Z",
"connectionId": "<string>"
}
}{
"error": {
"code": "<string>",
"details": {},
"message": "<string>",
"param": "<string>",
"retryHint": "<string>",
"retryable": true,
"type": "<string>"
}
}广告
Update an ad rule
Ad Rules. Can spend money or change spend: needs the ads:spend scope and X-Aisa-Confirm: spend; without the header the request is refused with confirmation_required and nothing is sent. Changes an automated rule that can change budgets and turn delivery on or off. 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.
PATCH
https://api.aisa.one
/
apis
/
v1
/
ads
/
rules
/
{ruleId}
Update an ad rule
curl --request PATCH \
--url https://api.aisa.one/apis/v1/ads/rules/{ruleId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.aisa.one/apis/v1/ads/rules/{ruleId}"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.aisa.one/apis/v1/ads/rules/{ruleId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/ads/rules/{ruleId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/ads/rules/{ruleId}"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.aisa.one/apis/v1/ads/rules/{ruleId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/ads/rules/{ruleId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"rule": {
"actions": [
{
"type": "notify"
}
],
"adAccountId": "<string>",
"campaignIds": [
"<string>"
],
"conditions": {
"all": [
{}
]
},
"cooldownMinutes": 123,
"createdAt": "2023-11-07T05:31:56Z",
"enabled": true,
"id": "<string>",
"lastRunAt": "2023-11-07T05:31:56Z",
"level": "campaign",
"name": "<string>",
"nextRunAt": "2023-11-07T05:31:56Z",
"platform": "<string>",
"schedule": {
"everyMinutes": 60
},
"updatedAt": "2023-11-07T05:31:56Z",
"connectionId": "<string>"
}
}{
"error": {
"code": "<string>",
"details": {},
"message": "<string>",
"param": "<string>",
"retryHint": "<string>",
"retryable": true,
"type": "<string>"
}
}请求规范
- 方法与路径: PATCH /apis/v1/ads/rules/{ruleId}
- 可用状态: enabled
- 请求 URL 模板:
https://api.aisa.one/apis/v1/ads/rules/{ruleId} - ruleId: path; 必填
- connectionId: query; 必填
- X-Aisa-Confirm: header; 可选
{
"operationId": "patch_aisa_ads_apis_v1_ads_rules_ruleid",
"method": "PATCH",
"path": "/apis/v1/ads/rules/{ruleId}",
"servers": [
{
"url": "https://api.aisa.one"
}
],
"parameters": [
{
"in": "path",
"name": "ruleId",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "The ads connection (adc_...) the request runs on: one of yours, from GET /apis/v1/ads/connections. On a request with a JSON body it may be sent as a top-level body member instead.",
"in": "query",
"name": "connectionId",
"required": true,
"schema": {
"pattern": "^adc_[0-9A-Za-z]+$",
"type": "string"
}
},
{
"description": "Required with the value \"spend\" when the request can spend money or change spend. Without it the request is refused with 409 confirmation_required, which describes what would happen; nothing is sent to the ad platform.",
"in": "header",
"name": "X-Aisa-Confirm",
"required": false,
"schema": {
"enum": [
"spend"
],
"type": "string"
}
}
],
"security": [
{
"bearerAuth": []
}
],
"requestBody": {
"content": {
"application/json": {
"example": {
"connectionId": "adc_7f3k2m9q",
"enabled": false,
"name": "Winter launch"
},
"schema": {
"additionalProperties": true,
"properties": {
"actions": {
"description": "Each type at most once, and at most one of `pause`, `activate` and `adjust_budget`.",
"items": {
"oneOf": [
{
"properties": {
"type": {
"enum": [
"notify"
],
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
{
"properties": {
"maxChangesPerDay": {
"description": "At most this many objects changed in any 24 hours, across runs. Matches over the limit are skipped with `daily_limit_reached` and tried again later.",
"maximum": 100,
"minimum": 1,
"type": "integer"
},
"type": {
"description": "Pause the campaign, ad set or ad.",
"enum": [
"pause"
],
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
{
"properties": {
"maxChangesPerDay": {
"description": "At most this many objects changed in any 24 hours, across runs. Matches over the limit are skipped with `daily_limit_reached` and tried again later.",
"maximum": 100,
"minimum": 1,
"type": "integer"
},
"type": {
"description": "Reactivate a campaign, ad set or ad a rule paused, once `cooldownMinutes` has passed since the pause. Objects you paused yourself are never touched.",
"enum": [
"activate"
],
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
{
"properties": {
"direction": {
"enum": [
"increase",
"decrease"
],
"type": "string"
},
"limit": {
"description": "The budget never goes above this on an increase, or below it on a decrease, in the ad account currency.",
"exclusiveMinimum": 0,
"type": "number"
},
"maxChangesPerDay": {
"description": "At most this many objects changed in any 24 hours, across runs. Matches over the limit are skipped with `daily_limit_reached` and tried again later.",
"maximum": 100,
"minimum": 1,
"type": "integer"
},
"percent": {
"description": "Change in percent: up to 100 for an increase, up to 90 for a decrease.",
"maximum": 100,
"minimum": 1,
"type": "integer"
},
"type": {
"description": "Change the daily budget. Not on ad-level rules (an ad has no budget), and on Google it needs a campaign-level rule (ad groups have no budget of their own).",
"enum": [
"adjust_budget"
],
"type": "string"
}
},
"required": [
"direction",
"limit",
"percent",
"type"
],
"type": "object"
}
]
},
"minItems": 1,
"type": "array"
},
"campaignIds": {
"description": "Must be yours: it is checked through the connection before the request is sent, and an id that is not yours answers not_found.",
"items": {
"type": "string"
},
"maxItems": 100,
"minItems": 1,
"type": [
"array",
"null"
]
},
"conditions": {
"description": "Every condition must hold for an object to match. A rate with no denominator (a CPA with no conversions) never matches.",
"properties": {
"all": {
"items": {
"properties": {
"metric": {
"anyOf": [
{
"enum": [
"spend",
"impressions",
"clicks",
"conversions",
"ctr",
"cpc",
"cpm",
"cpa",
"roas",
"reach",
"frequency"
]
},
{
"pattern": "^result:[a-z][a-z0-9_]{0,39}$"
}
],
"description": "`ctr` is a percentage. `spend`, `cpc`, `cpm` and `cpa` are in the ad account currency. `reach` and `frequency` use the platform's de-duplicated reach, so they are accepted on Meta and TikTok only.",
"type": "string"
},
"op": {
"enum": [
">",
">=",
"<",
"<="
],
"type": "string"
},
"value": {
"minimum": 0,
"type": "number"
},
"window": {
"description": "Days in the ad account's own timezone. `last_7d` is the 7 full days before today; only `today` reads the day in progress.",
"enum": [
"today",
"yesterday",
"last_3d",
"last_7d",
"last_14d",
"last_30d"
],
"type": "string"
}
},
"required": [
"metric",
"op",
"value",
"window"
],
"type": "object"
},
"maxItems": 10,
"minItems": 1,
"type": "array"
}
},
"required": [
"all"
],
"type": "object"
},
"connectionId": {
"description": "The ads connection (adc_...), when not sent as the connectionId query parameter.",
"pattern": "^adc_[0-9A-Za-z]+$",
"type": "string"
},
"cooldownMinutes": {
"maximum": 43200,
"minimum": 0,
"type": "integer"
},
"enabled": {
"type": "boolean"
},
"level": {
"description": "Whether the rule checks campaigns, ad sets or single ads. Each one is evaluated on its own.",
"enum": [
"campaign",
"adset",
"ad"
],
"type": "string"
},
"name": {
"maxLength": 200,
"minLength": 1,
"type": "string"
},
"schedule": {
"properties": {
"everyMinutes": {
"description": "How often the rule runs, in minutes.",
"enum": [
60,
180,
360,
720,
1440
],
"type": "integer"
}
},
"required": [
"everyMinutes"
],
"type": "object"
}
},
"type": "object"
}
}
},
"required": true
},
"x-aisa-status": "enabled",
"components": {
"securitySchemes": {
"bearerAuth": {
"scheme": "bearer",
"type": "http"
}
}
}
}
费用与请求规则
此操作不另收费。 广告投放费用由广告平台向已连接的广告账户另行收取。授权
请求头
查询参数
请求体
application/json