List Alerts
curl -X GET "https://api.example.com/alerts/?workspace_id=workspace123&type=critical" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"message" : "Alerts retrieved successfully" ,
"alerts" : [
{
"id" : "alert123" ,
"title" : "High pH Alert" ,
"type" : "critical" ,
"workspace_id" : "workspace123" ,
"meter_id" : "meter123" ,
"owner" : "user123" ,
"parameters" : {
"ph" : {
"min" : 6.0 ,
"max" : 8.5
}
},
"guests" : [ "[email protected] " ]
}
]
}
Retrieve alerts with optional filters.
Endpoint: GET /alerts/
Authentication: Required (Bearer token)
Query Parameters
Filter by alert type: critical or warning
Response
Get Alert by ID
curl -X GET https://api.example.com/alerts/alert123/ \
-H "Authorization: Bearer YOUR_TOKEN"
{
"message" : "Alert retrieved successfully" ,
"alert" : {
"id" : "alert123" ,
"title" : "High pH Alert" ,
"type" : "critical" ,
"workspace_id" : "workspace123" ,
"meter_id" : "meter123" ,
"owner" : "user123" ,
"parameters" : {
"ph" : {
"min" : 6.0 ,
"max" : 8.5
}
},
"guests" : [ "[email protected] " ]
}
}
Retrieve a specific alert by ID.
Endpoint: GET /alerts/{id}/
Authentication: Required (Bearer token)
Path Parameters
Create Alert
curl -X POST https://api.example.com/alerts/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Temperature Warning",
"type": "warning",
"workspace_id": "workspace123",
"meter_id": "meter123",
"parameters": {
"temperature": {
"min": 10.0,
"max": 30.0
}
},
"guests": ["[email protected] ", "[email protected] "]
}'
{
"message" : "Alert created successfully" ,
"alert" : {
"id" : "alert456" ,
"title" : "Temperature Warning" ,
"type" : "warning" ,
"workspace_id" : "workspace123" ,
"meter_id" : "meter123" ,
"owner" : "user123" ,
"parameters" : {
"temperature" : {
"min" : 10.0 ,
"max" : 30.0
}
},
"guests" : [ "[email protected] " , "[email protected] " ]
}
}
Create a new alert for a meter.
Endpoint: POST /alerts/
Authentication: Required (Bearer token)
Request Body
Alert type: critical or warning
Alert threshold parameters (sensor min/max values) {
"ph" : { "min" : 6.0 , "max" : 8.5 },
"temperature" : { "min" : 10.0 , "max" : 30.0 },
"conductivity" : { "min" : 100 , "max" : 1000 },
"tds" : { "min" : 50 , "max" : 500 },
"turbidity" : { "min" : 0 , "max" : 5 }
}
Array of email addresses to notify when alert is triggered
Update Alert
curl -X PUT https://api.example.com/alerts/alert123/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Updated pH Alert",
"type": "warning",
"parameters": {
"ph": {
"min": 6.5,
"max": 8.0
}
},
"guests": ["[email protected] "]
}'
{
"message" : "Alert updated successfully" ,
"alert" : {
"id" : "alert123" ,
"title" : "Updated pH Alert" ,
"type" : "warning" ,
"workspace_id" : "workspace123" ,
"meter_id" : "meter123" ,
"owner" : "user123" ,
"parameters" : {
"ph" : {
"min" : 6.5 ,
"max" : 8.0
}
},
"guests" : [ "[email protected] " ]
}
}
Update an existing alert.
Endpoint: PUT /alerts/{id}/
Authentication: Required (Bearer token)
Path Parameters
Request Body
Alert type: critical or warning
Updated threshold parameters
Updated list of email addresses to notify
Delete Alert
curl -X DELETE https://api.example.com/alerts/alert123/ \
-H "Authorization: Bearer YOUR_TOKEN"
{
"message" : "Alert deleted successfully" ,
"alert" : {
"id" : "alert123" ,
"title" : "High pH Alert"
}
}
Delete an alert.
Endpoint: DELETE /alerts/{id}/
Authentication: Required (Bearer token)
Path Parameters
List Notifications
curl -X GET "https://api.example.com/alerts/notifications/?type=critical&is_read=false&status=pending" \
-H "Authorization: Bearer YOUR_TOKEN"
{
"message" : "Notifications retrieved successfully" ,
"notifications" : [
{
"id" : "notif123" ,
"alert_id" : "alert123" ,
"type" : "critical" ,
"is_read" : false ,
"status" : "pending" ,
"timestamp" : "2024-01-15T10:30:00Z" ,
"record_parameters" : [
{
"sensor" : "ph" ,
"value" : 9.2
}
],
"user_ids" : [ "[email protected] " ]
}
]
}
Retrieve alert notifications for the authenticated user.
Endpoint: GET /alerts/notifications/
Authentication: Required (Bearer token)
Query Parameters
Filter by notification type: critical or warning
Filter by status: pending, accepted, or rejected
Convert timestamps to readable format
Get Notification by ID
curl -X GET https://api.example.com/alerts/notifications/notif123/ \
-H "Authorization: Bearer YOUR_TOKEN"
{
"message" : "Notification retrieved successfully" ,
"notification" : {
"id" : "notif123" ,
"alert_id" : "alert123" ,
"type" : "critical" ,
"is_read" : false ,
"status" : "pending" ,
"timestamp" : "January 15, 2024 10:30 AM" ,
"record_parameters" : [
{
"sensor" : "ph" ,
"value" : 9.2
}
],
"user_ids" : [ "[email protected] " ]
}
}
Get a specific notification by ID.
Endpoint: GET /alerts/notifications/{notification_id}/
Authentication: Required (Bearer token)
Path Parameters
Mark Notification as Read
curl -X PUT https://api.example.com/alerts/notifications/notif123/ \
-H "Authorization: Bearer YOUR_TOKEN"
{
"message" : "Notification marked as read" ,
"notification" : {
"id" : "notif123" ,
"is_read" : true
}
}
Mark a notification as read.
Endpoint: PUT /alerts/notifications/{notification_id}/
Authentication: Required (Bearer token)
Path Parameters
Update Notification Status
curl -X PUT https://api.example.com/alerts/notifications/status/notif123/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"status": "accepted"
}'
{
"message" : "Notification status updated"
}
Update notification status (accept or reject). For critical alerts with status accepted, email notifications will be sent to all guests.
Endpoint: PUT /alerts/notifications/status/{notification_id}/
Authentication: Required (Bearer token)
Path Parameters
Request Body
New status: accepted or rejected (cannot be pending)
Response