Hello and thanks for posting.
Deleting attributes via the API is possible on an indirect way by object modification, in particular by overwriting values one “layer” above.
For example, the following unsets all custom variables for a host.
curl -k -s -S -i -u root:icinga -H 'Accept: application/json' -X POST \
'https://localhost:5665/v1/objects/hosts/dummy-23' \
-d '{ "attrs": { "vars": { } }, "pretty": true }'
I dumped the output of the queried object before and after. The diff looks like this:
--- host-pre.json 2025-09-04 11:24:43.987734772 +0200
+++ host-post.json 2025-09-04 11:26:24.750229903 +0200
@@ -95,7 +95,16 @@
"next_update": 1756978460.292537,
"notes": "",
"notes_url": "",
- "original_attributes": null,
+ "original_attributes": {
+ "vars": {
+ "app": "storage",
+ "department": "nms",
+ "abc": "\ud83e\udee9",
+ "env": "prod",
+ "is_dummy": true,
+ "location": "london"
+ }
+ },
"package": "_etc",
"paused": false,
"previous_state_change": 1756900736.877618,
@@ -115,15 +124,8 @@
"dummy-23"
],
"type": "Host",
- "vars": {
- "app": "storage",
- "department": "nms",
- "abc": "\ud83e\udee9",
- "env": "prod",
- "is_dummy": true,
- "location": "london"
- },
- "version": 0,
+ "vars": {},
+ "version": 1756977971.123391,
"volatile": false,
"zone": "master"
},
In Icinga DB Web, the host’s custom variables section is now empty as well.
It is also possible to overwrite all custom variables with new ones.
curl -k -s -S -i -u root:icinga -H 'Accept: application/json' -X POST \
'https://localhost:5665/v1/objects/hosts/dummy-42' \
-d '{ "attrs": { "vars": { "foo": "bar" } }, "pretty": true }'
Resulting in the host only having the foo custom var.
I have just also tried to unset a single custom variable by setting it to null, "" or {}, but all this has not resulted in removing the single variable.
Thus, I would advise you to alter the vars one level above. For example, you can first query all custom variables from the API, filter out the ones you want to delete, and update the attrs.vars then with the filtered set.