Create User Group (AccesControl) using the Icinga Web 2 API

Hi Everyone.

Is it possible to create a User Group but using the icingaweb API?

If I check the request from the browser developers tool seems like is using cookies, and I’m not able to use Basic Auth (the user which I use to log to the Web UI):

This is what I want to do via API:

Thanks in advance

1 Like

For API calls (to port 5665 by default) you will need to use one of your configured API user(s). By default the root user (and usually any other API user(s) you configure) can be found in /etc/icinga2/conf.d/api-users.conf

API docs don’t seem to support creating users/groups, but if you were able to dig up the call using the dev tools, then you should be good to go.

If the call isn’t to the API listener (again, on port 5665 by default), then you probably need to try to track down the login process so that you can generate your cookie with code.

As the Icinga Web 2 API sadly is undocumented I played with curl a bit. As I am no expert, I just did trial and error^^
What worked:
curl -Sks -H 'Accept: application/json' -u user:pw -X POST -d 'group_name=test' http://host.domain/icingaweb2/group/add?backend=icingaweb2

I’m not sure what your plan with this is though. The users still have to be assigned to the groups by adding the group to each user object.
And to limit user access those group have to be assigned to a role.
Just to keep that in mind :slight_smile:

This is about the Icinga Web 2 API, not the Icinga 2 Core API :wink:

1 Like

True, this works. Thank you!!. I don’t know why it was failing with postman but I tried using curl and works.

I marked this as solution. :slight_smile: