# Rules ## List rules for a detector **get** `/api/detectors/{detectorId}/rules` List rules for a detector ### Path Parameters - `detectorId: string` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { rules }` - `rules: array of object { id, condition, detectorId, 4 more }` - `id: string` - `condition: Condition` - `LeafCondition object { leaf }` - `leaf: object { fact, op, value }` - `fact: string` - `op: "eq" or "neq" or "in" or 4 more` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: string or number or boolean or 2 more` - `string` - `number` - `boolean` - `array of string` - `array of number` - `RefCondition object { ref }` - `ref: object { fact, op, reference }` - `fact: string` - `op: "eq" or "neq" or "in" or "nin"` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: string` - `InRelationCondition object { in_relation }` - `in_relation: object { args, relation }` - `args: array of unknown` - `relation: string` - `AllCondition object { all }` - `all: array of Condition` - `AnyCondition object { any }` - `any: array of Condition` - `NotCondition object { not }` - `not: Condition` - `OnceCondition object { once }` - `once: Condition` - `HistoricallyCondition object { historically }` - `historically: Condition` - `SinceCondition object { since }` - `since: object { left, right }` - `left: Condition` - `right: Condition` - `OnceWithinCondition object { once_within }` - `once_within: object { inner, window_secs }` - `inner: Condition` - `window_secs: number` - `HistoricallyForCondition object { historically_for }` - `historically_for: object { inner, window_secs, boundary }` - `inner: Condition` - `window_secs: number` - `boundary: optional "weak" or "strong"` - `"weak"` - `"strong"` - `SinceWithinCondition object { since_within }` - `since_within: object { left, right, window_secs }` - `left: Condition` - `right: Condition` - `window_secs: number` - `KeyedCondition object { keyed }` - `keyed: object { inner, key }` - `inner: Condition` - `key: string` - `detectorId: string` - `enabled: boolean` - `name: string` - `notify: boolean` - `priority: number` - `success: boolean` ### Example ```http curl https://rake.dev/api/detectors/$DETECTOR_ID/rules \ -H "Authorization: Bearer $RAKE_API_KEY" ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "rules": [ { "id": "id", "condition": { "leaf": { "fact": "fact", "op": "eq", "value": "string" } }, "detectorId": "detectorId", "enabled": true, "name": "name", "notify": true, "priority": 0 } ] }, "success": true } ``` ## Create a new rule **post** `/api/detectors/{detectorId}/rules` Create a new rule ### Path Parameters - `detectorId: string` ### Body Parameters - `condition: string` - `name: string` - `notify: optional boolean` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { id }` - `id: string` - `success: boolean` ### Example ```http curl https://rake.dev/api/detectors/$DETECTOR_ID/rules \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $RAKE_API_KEY" \ -d '{ "condition": "condition", "name": "name" }' ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "id": "id" }, "success": true } ``` ## Update a rule **patch** `/api/detectors/{detectorId}/rules/{id}` Update a rule ### Path Parameters - `detectorId: string` - `id: string` ### Body Parameters - `condition: optional string` - `enabled: optional boolean` - `name: optional string` - `notify: optional boolean` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { id, condition, detectorId, 4 more }` - `id: string` - `condition: Condition` - `LeafCondition object { leaf }` - `leaf: object { fact, op, value }` - `fact: string` - `op: "eq" or "neq" or "in" or 4 more` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: string or number or boolean or 2 more` - `string` - `number` - `boolean` - `array of string` - `array of number` - `RefCondition object { ref }` - `ref: object { fact, op, reference }` - `fact: string` - `op: "eq" or "neq" or "in" or "nin"` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: string` - `InRelationCondition object { in_relation }` - `in_relation: object { args, relation }` - `args: array of unknown` - `relation: string` - `AllCondition object { all }` - `all: array of Condition` - `AnyCondition object { any }` - `any: array of Condition` - `NotCondition object { not }` - `not: Condition` - `OnceCondition object { once }` - `once: Condition` - `HistoricallyCondition object { historically }` - `historically: Condition` - `SinceCondition object { since }` - `since: object { left, right }` - `left: Condition` - `right: Condition` - `OnceWithinCondition object { once_within }` - `once_within: object { inner, window_secs }` - `inner: Condition` - `window_secs: number` - `HistoricallyForCondition object { historically_for }` - `historically_for: object { inner, window_secs, boundary }` - `inner: Condition` - `window_secs: number` - `boundary: optional "weak" or "strong"` - `"weak"` - `"strong"` - `SinceWithinCondition object { since_within }` - `since_within: object { left, right, window_secs }` - `left: Condition` - `right: Condition` - `window_secs: number` - `KeyedCondition object { keyed }` - `keyed: object { inner, key }` - `inner: Condition` - `key: string` - `detectorId: string` - `enabled: boolean` - `name: string` - `notify: boolean` - `priority: number` - `success: boolean` ### Example ```http curl https://rake.dev/api/detectors/$DETECTOR_ID/rules/$ID \ -X PATCH \ -H "Authorization: Bearer $RAKE_API_KEY" ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "id": "id", "condition": { "leaf": { "fact": "fact", "op": "eq", "value": "string" } }, "detectorId": "detectorId", "enabled": true, "name": "name", "notify": true, "priority": 0 }, "success": true } ``` ## Delete a rule **delete** `/api/detectors/{detectorId}/rules/{id}` Delete a rule ### Path Parameters - `detectorId: string` - `id: string` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { id }` - `id: string` - `success: boolean` ### Example ```http curl https://rake.dev/api/detectors/$DETECTOR_ID/rules/$ID \ -X DELETE \ -H "Authorization: Bearer $RAKE_API_KEY" ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message" } ], "messages": [ { "code": 1000, "message": "message" } ], "result": { "id": "id" }, "success": true } ``` ## Domain Types ### All Condition - `AllCondition object { all }` - `all: array of Condition` ### Any Condition - `AnyCondition object { any }` - `any: array of Condition` ### Condition - `Condition = LeafCondition or RefCondition or InRelationCondition or 10 more` - `LeafCondition object { leaf }` - `leaf: object { fact, op, value }` - `fact: string` - `op: "eq" or "neq" or "in" or 4 more` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: string or number or boolean or 2 more` - `string` - `number` - `boolean` - `array of string` - `array of number` - `RefCondition object { ref }` - `ref: object { fact, op, reference }` - `fact: string` - `op: "eq" or "neq" or "in" or "nin"` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: string` - `InRelationCondition object { in_relation }` - `in_relation: object { args, relation }` - `args: array of unknown` - `relation: string` - `AllCondition object { all }` - `all: array of Condition` - `AnyCondition object { any }` - `any: array of Condition` - `NotCondition object { not }` - `not: Condition` - `OnceCondition object { once }` - `once: Condition` - `HistoricallyCondition object { historically }` - `historically: Condition` - `SinceCondition object { since }` - `since: object { left, right }` - `left: Condition` - `right: Condition` - `OnceWithinCondition object { once_within }` - `once_within: object { inner, window_secs }` - `inner: Condition` - `window_secs: number` - `HistoricallyForCondition object { historically_for }` - `historically_for: object { inner, window_secs, boundary }` - `inner: Condition` - `window_secs: number` - `boundary: optional "weak" or "strong"` - `"weak"` - `"strong"` - `SinceWithinCondition object { since_within }` - `since_within: object { left, right, window_secs }` - `left: Condition` - `right: Condition` - `window_secs: number` - `KeyedCondition object { keyed }` - `keyed: object { inner, key }` - `inner: Condition` - `key: string` ### Historically Condition - `HistoricallyCondition object { historically }` - `historically: Condition` ### Historically For Condition - `HistoricallyForCondition object { historically_for }` - `historically_for: object { inner, window_secs, boundary }` - `inner: Condition` - `window_secs: number` - `boundary: optional "weak" or "strong"` - `"weak"` - `"strong"` ### In Relation Condition - `InRelationCondition object { in_relation }` - `in_relation: object { args, relation }` - `args: array of unknown` - `relation: string` ### Keyed Condition - `KeyedCondition object { keyed }` - `keyed: object { inner, key }` - `inner: Condition` - `key: string` ### Leaf Condition - `LeafCondition object { leaf }` - `leaf: object { fact, op, value }` - `fact: string` - `op: "eq" or "neq" or "in" or 4 more` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: string or number or boolean or 2 more` - `string` - `number` - `boolean` - `array of string` - `array of number` ### Not Condition - `NotCondition object { not }` - `not: Condition` ### Once Condition - `OnceCondition object { once }` - `once: Condition` ### Once Within Condition - `OnceWithinCondition object { once_within }` - `once_within: object { inner, window_secs }` - `inner: Condition` - `window_secs: number` ### Ref Condition - `RefCondition object { ref }` - `ref: object { fact, op, reference }` - `fact: string` - `op: "eq" or "neq" or "in" or "nin"` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: string` ### Since Condition - `SinceCondition object { since }` - `since: object { left, right }` - `left: Condition` - `right: Condition` ### Since Within Condition - `SinceWithinCondition object { since_within }` - `since_within: object { left, right, window_secs }` - `left: Condition` - `right: Condition` - `window_secs: number` ### Rule List Response - `RuleListResponse object { errors, messages, result, success }` - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { rules }` - `rules: array of object { id, condition, detectorId, 4 more }` - `id: string` - `condition: Condition` - `LeafCondition object { leaf }` - `leaf: object { fact, op, value }` - `fact: string` - `op: "eq" or "neq" or "in" or 4 more` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: string or number or boolean or 2 more` - `string` - `number` - `boolean` - `array of string` - `array of number` - `RefCondition object { ref }` - `ref: object { fact, op, reference }` - `fact: string` - `op: "eq" or "neq" or "in" or "nin"` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: string` - `InRelationCondition object { in_relation }` - `in_relation: object { args, relation }` - `args: array of unknown` - `relation: string` - `AllCondition object { all }` - `all: array of Condition` - `AnyCondition object { any }` - `any: array of Condition` - `NotCondition object { not }` - `not: Condition` - `OnceCondition object { once }` - `once: Condition` - `HistoricallyCondition object { historically }` - `historically: Condition` - `SinceCondition object { since }` - `since: object { left, right }` - `left: Condition` - `right: Condition` - `OnceWithinCondition object { once_within }` - `once_within: object { inner, window_secs }` - `inner: Condition` - `window_secs: number` - `HistoricallyForCondition object { historically_for }` - `historically_for: object { inner, window_secs, boundary }` - `inner: Condition` - `window_secs: number` - `boundary: optional "weak" or "strong"` - `"weak"` - `"strong"` - `SinceWithinCondition object { since_within }` - `since_within: object { left, right, window_secs }` - `left: Condition` - `right: Condition` - `window_secs: number` - `KeyedCondition object { keyed }` - `keyed: object { inner, key }` - `inner: Condition` - `key: string` - `detectorId: string` - `enabled: boolean` - `name: string` - `notify: boolean` - `priority: number` - `success: boolean` ### Rule Create Response - `RuleCreateResponse object { errors, messages, result, success }` - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { id }` - `id: string` - `success: boolean` ### Rule Update Response - `RuleUpdateResponse object { errors, messages, result, success }` - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { id, condition, detectorId, 4 more }` - `id: string` - `condition: Condition` - `LeafCondition object { leaf }` - `leaf: object { fact, op, value }` - `fact: string` - `op: "eq" or "neq" or "in" or 4 more` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `"contains"` - `"matches"` - `"between"` - `value: string or number or boolean or 2 more` - `string` - `number` - `boolean` - `array of string` - `array of number` - `RefCondition object { ref }` - `ref: object { fact, op, reference }` - `fact: string` - `op: "eq" or "neq" or "in" or "nin"` - `"eq"` - `"neq"` - `"in"` - `"nin"` - `reference: string` - `InRelationCondition object { in_relation }` - `in_relation: object { args, relation }` - `args: array of unknown` - `relation: string` - `AllCondition object { all }` - `all: array of Condition` - `AnyCondition object { any }` - `any: array of Condition` - `NotCondition object { not }` - `not: Condition` - `OnceCondition object { once }` - `once: Condition` - `HistoricallyCondition object { historically }` - `historically: Condition` - `SinceCondition object { since }` - `since: object { left, right }` - `left: Condition` - `right: Condition` - `OnceWithinCondition object { once_within }` - `once_within: object { inner, window_secs }` - `inner: Condition` - `window_secs: number` - `HistoricallyForCondition object { historically_for }` - `historically_for: object { inner, window_secs, boundary }` - `inner: Condition` - `window_secs: number` - `boundary: optional "weak" or "strong"` - `"weak"` - `"strong"` - `SinceWithinCondition object { since_within }` - `since_within: object { left, right, window_secs }` - `left: Condition` - `right: Condition` - `window_secs: number` - `KeyedCondition object { keyed }` - `keyed: object { inner, key }` - `inner: Condition` - `key: string` - `detectorId: string` - `enabled: boolean` - `name: string` - `notify: boolean` - `priority: number` - `success: boolean` ### Rule Delete Response - `RuleDeleteResponse object { errors, messages, result, success }` - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { id }` - `id: string` - `success: boolean`