curl --request POST \
--url https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"definition": {
"action": "pause",
"minimum_counted_arrivals": 4611686018427388000,
"cost_ratio": 5.05
},
"platform_ad_account_id": 2,
"account_id": 2,
"enabled": "<unknown>",
"window": "",
"window_days": "",
"author_type": "",
"current_revision_id": ""
}
'import requests
url = "https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules"
payload = {
"name": "<string>",
"definition": {
"action": "pause",
"minimum_counted_arrivals": 4611686018427388000,
"cost_ratio": 5.05
},
"platform_ad_account_id": 2,
"account_id": 2,
"enabled": "<unknown>",
"window": "",
"window_days": "",
"author_type": "",
"current_revision_id": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
definition: {
action: 'pause',
minimum_counted_arrivals: 4611686018427388000,
cost_ratio: 5.05
},
platform_ad_account_id: 2,
account_id: 2,
enabled: '<unknown>',
window: '',
window_days: '',
author_type: '',
current_revision_id: ''
})
};
fetch('https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules', 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://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'definition' => [
'action' => 'pause',
'minimum_counted_arrivals' => 4611686018427388000,
'cost_ratio' => 5.05
],
'platform_ad_account_id' => 2,
'account_id' => 2,
'enabled' => '<unknown>',
'window' => '',
'window_days' => '',
'author_type' => '',
'current_revision_id' => ''
]),
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://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"definition\": {\n \"action\": \"pause\",\n \"minimum_counted_arrivals\": 4611686018427388000,\n \"cost_ratio\": 5.05\n },\n \"platform_ad_account_id\": 2,\n \"account_id\": 2,\n \"enabled\": \"<unknown>\",\n \"window\": \"\",\n \"window_days\": \"\",\n \"author_type\": \"\",\n \"current_revision_id\": \"\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"definition\": {\n \"action\": \"pause\",\n \"minimum_counted_arrivals\": 4611686018427388000,\n \"cost_ratio\": 5.05\n },\n \"platform_ad_account_id\": 2,\n \"account_id\": 2,\n \"enabled\": \"<unknown>\",\n \"window\": \"\",\n \"window_days\": \"\",\n \"author_type\": \"\",\n \"current_revision_id\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"definition\": {\n \"action\": \"pause\",\n \"minimum_counted_arrivals\": 4611686018427388000,\n \"cost_ratio\": 5.05\n },\n \"platform_ad_account_id\": 2,\n \"account_id\": 2,\n \"enabled\": \"<unknown>\",\n \"window\": \"\",\n \"window_days\": \"\",\n \"author_type\": \"\",\n \"current_revision_id\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"rule": {
"id": "<string>",
"workspace_id": 123,
"platform_ad_account_id": 123,
"name": "<string>",
"enabled": true,
"suspended_at": "2023-11-07T05:31:56Z",
"suspended_reason": "<string>",
"window": {
"days": 3,
"kind": "last_complete_days",
"timezone": "<string>"
},
"current_revision": {
"id": "<string>",
"target_level": "ad",
"action": "pause",
"budget_change_percent": 123,
"minimum_counted_arrivals": 123,
"cost_comparison": "at_least",
"cost_ratio": "<string>",
"author_type": "user",
"created_at": "2023-11-07T05:31:56Z"
},
"revisions": [
{
"id": "<string>",
"target_level": "ad",
"action": "pause",
"budget_change_percent": 123,
"minimum_counted_arrivals": 123,
"cost_comparison": "at_least",
"cost_ratio": "<string>",
"author_type": "user",
"created_at": "2023-11-07T05:31:56Z"
}
]
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"error": {
"code": "api_route_not_found",
"message": "<string>",
"resolution": "<string>"
},
"request": {
"method": "<string>",
"path": "<string>"
},
"resources": {
"documentation": "<string>",
"openapi": "<string>"
}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>"
}{
"error": {
"code": "workspace_lock_timeout",
"message": "<string>"
}
}Create an action rule
Write an account-scoped rule using its validated definition. Send Accept: application/json for JSON errors. New rules start disabled.
curl --request POST \
--url https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"definition": {
"action": "pause",
"minimum_counted_arrivals": 4611686018427388000,
"cost_ratio": 5.05
},
"platform_ad_account_id": 2,
"account_id": 2,
"enabled": "<unknown>",
"window": "",
"window_days": "",
"author_type": "",
"current_revision_id": ""
}
'import requests
url = "https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules"
payload = {
"name": "<string>",
"definition": {
"action": "pause",
"minimum_counted_arrivals": 4611686018427388000,
"cost_ratio": 5.05
},
"platform_ad_account_id": 2,
"account_id": 2,
"enabled": "<unknown>",
"window": "",
"window_days": "",
"author_type": "",
"current_revision_id": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
definition: {
action: 'pause',
minimum_counted_arrivals: 4611686018427388000,
cost_ratio: 5.05
},
platform_ad_account_id: 2,
account_id: 2,
enabled: '<unknown>',
window: '',
window_days: '',
author_type: '',
current_revision_id: ''
})
};
fetch('https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules', 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://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'definition' => [
'action' => 'pause',
'minimum_counted_arrivals' => 4611686018427388000,
'cost_ratio' => 5.05
],
'platform_ad_account_id' => 2,
'account_id' => 2,
'enabled' => '<unknown>',
'window' => '',
'window_days' => '',
'author_type' => '',
'current_revision_id' => ''
]),
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://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"definition\": {\n \"action\": \"pause\",\n \"minimum_counted_arrivals\": 4611686018427388000,\n \"cost_ratio\": 5.05\n },\n \"platform_ad_account_id\": 2,\n \"account_id\": 2,\n \"enabled\": \"<unknown>\",\n \"window\": \"\",\n \"window_days\": \"\",\n \"author_type\": \"\",\n \"current_revision_id\": \"\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"definition\": {\n \"action\": \"pause\",\n \"minimum_counted_arrivals\": 4611686018427388000,\n \"cost_ratio\": 5.05\n },\n \"platform_ad_account_id\": 2,\n \"account_id\": 2,\n \"enabled\": \"<unknown>\",\n \"window\": \"\",\n \"window_days\": \"\",\n \"author_type\": \"\",\n \"current_revision_id\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://plainrouter.com/api/v1/agent/workspaces/{workspace}/action-rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"definition\": {\n \"action\": \"pause\",\n \"minimum_counted_arrivals\": 4611686018427388000,\n \"cost_ratio\": 5.05\n },\n \"platform_ad_account_id\": 2,\n \"account_id\": 2,\n \"enabled\": \"<unknown>\",\n \"window\": \"\",\n \"window_days\": \"\",\n \"author_type\": \"\",\n \"current_revision_id\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"rule": {
"id": "<string>",
"workspace_id": 123,
"platform_ad_account_id": 123,
"name": "<string>",
"enabled": true,
"suspended_at": "2023-11-07T05:31:56Z",
"suspended_reason": "<string>",
"window": {
"days": 3,
"kind": "last_complete_days",
"timezone": "<string>"
},
"current_revision": {
"id": "<string>",
"target_level": "ad",
"action": "pause",
"budget_change_percent": 123,
"minimum_counted_arrivals": 123,
"cost_comparison": "at_least",
"cost_ratio": "<string>",
"author_type": "user",
"created_at": "2023-11-07T05:31:56Z"
},
"revisions": [
{
"id": "<string>",
"target_level": "ad",
"action": "pause",
"budget_change_percent": 123,
"minimum_counted_arrivals": 123,
"cost_comparison": "at_least",
"cost_ratio": "<string>",
"author_type": "user",
"created_at": "2023-11-07T05:31:56Z"
}
]
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"error": {
"code": "api_route_not_found",
"message": "<string>",
"resolution": "<string>"
},
"request": {
"method": "<string>",
"path": "<string>"
},
"resources": {
"documentation": "<string>",
"openapi": "<string>"
}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>"
}{
"error": {
"code": "workspace_lock_timeout",
"message": "<string>"
}
}Authorizations
A workspace-scoped key with write ability and the actions.rules.store or actions.rules.update grant. Send Accept: application/json.
Path Parameters
The workspace ID
Body
Creates a disabled rule. enabled must be absent. window, window_days, author_type and current_revision_id must be absent or empty.
255\SOnly target_level, action, budget_change_percent, minimum_counted_arrivals, cost_comparison and cost_ratio are accepted.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
x >= 1Optional account ID, ignored by an account-bound key. An unbound key requires exactly one active available advertising account with an active connection; omission uses that account and a supplied ID must match it. Multiple active accounts return 422 even when account_id is supplied.
x >= 1Response
Saved rule with immutable revisions; no runs are included.
Show child attributes
Show child attributes