# How To launch a job with the Rest APIs in synchronous mode

**URL:** <https://forum.ansible.com/t/how-to-launch-a-job-with-the-rest-apis-in-synchronous-mode/27719>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [June 6, 2018, 9:29am UTC](https://forum.ansible.com/t/how-to-launch-a-job-with-the-rest-apis-in-synchronous-mode/27719 "2018-06-06T09:29:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manu](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.ansible.com/u/Manu)\
**Post date:** [June 6, 2018, 9:29am UTC](https://forum.ansible.com/t/how-to-launch-a-job-with-the-rest-apis-in-synchronous-mode/27719/1 "2018-06-06T09:29:59Z")

</div>

Hello,

I’m using the AWX APIs to launch a job from another php application. The problem is that the API launch without waiting for the completion of the task.

Is there a way to launch a job synchronously?

thanks in advance

Manu

---

<div class="post-metadata">

**Author:** ![Scott\_R\_Bowe](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@Scott\_R\_Bowe](https://forum.ansible.com/u/Scott_R_Bowe)\
**Post date:** [June 6, 2018, 10:39am UTC](https://forum.ansible.com/t/how-to-launch-a-job-with-the-rest-apis-in-synchronous-mode/27719/2 "2018-06-06T10:39:49Z")

</div>

I solve this by putting logic in my calling code to check the status of the wax job

---

<div class="post-metadata">

**Author:** ![Manu](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.ansible.com/u/Manu)\
**Post date:** [June 6, 2018, 11:19am UTC](https://forum.ansible.com/t/how-to-launch-a-job-with-the-rest-apis-in-synchronous-mode/27719/3 "2018-06-06T11:19:02Z")

</div>

Thank you for your reply.  
Indeed, I can call the API to check the status of the job until it is finished. I had already thought of this solution.

But, it would be much simpler and safer if the API could wait for the end of the job.  
There is no way to do that?

---

<div class="post-metadata">

**Author:** ![rpetrell](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rpetrell](https://forum.ansible.com/u/rpetrell)\
**Post date:** [June 6, 2018, 1:26pm UTC](https://forum.ansible.com/t/how-to-launch-a-job-with-the-rest-apis-in-synchronous-mode/27719/4 "2018-06-06T13:26:44Z")

</div>

Hey Manu,

As Scott suggested, the way to do this is to periodically poll the API for job status - other open source tools (like the Python-based tower-cli) take the same approach:

[https://github.com/ansible/tower-cli/blob/828234df230efc94f2b7abbceb3ae2309ccaf235/tower\_cli/models/base.py#L871](https://github.com/ansible/tower-cli/blob/828234df230efc94f2b7abbceb3ae2309ccaf235/tower_cli/models/base.py#L871)

We’re not _likely_ to add functionality to have the HTTP POST hang open as the job runs in the background because it could prevent the pool of HTTP worker processes from processing _other_ inbound HTTP requests (resulting in HTTP 504 errors).

---

<div class="post-metadata">

**Author:** ![Manu](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.ansible.com/u/Manu)\
**Post date:** [June 12, 2018, 2:41pm UTC](https://forum.ansible.com/t/how-to-launch-a-job-with-the-rest-apis-in-synchronous-mode/27719/5 "2018-06-12T14:41:14Z")

</div>

Hey Ryan,

Thank you for your answer, I will add a loop to control the status of the job until the end.
