{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://truleaf.org/fields/data-formats/1.0.0/alerts-rules.schema.json","title":"Alert rules (alerts/rules.json)","description":"The workspace's alert rule overrides (system defaults are not workspace data) and its notification defaults per category: every column, camelCase keys, ids as UUIDs, params as stored (SI units, camelCase).","type":"object","additionalProperties":false,"required":["orgId","rules","notificationDefaults"],"properties":{"orgId":{"type":"string","format":"uuid"},"rules":{"type":"array","description":"Ordered by kind, scope, farmId, parcelId, deviceId, sensorId, id.","items":{"$ref":"#/$defs/rule"}},"notificationDefaults":{"type":"array","description":"Ordered by category, id.","items":{"$ref":"#/$defs/notificationDefault"}}},"$defs":{"uuidOrNull":{"type":["string","null"],"format":"uuid"},"instant":{"type":"string","format":"date-time"},"instantOrNull":{"type":["string","null"],"format":"date-time"},"severity":{"type":"string","enum":["info","warning","critical"]},"rule":{"type":"object","additionalProperties":false,"required":["id","kind","scope","farmId","parcelId","deviceId","sensorId","enabled","severity","params","createdAt","createdBy","updatedAt","updatedBy","version"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","pattern":"^[a-z][a-z0-9_]{1,60}$"},"scope":{"type":"string","enum":["org","farm","parcel","device"]},"farmId":{"$ref":"#/$defs/uuidOrNull"},"parcelId":{"$ref":"#/$defs/uuidOrNull"},"deviceId":{"$ref":"#/$defs/uuidOrNull"},"sensorId":{"type":["integer","null"]},"enabled":{"type":["boolean","null"],"description":"null = inherited from the wider scope."},"severity":{"anyOf":[{"$ref":"#/$defs/severity"},{"type":"null"}],"description":"null = inherited from the wider scope."},"params":{"type":"object","description":"Partial override: only the keys this scope changes (SI units, camelCase)."},"createdAt":{"$ref":"#/$defs/instant"},"createdBy":{"type":"string"},"updatedAt":{"$ref":"#/$defs/instant"},"updatedBy":{"type":["string","null"]},"version":{"type":"integer","minimum":1}}},"notificationDefault":{"type":"object","additionalProperties":false,"required":["id","category","channels","minSeverity","inDigest","createdAt","updatedAt","version"],"properties":{"id":{"type":"string","format":"uuid"},"category":{"type":"string","pattern":"^[a-z][a-z_]{1,30}$"},"channels":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z_]{1,30}$"}},"minSeverity":{"$ref":"#/$defs/severity"},"inDigest":{"type":"boolean"},"createdAt":{"$ref":"#/$defs/instant"},"updatedAt":{"$ref":"#/$defs/instant"},"version":{"type":"integer","minimum":1}}}}}