Docs / API: Alert rules
Update a rule
Changes any of name, expression, url, format, cooldown_seconds and enabled. Setting enabled to true also clears the failure count.
PATCH/api/v1/rules/{id}
| Property | Value |
|---|---|
| Authentication | Required. Send Authorization: Bearer <key>. |
| Rate-limit cost | 1 unit |
| Status | Live |
#Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | Rule id. |
#Request body
JSON
{
"enabled": false
}#Request
curl -s -X PATCH "https://farbeamlabs.com/api/v1/rules/<id>" \
-H "Authorization: Bearer $FARBEAM_KEY" \
-H "content-type: application/json" \
-d '{"enabled": false}'const res = await fetch("https://farbeamlabs.com/api/v1/rules/<id>", {
method: "PATCH",
headers: { Authorization: `Bearer ${process.env.FARBEAM_KEY}`, "content-type": "application/json" },
body: JSON.stringify({"enabled": false})
});
const { data, meta, error } = await res.json();
if (error) throw new Error(`${error.code}: ${error.message}`);
console.log(data);import os, requests
res = requests.patch(
"https://farbeamlabs.com/api/v1/rules/<id>",
headers={"Authorization": f"Bearer {os.environ['FARBEAM_KEY']}"},
json={'enabled': False},
timeout=30,
)
body = res.json()
if "error" in body:
raise RuntimeError(body["error"]["code"])
print(body["data"])You can send this request now in the API playground.
#Errors
| HTTP | Code | Meaning |
|---|---|---|
| 401 | missing_key | The request has no key. |
| 404 | not_found | The item does not exist. |
| 422 | invalid_rule | The expression did not parse. The message gives the position. |
| 422 | invalid_url | The webhook URL is not a public HTTPS URL. |
All errors share one format. See errors.