Update Rule
curl --request PATCH \
--url http://api.gu1.ai/rules/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"category": "<string>",
"enabled": true,
"priority": 123,
"score": 123,
"status": "<string>",
"conditions": {},
"actions": [
{}
],
"targetEntityTypes": [
{}
],
"evaluationMode": "<string>",
"riskMatrixId": "<string>",
"scope": {},
"tags": [
{}
]
}
'import requests
url = "http://api.gu1.ai/rules/{id}"
payload = {
"name": "<string>",
"description": "<string>",
"category": "<string>",
"enabled": True,
"priority": 123,
"score": 123,
"status": "<string>",
"conditions": {},
"actions": [{}],
"targetEntityTypes": [{}],
"evaluationMode": "<string>",
"riskMatrixId": "<string>",
"scope": {},
"tags": [{}]
}
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({
name: '<string>',
description: '<string>',
category: '<string>',
enabled: true,
priority: 123,
score: 123,
status: '<string>',
conditions: {},
actions: [{}],
targetEntityTypes: [{}],
evaluationMode: '<string>',
riskMatrixId: '<string>',
scope: {},
tags: [{}]
})
};
fetch('http://api.gu1.ai/rules/{id}', 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 => "http://api.gu1.ai/rules/{id}",
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([
'name' => '<string>',
'description' => '<string>',
'category' => '<string>',
'enabled' => true,
'priority' => 123,
'score' => 123,
'status' => '<string>',
'conditions' => [
],
'actions' => [
[
]
],
'targetEntityTypes' => [
[
]
],
'evaluationMode' => '<string>',
'riskMatrixId' => '<string>',
'scope' => [
],
'tags' => [
[
]
]
]),
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 := "http://api.gu1.ai/rules/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"category\": \"<string>\",\n \"enabled\": true,\n \"priority\": 123,\n \"score\": 123,\n \"status\": \"<string>\",\n \"conditions\": {},\n \"actions\": [\n {}\n ],\n \"targetEntityTypes\": [\n {}\n ],\n \"evaluationMode\": \"<string>\",\n \"riskMatrixId\": \"<string>\",\n \"scope\": {},\n \"tags\": [\n {}\n ]\n}")
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("http://api.gu1.ai/rules/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"category\": \"<string>\",\n \"enabled\": true,\n \"priority\": 123,\n \"score\": 123,\n \"status\": \"<string>\",\n \"conditions\": {},\n \"actions\": [\n {}\n ],\n \"targetEntityTypes\": [\n {}\n ],\n \"evaluationMode\": \"<string>\",\n \"riskMatrixId\": \"<string>\",\n \"scope\": {},\n \"tags\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/rules/{id}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"category\": \"<string>\",\n \"enabled\": true,\n \"priority\": 123,\n \"score\": 123,\n \"status\": \"<string>\",\n \"conditions\": {},\n \"actions\": [\n {}\n ],\n \"targetEntityTypes\": [\n {}\n ],\n \"evaluationMode\": \"<string>\",\n \"riskMatrixId\": \"<string>\",\n \"scope\": {},\n \"tags\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"version": 123,
"previousVersionId": "<string>",
"updatedBy": "<string>",
"updatedAt": "<string>"
}API Reference
Update Rule
Update an existing rule configuration β in the gu1 rules engine for compliance and risk detection, with examples for update use cases.
PATCH
/
rules
/
{id}
Update Rule
curl --request PATCH \
--url http://api.gu1.ai/rules/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"category": "<string>",
"enabled": true,
"priority": 123,
"score": 123,
"status": "<string>",
"conditions": {},
"actions": [
{}
],
"targetEntityTypes": [
{}
],
"evaluationMode": "<string>",
"riskMatrixId": "<string>",
"scope": {},
"tags": [
{}
]
}
'import requests
url = "http://api.gu1.ai/rules/{id}"
payload = {
"name": "<string>",
"description": "<string>",
"category": "<string>",
"enabled": True,
"priority": 123,
"score": 123,
"status": "<string>",
"conditions": {},
"actions": [{}],
"targetEntityTypes": [{}],
"evaluationMode": "<string>",
"riskMatrixId": "<string>",
"scope": {},
"tags": [{}]
}
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({
name: '<string>',
description: '<string>',
category: '<string>',
enabled: true,
priority: 123,
score: 123,
status: '<string>',
conditions: {},
actions: [{}],
targetEntityTypes: [{}],
evaluationMode: '<string>',
riskMatrixId: '<string>',
scope: {},
tags: [{}]
})
};
fetch('http://api.gu1.ai/rules/{id}', 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 => "http://api.gu1.ai/rules/{id}",
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([
'name' => '<string>',
'description' => '<string>',
'category' => '<string>',
'enabled' => true,
'priority' => 123,
'score' => 123,
'status' => '<string>',
'conditions' => [
],
'actions' => [
[
]
],
'targetEntityTypes' => [
[
]
],
'evaluationMode' => '<string>',
'riskMatrixId' => '<string>',
'scope' => [
],
'tags' => [
[
]
]
]),
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 := "http://api.gu1.ai/rules/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"category\": \"<string>\",\n \"enabled\": true,\n \"priority\": 123,\n \"score\": 123,\n \"status\": \"<string>\",\n \"conditions\": {},\n \"actions\": [\n {}\n ],\n \"targetEntityTypes\": [\n {}\n ],\n \"evaluationMode\": \"<string>\",\n \"riskMatrixId\": \"<string>\",\n \"scope\": {},\n \"tags\": [\n {}\n ]\n}")
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("http://api.gu1.ai/rules/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"category\": \"<string>\",\n \"enabled\": true,\n \"priority\": 123,\n \"score\": 123,\n \"status\": \"<string>\",\n \"conditions\": {},\n \"actions\": [\n {}\n ],\n \"targetEntityTypes\": [\n {}\n ],\n \"evaluationMode\": \"<string>\",\n \"riskMatrixId\": \"<string>\",\n \"scope\": {},\n \"tags\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://api.gu1.ai/rules/{id}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"category\": \"<string>\",\n \"enabled\": true,\n \"priority\": 123,\n \"score\": 123,\n \"status\": \"<string>\",\n \"conditions\": {},\n \"actions\": [\n {}\n ],\n \"targetEntityTypes\": [\n {}\n ],\n \"evaluationMode\": \"<string>\",\n \"riskMatrixId\": \"<string>\",\n \"scope\": {},\n \"tags\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"version": 123,
"previousVersionId": "<string>",
"updatedBy": "<string>",
"updatedAt": "<string>"
}Overview
Updates an existing ruleβs configuration. All fields are optional - only include the fields you want to update. Updating a rule automatically increments its version number and maintains version history for audit purposes.Endpoint
PATCH http://api.gu1.ai/rules/{id}
Authentication
Requires a valid API key in the Authorization header:Authorization: Bearer YOUR_API_KEY
Path Parameters
string
required
UUID of the rule to update
Request Body
All fields are optional. Only include fields you want to modify.string
Update rule name
string
Update rule description
string
Update category:
kyc, kyb, aml, fraud, compliance, customboolean
Enable or disable the rule
number
Update priority (1-100)
number
Update risk score (0-100)
string
Update status:
draft, in_progress, in_review, active, shadow, archived, inactiveobject
Update condition logic
array
Update actions array
array
Update target entity types
string
Update evaluation mode:
sync or asyncstring
Update associated risk matrix UUID
object
Update scope configuration
array
Update tags array
Response
string
UUID of the updated rule
number
New version number (incremented)
string
UUID of the previous version
string
User ID who updated the rule
string
ISO timestamp of the update
Example Requests
Enable/Disable Rule
curl -X PATCH http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"enabled": false
}'
const response = await fetch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
{
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
enabled: false
})
}
);
const rule = await response.json();
console.log('Rule disabled. New version:', rule.version);
import requests
response = requests.patch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'enabled': False
}
)
rule = response.json()
print(f"Rule disabled. New version: {rule['version']}")
Update Priority and Score
curl -X PATCH http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"priority": 90,
"score": 75
}'
const response = await fetch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
{
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
priority: 90,
score: 75
})
}
);
const rule = await response.json();
console.log('Priority and score updated');
response = requests.patch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'priority': 90,
'score': 75
}
)
rule = response.json()
print('Priority and score updated')
Update Conditions
curl -X PATCH http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"conditions": {
"operator": "OR",
"conditions": [
{
"id": "cond-1",
"type": "simple",
"field": "enrichmentData.normalized.taxId",
"operator": "eq",
"value": "33.592.510/0001-54",
"filters": []
},
{
"id": "cond-2",
"type": "simple",
"field": "enrichmentData.normalized.taxId",
"operator": "eq",
"value": "12.345.678/0001-90",
"filters": []
}
]
}
}'
const response = await fetch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
{
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
conditions: {
operator: 'OR',
conditions: [
{
id: 'cond-1',
type: 'simple',
field: 'enrichmentData.normalized.taxId',
operator: 'eq',
value: '33.592.510/0001-54',
filters: []
},
{
id: 'cond-2',
type: 'simple',
field: 'enrichmentData.normalized.taxId',
operator: 'eq',
value: '12.345.678/0001-90',
filters: []
}
]
}
})
}
);
const rule = await response.json();
console.log('Conditions updated. Now checking 2 CNPJs');
response = requests.patch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'conditions': {
'operator': 'OR',
'conditions': [
{
'id': 'cond-1',
'type': 'simple',
'field': 'enrichmentData.normalized.taxId',
'operator': 'eq',
'value': '33.592.510/0001-54',
'filters': []
},
{
'id': 'cond-2',
'type': 'simple',
'field': 'enrichmentData.normalized.taxId',
'operator': 'eq',
'value': '12.345.678/0001-90',
'filters': []
}
]
}
}
)
rule = response.json()
print('Conditions updated. Now checking 2 CNPJs')
Add Actions
curl -X PATCH http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"actions": [
{
"type": "createAlert",
"createAlert": {
"type": "COMPLIANCE",
"title": "High Risk Entity Detected",
"description": "Entity matched high-risk criteria",
"severity": "CRITICAL",
"recipients": ["compliance@company.com", "security@company.com"]
},
"tags": ["high-risk", "urgent"]
},
{
"type": "updateEntityStatus",
"updateEntityStatus": {
"status": "under_review",
"reason": "Flagged by automated rule"
}
},
{
"type": "sendNotification",
"sendNotification": {
"channel": "email",
"recipients": ["compliance-lead@company.com"],
"message": "Immediate review required for high-risk entity"
}
}
]
}'
Update Status to Shadow Mode
curl -X PATCH http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "shadow",
"enabled": true
}'
// Deploy rule in shadow mode (logs matches without executing actions)
const response = await fetch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
{
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'shadow',
enabled: true
})
}
);
const rule = await response.json();
console.log('Rule deployed in shadow mode for testing');
# Deploy rule in shadow mode
response = requests.patch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'status': 'shadow',
'enabled': True
}
)
rule = response.json()
print('Rule deployed in shadow mode for testing')
Update Tags
curl -X PATCH http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tags": ["blocklist", "high-priority", "brazil", "automated"]
}'
const response = await fetch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
{
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
tags: ['blocklist', 'high-priority', 'brazil', 'automated']
})
}
);
const rule = await response.json();
console.log('Tags updated');
response = requests.patch(
'http://api.gu1.ai/rules/e2cdd639-52cc-4749-9b16-927bfa5dfaea',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'tags': ['blocklist', 'high-priority', 'brazil', 'automated']
}
)
rule = response.json()
print('Tags updated')
Response Example
{
"id": "e2cdd639-52cc-4749-9b16-927bfa5dfaea",
"organizationId": "71e8f908-e032-4fcb-b0ce-ad0cd0ffb236",
"name": "CNPJ Blocklist Check",
"description": "Block companies with specific CNPJ",
"category": "kyb",
"status": "active",
"enabled": true,
"priority": 90,
"score": 75,
"conditions": {...},
"actions": [...],
"scope": {...},
"targetEntityTypes": ["company"],
"evaluationMode": "sync",
"riskMatrixId": "d257247b-af7b-402a-ad8f-eac209e2990e",
"version": 2,
"previousVersionId": "e2cdd639-52cc-4749-9b16-927bfa5dfaea-v1",
"tags": ["blocklist", "high-priority"],
"createdBy": "f35c10cb-9b67-4cda-9aea-f36567375dba",
"createdAt": "2024-12-22T14:10:28.131Z",
"updatedBy": "f35c10cb-9b67-4cda-9aea-f36567375dba",
"updatedAt": "2024-12-23T10:30:00.000Z",
"stats": {
"failures": 0,
"successes": 7,
"executions": 7
}
}
Error Responses
404 Not Found
{
"error": "Rule not found",
"id": "e2cdd639-52cc-4749-9b16-927bfa5dfaea"
}
400 Bad Request - Invalid Data
{
"error": "Validation failed",
"details": {
"field": "priority",
"message": "Priority must be between 1 and 100"
}
}
401 Unauthorized
{
"error": "Invalid or missing API key"
}
403 Forbidden
{
"error": "Access denied",
"message": "You don't have permission to update this rule"
}
409 Conflict
{
"error": "Rule is currently being executed",
"message": "Cannot update rule during active execution"
}
Use Cases
Progressive Rule Refinement
// Start with shadow mode, then gradually activate
async function deployRuleProgressively(ruleId) {
// Phase 1: Deploy in shadow mode
console.log('Phase 1: Shadow mode deployment...');
await fetch(`http://api.gu1.ai/rules/${ruleId}`, {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'shadow',
enabled: true
})
});
// Wait and monitor for 1 week...
console.log('Monitoring shadow mode for 1 week...');
// Phase 2: Activate with low priority
console.log('Phase 2: Activating with low priority...');
await fetch(`http://api.gu1.ai/rules/${ruleId}`, {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'active',
priority: 20
})
});
// Wait and monitor performance...
console.log('Monitoring performance...');
// Phase 3: Increase priority if performing well
console.log('Phase 3: Increasing priority...');
await fetch(`http://api.gu1.ai/rules/${ruleId}`, {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
priority: 80
})
});
console.log('β
Rule fully deployed');
}
Bulk Update Rules by Category
def bulk_update_by_category(category, updates):
"""Update all rules in a category"""
# Get all rules in category
response = requests.get(
'http://api.gu1.ai/rules',
headers={
'Authorization': 'Bearer YOUR_API_KEY'
},
params={
'category': category,
'pageSize': 100
}
)
rules = response.json()['rules']
print(f"Updating {len(rules)} rules in category '{category}'...")
for rule in rules:
update_response = requests.patch(
f'http://api.gu1.ai/rules/{rule["id"]}',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json=updates
)
if update_response.status_code == 200:
print(f" β
Updated: {rule['name']}")
else:
print(f" β Failed: {rule['name']}")
print(f"Bulk update completed")
# Example: Disable all AML rules temporarily
bulk_update_by_category('aml', {'enabled': False})
A/B Testing Rules
async function setupRuleABTest(ruleId) {
// Get original rule
const originalResponse = await fetch(
`http://api.gu1.ai/rules/${ruleId}`,
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
}
);
const original = await originalResponse.json();
// Create variant with different score
const variantResponse = await fetch(
'http://api.gu1.ai/rules',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
...original,
id: undefined,
name: original.name + ' (Variant)',
score: original.score + 10,
tags: [...original.tags, 'ab-test', 'variant'],
enabled: false // Start disabled
})
}
);
const variant = await variantResponse.json();
// Tag original as control
await fetch(`http://api.gu1.ai/rules/${ruleId}`, {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
tags: [...original.tags, 'ab-test', 'control']
})
});
console.log('A/B test setup complete');
console.log('Control:', ruleId);
console.log('Variant:', variant.id);
return { control: ruleId, variant: variant.id };
}
Rotate Action Recipients
def rotate_alert_recipients(rule_id, new_recipients):
"""Update alert recipients for a rule"""
# Get current rule
response = requests.get(
f'http://api.gu1.ai/rules/{rule_id}',
headers={
'Authorization': 'Bearer YOUR_API_KEY'
}
)
rule = response.json()
# Update alert recipients in actions
updated_actions = []
for action in rule['actions']:
if action['type'] == 'createAlert':
action['createAlert']['recipients'] = new_recipients
updated_actions.append(action)
# Update rule
update_response = requests.patch(
f'http://api.gu1.ai/rules/{rule_id}',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'actions': updated_actions
}
)
if update_response.status_code == 200:
print(f"β
Alert recipients updated to: {new_recipients}")
else:
print(f"β Failed to update recipients")
return update_response.json()
Best Practices
- Partial Updates: Only send fields you want to change
- Test First: Use execute endpoint to test before updating production rules
- Shadow Mode: Test condition changes in shadow mode before activating
- Version History: Keep track of version numbers for rollback capability
- Monitor Stats: Watch execution statistics after updates
- Gradual Rollout: Update priority gradually when deploying new logic
- Tag Changes: Tag rules with update metadata for tracking
Versioning
Each update creates a new version:version: Increments by 1previousVersionId: Links to previous version- Version history is maintained for audit and rollback
Notes
- Updates are applied immediately for sync rules
- Async rules may take a few minutes to reflect changes
- Statistics are preserved across updates
- Disabled rules donβt execute but remain in the system
See Also
- Get Rule - Retrieve current rule state
- Execute Rule - Test updated rules
- Create Rule - Create new rules
- List Rules - Query rules
Was this page helpful?
βI