Create monitor
curl --request POST \
--url https://api.trymaitai.ai/api/v1/monitors \
--header 'Content-Type: application/json' \
--header 'X-Maitai-Api-Key: <api-key>' \
--data '
{
"name": "Order intake completeness",
"description": "Catches order intents that miss customer_id or order_total.",
"config": {
"runner": {
"resource_type": "direct",
"input": {
"response_path": "response"
}
},
"result": {
"error": {
"id": "g_err",
"kind": "group",
"op": "OR",
"children": [
{
"id": "c1",
"kind": "condition",
"source": "json",
"path": "customer_id",
"operator": "does_not_exist",
"value": ""
},
{
"id": "c2",
"kind": "condition",
"source": "json",
"path": "order_total",
"operator": "does_not_exist",
"value": ""
}
]
},
"warning": {
"id": "g_warn",
"kind": "group",
"op": "OR",
"children": []
},
"default_outcome": "pass"
}
}
}
'import requests
url = "https://api.trymaitai.ai/api/v1/monitors"
payload = {
"name": "Order intake completeness",
"description": "Catches order intents that miss customer_id or order_total.",
"config": {
"runner": {
"resource_type": "direct",
"input": { "response_path": "response" }
},
"result": {
"error": {
"id": "g_err",
"kind": "group",
"op": "OR",
"children": [
{
"id": "c1",
"kind": "condition",
"source": "json",
"path": "customer_id",
"operator": "does_not_exist",
"value": ""
},
{
"id": "c2",
"kind": "condition",
"source": "json",
"path": "order_total",
"operator": "does_not_exist",
"value": ""
}
]
},
"warning": {
"id": "g_warn",
"kind": "group",
"op": "OR",
"children": []
},
"default_outcome": "pass"
}
}
}
headers = {
"X-Maitai-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Maitai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Order intake completeness',
description: 'Catches order intents that miss customer_id or order_total.',
config: {
runner: {resource_type: 'direct', input: {response_path: 'response'}},
result: {
error: {
id: 'g_err',
kind: 'group',
op: 'OR',
children: [
{
id: 'c1',
kind: 'condition',
source: 'json',
path: 'customer_id',
operator: 'does_not_exist',
value: ''
},
{
id: 'c2',
kind: 'condition',
source: 'json',
path: 'order_total',
operator: 'does_not_exist',
value: ''
}
]
},
warning: {id: 'g_warn', kind: 'group', op: 'OR', children: []},
default_outcome: 'pass'
}
}
})
};
fetch('https://api.trymaitai.ai/api/v1/monitors', 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.trymaitai.ai/api/v1/monitors",
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' => 'Order intake completeness',
'description' => 'Catches order intents that miss customer_id or order_total.',
'config' => [
'runner' => [
'resource_type' => 'direct',
'input' => [
'response_path' => 'response'
]
],
'result' => [
'error' => [
'id' => 'g_err',
'kind' => 'group',
'op' => 'OR',
'children' => [
[
'id' => 'c1',
'kind' => 'condition',
'source' => 'json',
'path' => 'customer_id',
'operator' => 'does_not_exist',
'value' => ''
],
[
'id' => 'c2',
'kind' => 'condition',
'source' => 'json',
'path' => 'order_total',
'operator' => 'does_not_exist',
'value' => ''
]
]
],
'warning' => [
'id' => 'g_warn',
'kind' => 'group',
'op' => 'OR',
'children' => [
]
],
'default_outcome' => 'pass'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Maitai-Api-Key: <api-key>"
],
]);
$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.trymaitai.ai/api/v1/monitors"
payload := strings.NewReader("{\n \"name\": \"Order intake completeness\",\n \"description\": \"Catches order intents that miss customer_id or order_total.\",\n \"config\": {\n \"runner\": {\n \"resource_type\": \"direct\",\n \"input\": {\n \"response_path\": \"response\"\n }\n },\n \"result\": {\n \"error\": {\n \"id\": \"g_err\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": [\n {\n \"id\": \"c1\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"customer_id\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n },\n {\n \"id\": \"c2\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"order_total\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n }\n ]\n },\n \"warning\": {\n \"id\": \"g_warn\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": []\n },\n \"default_outcome\": \"pass\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Maitai-Api-Key", "<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))
}HttpResponse<String> response = Unirest.post("https://api.trymaitai.ai/api/v1/monitors")
.header("X-Maitai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Order intake completeness\",\n \"description\": \"Catches order intents that miss customer_id or order_total.\",\n \"config\": {\n \"runner\": {\n \"resource_type\": \"direct\",\n \"input\": {\n \"response_path\": \"response\"\n }\n },\n \"result\": {\n \"error\": {\n \"id\": \"g_err\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": [\n {\n \"id\": \"c1\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"customer_id\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n },\n {\n \"id\": \"c2\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"order_total\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n }\n ]\n },\n \"warning\": {\n \"id\": \"g_warn\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": []\n },\n \"default_outcome\": \"pass\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trymaitai.ai/api/v1/monitors")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Maitai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Order intake completeness\",\n \"description\": \"Catches order intents that miss customer_id or order_total.\",\n \"config\": {\n \"runner\": {\n \"resource_type\": \"direct\",\n \"input\": {\n \"response_path\": \"response\"\n }\n },\n \"result\": {\n \"error\": {\n \"id\": \"g_err\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": [\n {\n \"id\": \"c1\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"customer_id\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n },\n {\n \"id\": \"c2\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"order_total\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n }\n ]\n },\n \"warning\": {\n \"id\": \"g_warn\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": []\n },\n \"default_outcome\": \"pass\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 502,
"name": "Order intake completeness",
"status": "DRAFT",
"target_count": 0,
"has_unpublished_changes": true
}
}Monitors
Create monitor
Create a reusable production monitor. New monitors land in DRAFT.
POST
/
monitors
Create monitor
curl --request POST \
--url https://api.trymaitai.ai/api/v1/monitors \
--header 'Content-Type: application/json' \
--header 'X-Maitai-Api-Key: <api-key>' \
--data '
{
"name": "Order intake completeness",
"description": "Catches order intents that miss customer_id or order_total.",
"config": {
"runner": {
"resource_type": "direct",
"input": {
"response_path": "response"
}
},
"result": {
"error": {
"id": "g_err",
"kind": "group",
"op": "OR",
"children": [
{
"id": "c1",
"kind": "condition",
"source": "json",
"path": "customer_id",
"operator": "does_not_exist",
"value": ""
},
{
"id": "c2",
"kind": "condition",
"source": "json",
"path": "order_total",
"operator": "does_not_exist",
"value": ""
}
]
},
"warning": {
"id": "g_warn",
"kind": "group",
"op": "OR",
"children": []
},
"default_outcome": "pass"
}
}
}
'import requests
url = "https://api.trymaitai.ai/api/v1/monitors"
payload = {
"name": "Order intake completeness",
"description": "Catches order intents that miss customer_id or order_total.",
"config": {
"runner": {
"resource_type": "direct",
"input": { "response_path": "response" }
},
"result": {
"error": {
"id": "g_err",
"kind": "group",
"op": "OR",
"children": [
{
"id": "c1",
"kind": "condition",
"source": "json",
"path": "customer_id",
"operator": "does_not_exist",
"value": ""
},
{
"id": "c2",
"kind": "condition",
"source": "json",
"path": "order_total",
"operator": "does_not_exist",
"value": ""
}
]
},
"warning": {
"id": "g_warn",
"kind": "group",
"op": "OR",
"children": []
},
"default_outcome": "pass"
}
}
}
headers = {
"X-Maitai-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Maitai-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Order intake completeness',
description: 'Catches order intents that miss customer_id or order_total.',
config: {
runner: {resource_type: 'direct', input: {response_path: 'response'}},
result: {
error: {
id: 'g_err',
kind: 'group',
op: 'OR',
children: [
{
id: 'c1',
kind: 'condition',
source: 'json',
path: 'customer_id',
operator: 'does_not_exist',
value: ''
},
{
id: 'c2',
kind: 'condition',
source: 'json',
path: 'order_total',
operator: 'does_not_exist',
value: ''
}
]
},
warning: {id: 'g_warn', kind: 'group', op: 'OR', children: []},
default_outcome: 'pass'
}
}
})
};
fetch('https://api.trymaitai.ai/api/v1/monitors', 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.trymaitai.ai/api/v1/monitors",
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' => 'Order intake completeness',
'description' => 'Catches order intents that miss customer_id or order_total.',
'config' => [
'runner' => [
'resource_type' => 'direct',
'input' => [
'response_path' => 'response'
]
],
'result' => [
'error' => [
'id' => 'g_err',
'kind' => 'group',
'op' => 'OR',
'children' => [
[
'id' => 'c1',
'kind' => 'condition',
'source' => 'json',
'path' => 'customer_id',
'operator' => 'does_not_exist',
'value' => ''
],
[
'id' => 'c2',
'kind' => 'condition',
'source' => 'json',
'path' => 'order_total',
'operator' => 'does_not_exist',
'value' => ''
]
]
],
'warning' => [
'id' => 'g_warn',
'kind' => 'group',
'op' => 'OR',
'children' => [
]
],
'default_outcome' => 'pass'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Maitai-Api-Key: <api-key>"
],
]);
$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.trymaitai.ai/api/v1/monitors"
payload := strings.NewReader("{\n \"name\": \"Order intake completeness\",\n \"description\": \"Catches order intents that miss customer_id or order_total.\",\n \"config\": {\n \"runner\": {\n \"resource_type\": \"direct\",\n \"input\": {\n \"response_path\": \"response\"\n }\n },\n \"result\": {\n \"error\": {\n \"id\": \"g_err\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": [\n {\n \"id\": \"c1\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"customer_id\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n },\n {\n \"id\": \"c2\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"order_total\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n }\n ]\n },\n \"warning\": {\n \"id\": \"g_warn\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": []\n },\n \"default_outcome\": \"pass\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Maitai-Api-Key", "<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))
}HttpResponse<String> response = Unirest.post("https://api.trymaitai.ai/api/v1/monitors")
.header("X-Maitai-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Order intake completeness\",\n \"description\": \"Catches order intents that miss customer_id or order_total.\",\n \"config\": {\n \"runner\": {\n \"resource_type\": \"direct\",\n \"input\": {\n \"response_path\": \"response\"\n }\n },\n \"result\": {\n \"error\": {\n \"id\": \"g_err\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": [\n {\n \"id\": \"c1\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"customer_id\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n },\n {\n \"id\": \"c2\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"order_total\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n }\n ]\n },\n \"warning\": {\n \"id\": \"g_warn\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": []\n },\n \"default_outcome\": \"pass\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trymaitai.ai/api/v1/monitors")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Maitai-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Order intake completeness\",\n \"description\": \"Catches order intents that miss customer_id or order_total.\",\n \"config\": {\n \"runner\": {\n \"resource_type\": \"direct\",\n \"input\": {\n \"response_path\": \"response\"\n }\n },\n \"result\": {\n \"error\": {\n \"id\": \"g_err\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": [\n {\n \"id\": \"c1\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"customer_id\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n },\n {\n \"id\": \"c2\",\n \"kind\": \"condition\",\n \"source\": \"json\",\n \"path\": \"order_total\",\n \"operator\": \"does_not_exist\",\n \"value\": \"\"\n }\n ]\n },\n \"warning\": {\n \"id\": \"g_warn\",\n \"kind\": \"group\",\n \"op\": \"OR\",\n \"children\": []\n },\n \"default_outcome\": \"pass\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 502,
"name": "Order intake completeness",
"status": "DRAFT",
"target_count": 0,
"has_unpublished_changes": true
}
}Was this page helpful?
⌘I