Icinga api


Is there ny possibility in API to delete all hosts?
(I haven’t find anything about it it doc)

In fact what I want to do:

I’ve configurations files with my hosts, config, … I parse these file and generate host config with API.
But sometimes, I’ve new hosts, or I delete some hosts…, and I want to do something proper to do that.

  • Perhaps delete all my hosts at the beginning I reload my monitoring?
  • Or is there any possibility to check if host exist, update it if necessary, delete it if necessary, crete it if necessary, … without doing thousands and thousand curl on API?

Thanks for answers and ideas


Hum I can delete all hosts which have been created with API with:

curl -XDELETE https://localhost:5665/v1/objects/hosts?cascade=1 -u admin:$PASSWORD_API_ADMIN -vv -k -H ‘Accept: application/json’ -H ‘Content-Type: application/json’

So it should answer my questions.

Nevertheless, if you have any ideas to be more proper to automise actions.
For the moment, I will so:

  • delete all hosts
  • parsing my files and create hosts config

(I cant update very easy config becsause of the error:
status": "Attribute ‘zone’ could not be set: Error: Attribute cannot be modified.\n

Hi @enigma619,

this will work from the technical point of view but I guess you will loose information like the host state and history (state changes, downtimes, etc. pp).
I don’t know about how much hosts we’re talking here but this will probably create some unnecessary load as well.

I would recommend to query the /v1/objects/hosts endpoint to get a list of all hosts and work with that map in the program that’s responsible to create and manage the hosts. So the logic of hosts to be deleted, created and modified(?) will happen in your own code.

Best regards,


Thanks for answer.
Yeap it’s not the better idea.
I thought about this plan and I think I will create a file with my hosts and every hour or day I will create a new one with all hosts (with new, or delation, …) and so i will make a diff between these two files.
Then with the diff, I will add or delete the differences hosts.