Engine API
The engine is the core evaluation service. It accepts a policy rule and data, evaluates the rule, and returns the result.
Endpoint
POST https://api.policy.keloran.dev/runRequest
| Field | Type | Required | Description |
|---|---|---|---|
rule | string | Yes | The policy rule text |
data | object | Yes | JSON data to evaluate against |
Example Request
curl -X POST https://api.policy.keloran.dev/run \ -H "Content-Type: application/json" \ -d '{ "rule": "A **Person** gets approved if __age__ of **Person** is greater than 18.", "data": { "Person": { "age": 25 } } }'Response
The engine returns a JSON object with the evaluation result:
{ "result": true, "trace": [ "Evaluating rule: A **Person** gets approved", "Checking: __age__ of **Person** is greater than 18", "Value: 25 > 18 = true", "Rule passed" ]}| Field | Type | Description |
|---|---|---|
result | boolean | Whether the policy passed (true) or failed (false) |
trace | string[] | Step-by-step evaluation trace |
error | string | Error message if the rule failed to parse |
Error Handling
If the rule text is invalid or the data is missing required fields, the engine returns an error:
{ "result": false, "error": "Parse error: unexpected token at line 1"}Common errors:
- Parse error — the rule syntax is invalid
- Missing selector — the data doesn’t contain the referenced selector
- Missing property — the data doesn’t contain the referenced property
Try It
Interactive Example
Policy Rule
Test Data (JSON)
Multi-Rule Evaluation
Send multiple rules in a single request. The engine evaluates all rules and returns the result of the last rule (the golden rule):
curl -X POST https://api.policy.keloran.dev/run \ -H "Content-Type: application/json" \ -d '{ "rule": "A **user** passes age check if __age__ of **user** is at least 18.\n\nA **user** is eligible if the **user** passes age check.", "data": { "user": { "age": 25 } } }'