List Alert Rules
Retrieve all alert rules for a bucket.
Endpoint
GET /api/buckets/:bucketId/alerts
Authentication
| Key Type | Allowed |
|---|---|
Admin (dakkio_a_) | ✅ Yes |
Write (dakkio_w_) | ✅ Yes |
Read (dakkio_r_) | ✅ Yes |
All key types can list alert rules for their respective bucket.
Request
Headers
| Header | Type | Required | Description |
|---|---|---|---|
X-API-Key | string | ✅ Yes | Your API key (Admin, Write, or Read) |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bucketId | string | ✅ Yes | The bucket ID (24-character hex string) |
Example Request
curl -X GET "https://api.dakkio.io/api/buckets/507f1f77bcf86cd799439011/alerts" \
-H "X-API-Key: dakkio_r_your_read_key..."
Response
Success Response (200 OK)
{
"alertRules": [
{
"_id": "507f1f77bcf86cd799439017",
"name": "High Temperature Alert",
"condition": "temperature is greater than 30",
"dataSourceId": "507f1f77bcf86cd799439015",
"webhookUrl": "https://hooks.slack.com/services/...",
"status": "active",
"cooldownMinutes": 5,
"lastTriggeredAt": "2024-01-15T14:30:00Z",
"createdAt": "2024-01-15T10:35:00Z"
},
{
"_id": "507f1f77bcf86cd799439018",
"name": "Low Humidity Warning",
"condition": "humidity is less than 30",
"dataSourceId": "507f1f77bcf86cd799439015",
"webhookUrl": "https://api.example.com/alerts",
"status": "active",
"cooldownMinutes": 15,
"lastTriggeredAt": null,
"createdAt": "2024-01-15T10:40:00Z"
}
]
}
Empty Response (200 OK)
{
"alertRules": []
}
Error Responses
401 Unauthorized
{
"error": "Unauthorized",
"message": "Invalid or missing API key"
}
403 Forbidden
{
"error": "Forbidden",
"message": "API key does not have access to this bucket"
}
404 Not Found
{
"error": "Not Found",
"message": "Bucket not found"
}
Code Examples
JavaScript/Node.js
const axios = require('axios');
async function listAlertRules(bucketId) {
const response = await axios.get(
`https://api.dakkio.io/api/buckets/${bucketId}/alerts`,
{
headers: {
'X-API-Key': process.env.DAKKIO_READ_KEY
}
}
);
return response.data.alertRules;
}
// List all alert rules
const alerts = await listAlertRules('507f1f77bcf86cd799439011');
console.log(`Found ${alerts.length} alert rules:`);
alerts.forEach(alert => {
console.log(`- ${alert.name}: "${alert.condition}" (${alert.status})`);
});
Python
import requests
import os
def list_alert_rules(bucket_id):
response = requests.get(
f'https://api.dakkio.io/api/buckets/{bucket_id}/alerts',
headers={
'X-API-Key': os.environ['DAKKIO_READ_KEY']
}
)
if response.status_code == 200:
return response.json()['alertRules']
else:
print('Error:', response.json())
return []
# List all alert rules
alerts = list_alert_rules('507f1f77bcf86cd799439011')
for alert in alerts:
print(f"- {alert['name']}: \"{alert['condition']}\" ({alert['status']})")
Response Fields
| Field | Type | Description |
|---|---|---|
_id | string | Unique alert rule identifier |
name | string | Alert rule name |
condition | string | Natural language condition |
dataSourceId | string | Data source this alert monitors |
webhookUrl | string | URL to receive alert notifications |
status | string | Status: active or paused |
cooldownMinutes | number | Minimum minutes between alerts |
lastTriggeredAt | string | Last trigger timestamp (ISO 8601) |
createdAt | string | Creation timestamp (ISO 8601) |
Related Endpoints
- Create Alert Rule - Create a new alert rule