API to set alerts with influxDB

Example we have a query
import “timezone”
option location = timezone.location(name: “Asia/Kolkata”)
from(bucket: “general”)
|> range(start: -24h, stop: -1s)
|> filter(fn: (r) => r[“_measurement”] == “mem”)
|> filter(fn: (r) => r[“_field”] == “device_temperature”)
|> filter(fn: (r) => r[“_value”] >= 2 and r[“_value”] <= 8)
|> group(columns: [“device_mac”])
|> aggregateWindow(every: 15m, fn: mean, createEmpty: false)

and want to send instant alert to a user via Email if any device_mac address temperature is above x or below y

How can I set this programmatically using API
php , python API