# AWX API for Inventory Creation

**URL:** <https://forum.ansible.com/t/awx-api-for-inventory-creation/7563>\
**Category:** Get Help\
**Tags:** api, awx\
**Created:** [July 31, 2024, 9:11am UTC](https://forum.ansible.com/t/awx-api-for-inventory-creation/7563 "2024-07-31T09:11:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prateektl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/prateektl/32/8985_2.png) [@prateektl](https://forum.ansible.com/u/prateektl)\
**Post date:** [July 31, 2024, 9:11am UTC](https://forum.ansible.com/t/awx-api-for-inventory-creation/7563/1 "2024-07-31T09:11:57Z")

</div>

The AWX API, which can be used to create the inventory is missing the parameter instance group in the document. I want to assign the instance group for the inventory when its created. Using the API’s there is no option to pass this details.

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/1/1b35a2389becedd4ed8503ebb25d6e80f84945ce.png)

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [July 31, 2024, 12:22pm UTC](https://forum.ansible.com/t/awx-api-for-inventory-creation/7563/2 "2024-07-31T12:22:30Z")

</div>

Hi, try `POST` ing request to `/api/v2/inventories/{id}/instance_groups/` after initial creation of new inventory.

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/4/4cf7a6053f2e39fd7cc8469af796fc24af71c9c4.png)

---

<div class="post-metadata">

**Author:** ![prateektl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/prateektl/32/8985_2.png) [@prateektl](https://forum.ansible.com/u/prateektl)\
**Post date:** [July 31, 2024, 1:48pm UTC](https://forum.ansible.com/t/awx-api-for-inventory-creation/7563/3 "2024-07-31T13:48:27Z")

</div>

Thank you @kurokobo , i had to make the second API call as you suggested and it works.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 30, 2024, 1:48pm UTC](https://forum.ansible.com/t/awx-api-for-inventory-creation/7563/4 "2024-08-30T13:48:49Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
