API reference OpenAPI 3.1
POST /rules:validate

Validate rule

Bearer API key or staff session application/json operation validateRule

Request

Content type: application/json · required

FieldTypeRequiredDescription
key string Yes —
name string Yes —
description string No —
typology string No —
trigger object No
Show 2 nested fields
FieldTypeRequiredDescription
events array of string No —
filter string No —
features array of object No
Show 6 nested fields
FieldTypeRequiredDescription
name string Yes —
agg string Yes one of count, sum, avg, max, min, distinct_count, last, first, stddev
window string Yes —
group_by array of string No —
where string No —
field string No —
condition string Yes max length 4096
suppress_if string No max length 1024
groups array of object No
Show 2 nested fields
FieldTypeRequiredDescription
op string Yes one of all_of, any_of, not
conditions array of string Yes —
outcome object Yes
Show 5 nested fields
FieldTypeRequiredDescription
severity string Yes one of low, medium, high, critical
score number No —
decision string Yes one of ALLOW, REVIEW, HOLD, BLOCK
reason_code string Yes —
explain string No —
actions array of object No —
params object No —
schedule object No
Show 2 nested fields
FieldTypeRequiredDescription
mode string No one of realtime, cron, manual
cron string No —
curl -X POST "$MONICHEK_API/rules:validate" \
  -H "Authorization: Bearer $MONICHEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "key": "rule_key",
  "name": "Ada Okafor",
  "description": "Example note",
  "typology": "string",
  "trigger": {
    "events": [
      "string"
    ],
    "filter": "string"
  },
  "features": [
    {
      "name": "Ada Okafor",
      "agg": "count",
      "window": "string",
      "group_by": [
        "string"
      ],
      "where": "string",
      "field": "string"
    }
  ],
  "condition": "string",
  "suppress_if": "string",
  "groups": [
    {
      "op": "all_of",
      "conditions": [
        "string"
      ]
    }
  ],
  "outcome": {
    "severity": "low",
    "score": 0,
    "decision": "ALLOW",
    "reason_code": "string",
    "explain": "string"
  },
  "actions": [
    {}
  ],
  "params": {},
  "schedule": {
    "mode": "realtime",
    "cron": "string"
  }
}'
const res = await fetch(`${MONICHEK_API}/rules:validate`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${MONICHEK_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "key": "rule_key",
    "name": "Ada Okafor",
    "description": "Example note",
    "typology": "string",
    "trigger": {
      "events": [
        "string"
      ],
      "filter": "string"
    },
    "features": [
      {
        "name": "Ada Okafor",
        "agg": "count",
        "window": "string",
        "group_by": [
          "string"
        ],
        "where": "string",
        "field": "string"
      }
    ],
    "condition": "string",
    "suppress_if": "string",
    "groups": [
      {
        "op": "all_of",
        "conditions": [
          "string"
        ]
      }
    ],
    "outcome": {
      "severity": "low",
      "score": 0,
      "decision": "ALLOW",
      "reason_code": "string",
      "explain": "string"
    },
    "actions": [
      {}
    ],
    "params": {},
    "schedule": {
      "mode": "realtime",
      "cron": "string"
    }
  }),
});

const data = await res.json();
import os
import requests

res = requests.post(
    f"{os.environ['MONICHEK_API']}/rules:validate",
    headers={"Authorization": f"Bearer {os.environ['MONICHEK_API_KEY']}"},
    json={
      "key": "rule_key",
      "name": "Ada Okafor",
      "description": "Example note",
      "typology": "string",
      "trigger": {
        "events": [
          "string"
        ],
        "filter": "string"
      },
      "features": [
        {
          "name": "Ada Okafor",
          "agg": "count",
          "window": "string",
          "group_by": [
            "string"
          ],
          "where": "string",
          "field": "string"
        }
      ],
      "condition": "string",
      "suppress_if": "string",
      "groups": [
        {
          "op": "all_of",
          "conditions": [
            "string"
          ]
        }
      ],
      "outcome": {
        "severity": "low",
        "score": 0,
        "decision": "ALLOW",
        "reason_code": "string",
        "explain": "string"
      },
      "actions": [
        {}
      ],
      "params": {},
      "schedule": {
        "mode": "realtime",
        "cron": "string"
      }
    },
)
print(res.json())
$ch = curl_init(getenv('MONICHEK_API') . '/rules:validate');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('MONICHEK_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'key' => 'rule_key',
        'name' => 'Ada Okafor',
        'description' => 'Example note',
        'typology' => 'string',
        'trigger' => [
            'events' => [
                'string',
            ],
            'filter' => 'string',
        ],
        'features' => [
            [
                'name' => 'Ada Okafor',
                'agg' => 'count',
                'window' => 'string',
                'group_by' => [
                    'string',
                ],
                'where' => 'string',
                'field' => 'string',
            ],
        ],
        'condition' => 'string',
        'suppress_if' => 'string',
        'groups' => [
            [
                'op' => 'all_of',
                'conditions' => [
                    'string',
                ],
            ],
        ],
        'outcome' => [
            'severity' => 'low',
            'score' => 0,
            'decision' => 'ALLOW',
            'reason_code' => 'string',
            'explain' => 'string',
        ],
        'actions' => [
            [],
        ],
        'params' => [],
        'schedule' => [
            'mode' => 'realtime',
            'cron' => 'string',
        ],
    ]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

Responses

200 OK validated application/json
{
  "object": "validated"
}

Error responses

StatusMeaningBody
422 Unprocessable Entity RFC 9457 problem

Errors use the RFC 9457 problem format with a stable code.