Compile and Save Instruction
curl --request POST \
--url http://localhost:8081/compile-and-save-instruction \
--header 'Content-Type: application/json' \
--data '
{
"script": "rule HighValueTransaction {\n description \"Review any transaction above $10,000\"\n when amount > 10000\n then review\n score 0.5\n reason \"Amount exceeds threshold\"\n}"
}
'import requests
url = "http://localhost:8081/compile-and-save-instruction"
payload = { "script": "rule HighValueTransaction {
description \"Review any transaction above $10,000\"
when amount > 10000
then review
score 0.5
reason \"Amount exceeds threshold\"
}" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
script: 'rule HighValueTransaction {\n description "Review any transaction above $10,000"\n when amount > 10000\n then review\n score 0.5\n reason "Amount exceeds threshold"\n}'
})
};
fetch('http://localhost:8081/compile-and-save-instruction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://localhost:8081/compile-and-save-instruction",
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([
'script' => 'rule HighValueTransaction {
description "Review any transaction above $10,000"
when amount > 10000
then review
score 0.5
reason "Amount exceeds threshold"
}'
]),
CURLOPT_HTTPHEADER => [
"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://localhost:8081/compile-and-save-instruction"
payload := strings.NewReader("{\n \"script\": \"rule HighValueTransaction {\\n description \\\"Review any transaction above $10,000\\\"\\n when amount > 10000\\n then review\\n score 0.5\\n reason \\\"Amount exceeds threshold\\\"\\n}\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://localhost:8081/compile-and-save-instruction")
.header("Content-Type", "application/json")
.body("{\n \"script\": \"rule HighValueTransaction {\\n description \\\"Review any transaction above $10,000\\\"\\n when amount > 10000\\n then review\\n score 0.5\\n reason \\\"Amount exceeds threshold\\\"\\n}\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8081/compile-and-save-instruction")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"script\": \"rule HighValueTransaction {\\n description \\\"Review any transaction above $10,000\\\"\\n when amount > 10000\\n then review\\n score 0.5\\n reason \\\"Amount exceeds threshold\\\"\\n}\"\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"name": "HighValueTransaction",
"text": "rule HighValueTransaction {\n description \"Review any transaction above $10,000\"\n when amount > 10000\n then review\n score 0.5\n reason \"Amount exceeds threshold\"\n}",
"description": "Review any transaction above $10,000",
"dsl_json": "{\"name\":\"HighValueTransaction\",\"when\":[...],\"then\":{...}}",
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}Instructions
Compile and Save
Compiles a Watchscript and saves it as an instruction. The script is validated and parsed into an AST, then stored in the database. Once saved, the rule is immediately active and will be evaluated against all incoming transactions.
POST
/
compile-and-save-instruction
Compile and Save Instruction
curl --request POST \
--url http://localhost:8081/compile-and-save-instruction \
--header 'Content-Type: application/json' \
--data '
{
"script": "rule HighValueTransaction {\n description \"Review any transaction above $10,000\"\n when amount > 10000\n then review\n score 0.5\n reason \"Amount exceeds threshold\"\n}"
}
'import requests
url = "http://localhost:8081/compile-and-save-instruction"
payload = { "script": "rule HighValueTransaction {
description \"Review any transaction above $10,000\"
when amount > 10000
then review
score 0.5
reason \"Amount exceeds threshold\"
}" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
script: 'rule HighValueTransaction {\n description "Review any transaction above $10,000"\n when amount > 10000\n then review\n score 0.5\n reason "Amount exceeds threshold"\n}'
})
};
fetch('http://localhost:8081/compile-and-save-instruction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://localhost:8081/compile-and-save-instruction",
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([
'script' => 'rule HighValueTransaction {
description "Review any transaction above $10,000"
when amount > 10000
then review
score 0.5
reason "Amount exceeds threshold"
}'
]),
CURLOPT_HTTPHEADER => [
"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://localhost:8081/compile-and-save-instruction"
payload := strings.NewReader("{\n \"script\": \"rule HighValueTransaction {\\n description \\\"Review any transaction above $10,000\\\"\\n when amount > 10000\\n then review\\n score 0.5\\n reason \\\"Amount exceeds threshold\\\"\\n}\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://localhost:8081/compile-and-save-instruction")
.header("Content-Type", "application/json")
.body("{\n \"script\": \"rule HighValueTransaction {\\n description \\\"Review any transaction above $10,000\\\"\\n when amount > 10000\\n then review\\n score 0.5\\n reason \\\"Amount exceeds threshold\\\"\\n}\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8081/compile-and-save-instruction")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"script\": \"rule HighValueTransaction {\\n description \\\"Review any transaction above $10,000\\\"\\n when amount > 10000\\n then review\\n score 0.5\\n reason \\\"Amount exceeds threshold\\\"\\n}\"\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"name": "HighValueTransaction",
"text": "rule HighValueTransaction {\n description \"Review any transaction above $10,000\"\n when amount > 10000\n then review\n score 0.5\n reason \"Amount exceeds threshold\"\n}",
"description": "Review any transaction above $10,000",
"dsl_json": "{\"name\":\"HighValueTransaction\",\"when\":[...],\"then\":{...}}",
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}Body
application/json
The Watchscript source code to compile and save
Response
Instruction compiled and saved successfully
Unique instruction identifier
Rule name (extracted from Watchscript)
The original Watchscript source text
Human-readable description (extracted from Watchscript)
Compiled DSL as JSON string (AST representation)
Creation timestamp
Last update timestamp
⌘I
.png?fit=max&auto=format&n=0JF6z69u57hmqsWm&q=85&s=531373acedba0eb783b669f6d558dfd8)