# Inventory groups via API

**URL:** <https://forum.ansible.com/t/inventory-groups-via-api/34874>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [March 28, 2021, 5:55am UTC](https://forum.ansible.com/t/inventory-groups-via-api/34874 "2021-03-28T05:55:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Cote](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@Ian\_Cote](https://forum.ansible.com/u/Ian_Cote)\
**Post date:** [March 28, 2021, 5:55am UTC](https://forum.ansible.com/t/inventory-groups-via-api/34874/1 "2021-03-28T05:55:53Z")

</div>

Hello!

I can add groups and update the group variables via the API, but I’m not seeing how to set parent/child group relationships or add hosts to a group via the API.

awx cli doesn’t seem to have anything there either, although it used to apparently back in the tower-cli days.

My use case has a group being created for a site - “site\_foo” that will need variables, a list of hosts, and then be set as child to one group - “region\_bar” and parent to another group - “central\_stuff”.

Any help is appreciated.

Thanks,  
-ian

---

<div class="post-metadata">

**Author:** ![Wei-Yen\_Tan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/wei-yen_tan/32/4111_2.png) [@Wei-Yen\_Tan](https://forum.ansible.com/u/Wei-Yen_Tan)\
**Post date:** [March 29, 2021, 8:19pm UTC](https://forum.ansible.com/t/inventory-groups-via-api/34874/2 "2021-03-29T20:19:52Z")

</div>

I wrote a role exactly for this purpose although it is based on parent child relationship

[https://github.com/redhat-cop/tower\_configuration/blob/devel/roles/groups/tasks/main.yml](https://github.com/redhat-cop/tower_configuration/blob/devel/roles/groups/tasks/main.yml)

[https://github.com/redhat-cop/tower\_configuration/blob/devel/roles/groups/README.md](https://github.com/redhat-cop/tower_configuration/blob/devel/roles/groups/README.md)

---

<div class="post-metadata">

**Author:** ![Ian\_Cote](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@Ian\_Cote](https://forum.ansible.com/u/Ian_Cote)\
**Post date:** [March 30, 2021, 7:48pm UTC](https://forum.ansible.com/t/inventory-groups-via-api/34874/3 "2021-03-30T19:48:28Z")

</div>

Thanks - that will do perfect. Thank you!
