Skip to main content

List Alert Rules

Retrieve all alert rules for a bucket.

Endpoint

GET /api/buckets/:bucketId/alerts

Authentication

Key TypeAllowed
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

HeaderTypeRequiredDescription
X-API-Keystring✅ YesYour API key (Admin, Write, or Read)

Path Parameters

ParameterTypeRequiredDescription
bucketIdstring✅ YesThe 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

FieldTypeDescription
_idstringUnique alert rule identifier
namestringAlert rule name
conditionstringNatural language condition
dataSourceIdstringData source this alert monitors
webhookUrlstringURL to receive alert notifications
statusstringStatus: active or paused
cooldownMinutesnumberMinimum minutes between alerts
lastTriggeredAtstringLast trigger timestamp (ISO 8601)
createdAtstringCreation timestamp (ISO 8601)