Create an advanced rule
Project-scoped operation. Requires the advanced_rules add-on. Successful JSON and status-only responses vary by operation. The service does not declare a stable response schema for this operation; do not assume a collection envelope or undocumented fields.
POST
/
shield
/
domains
/
{domain_id}
/
advanced-rules
Create an advanced rule
curl --request POST \
--url https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules \
--header 'Aptranet-Secret: <api-key>' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "Block foobar bot",
"enabled": true,
"action": {
"allow": {},
"block": {
"action_duration": "12h"
},
"captcha": {},
"handshake": {},
"monitor": {}
},
"source": "request.rate_limit([], '.*events', 5, 200, [], [], '', 'ip') and not ('mb-web-ui' in request.headers['Cookie'] or 'mb-mobile-ios' in request.headers['Cookie'] or 'session-token' in request.headers['Cookie']) and not request.headers['session']"
}
EOFimport requests
url = "https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules"
payload = {
"name": "Block foobar bot",
"enabled": True,
"action": {
"allow": {},
"block": { "action_duration": "12h" },
"captcha": {},
"handshake": {},
"monitor": {}
},
"source": "request.rate_limit([], '.*events', 5, 200, [], [], '', 'ip') and not ('mb-web-ui' in request.headers['Cookie'] or 'mb-mobile-ios' in request.headers['Cookie'] or 'session-token' in request.headers['Cookie']) and not request.headers['session']"
}
headers = {
"Authorization": "Bearer <token>",
"Aptranet-Secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Aptranet-Secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Block foobar bot',
enabled: true,
action: {
allow: {},
block: {action_duration: '12h'},
captcha: {},
handshake: {},
monitor: {}
},
source: 'request.rate_limit([], \'.*events\', 5, 200, [], [], \'\', \'ip\') and not (\'mb-web-ui\' in request.headers[\'Cookie\'] or \'mb-mobile-ios\' in request.headers[\'Cookie\'] or \'session-token\' in request.headers[\'Cookie\']) and not request.headers[\'session\']'
})
};
fetch('https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules"
payload := strings.NewReader("{\n \"name\": \"Block foobar bot\",\n \"enabled\": true,\n \"action\": {\n \"allow\": {},\n \"block\": {\n \"action_duration\": \"12h\"\n },\n \"captcha\": {},\n \"handshake\": {},\n \"monitor\": {}\n },\n \"source\": \"request.rate_limit([], '.*events', 5, 200, [], [], '', 'ip') and not ('mb-web-ui' in request.headers['Cookie'] or 'mb-mobile-ios' in request.headers['Cookie'] or 'session-token' in request.headers['Cookie']) and not request.headers['session']\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Aptranet-Secret", "<api-key>")
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))
}{
"error": "<string>",
"error_description": "<string>"
}Authorizations
Project API access key.
Current secret for the access key.
Path Parameters
Body
application/json
Required string length:
1 - 100Example:
"Block foobar bot"
Show child attributes
Show child attributes
Minimum string length:
1Example:
"request.rate_limit([], '.*events', 5, 200, [], [], '', 'ip') and not ('mb-web-ui' in request.headers['Cookie'] or 'mb-mobile-ios' in request.headers['Cookie'] or 'session-token' in request.headers['Cookie']) and not request.headers['session']"
Maximum string length:
100Available options:
access, header_filter, body_filter Response
Successful response.
Create an advanced rule
curl --request POST \
--url https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules \
--header 'Aptranet-Secret: <api-key>' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "Block foobar bot",
"enabled": true,
"action": {
"allow": {},
"block": {
"action_duration": "12h"
},
"captcha": {},
"handshake": {},
"monitor": {}
},
"source": "request.rate_limit([], '.*events', 5, 200, [], [], '', 'ip') and not ('mb-web-ui' in request.headers['Cookie'] or 'mb-mobile-ios' in request.headers['Cookie'] or 'session-token' in request.headers['Cookie']) and not request.headers['session']"
}
EOFimport requests
url = "https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules"
payload = {
"name": "Block foobar bot",
"enabled": True,
"action": {
"allow": {},
"block": { "action_duration": "12h" },
"captcha": {},
"handshake": {},
"monitor": {}
},
"source": "request.rate_limit([], '.*events', 5, 200, [], [], '', 'ip') and not ('mb-web-ui' in request.headers['Cookie'] or 'mb-mobile-ios' in request.headers['Cookie'] or 'session-token' in request.headers['Cookie']) and not request.headers['session']"
}
headers = {
"Authorization": "Bearer <token>",
"Aptranet-Secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Aptranet-Secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Block foobar bot',
enabled: true,
action: {
allow: {},
block: {action_duration: '12h'},
captcha: {},
handshake: {},
monitor: {}
},
source: 'request.rate_limit([], \'.*events\', 5, 200, [], [], \'\', \'ip\') and not (\'mb-web-ui\' in request.headers[\'Cookie\'] or \'mb-mobile-ios\' in request.headers[\'Cookie\'] or \'session-token\' in request.headers[\'Cookie\']) and not request.headers[\'session\']'
})
};
fetch('https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aptranet.com/shield/domains/{domain_id}/advanced-rules"
payload := strings.NewReader("{\n \"name\": \"Block foobar bot\",\n \"enabled\": true,\n \"action\": {\n \"allow\": {},\n \"block\": {\n \"action_duration\": \"12h\"\n },\n \"captcha\": {},\n \"handshake\": {},\n \"monitor\": {}\n },\n \"source\": \"request.rate_limit([], '.*events', 5, 200, [], [], '', 'ip') and not ('mb-web-ui' in request.headers['Cookie'] or 'mb-mobile-ios' in request.headers['Cookie'] or 'session-token' in request.headers['Cookie']) and not request.headers['session']\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Aptranet-Secret", "<api-key>")
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))
}{
"error": "<string>",
"error_description": "<string>"
}