Skip to main content

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

workspace_id
string
Filter by workspace ID
meter_id
string
Filter by meter ID
type
string
Filter by alert type: critical or warning

Response

message
string
Success message
alerts
array
Array of alert objects

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

id
string
required
Alert ID

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

title
string
required
Alert title
type
string
required
Alert type: critical or warning
workspace_id
string
required
Workspace ID
meter_id
string
required
Meter ID to monitor
parameters
object
required
Alert threshold parameters (sensor min/max values)
guests
array
required
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

id
string
required
Alert ID

Request Body

title
string
required
Updated alert title
type
string
required
Alert type: critical or warning
parameters
object
Updated threshold parameters
guests
array
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

id
string
required
Alert ID to delete

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

type
string
Filter by notification type: critical or warning
is_read
boolean
Filter by read status
status
string
default:"pending"
Filter by status: pending, accepted, or rejected
convert_timestamp
boolean
default:"false"
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

notification_id
string
required
Notification ID

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

notification_id
string
required
Notification ID

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

notification_id
string
required
Notification ID

Request Body

status
string
required
New status: accepted or rejected (cannot be pending)

Response

message
string
Success message

Build docs developers (and LLMs) love