# Is it possible to make a synchroniuos HTTP call from Synthetic monitor javascript execution step?

**URL:** <https://community.dynatrace.com/t/is-it-possible-to-make-a-synchroniuos-http-call-from-synthetic-monitor-javascript-execution-step/54525>\
**Category:** Synthetic Monitoring\
**Tags:** synthetic-monitoring\
**Created:** [January 4, 2026, 7:30pm UTC](https://community.dynatrace.com/t/is-it-possible-to-make-a-synchroniuos-http-call-from-synthetic-monitor-javascript-execution-step/54525 "2026-01-04T19:30:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deni](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/deni/32/163_2.png) [@deni](https://community.dynatrace.com/u/deni)\
**Post date:** [January 4, 2026, 7:30pm UTC](https://community.dynatrace.com/t/is-it-possible-to-make-a-synchroniuos-http-call-from-synthetic-monitor-javascript-execution-step/54525/1 "2026-01-04T19:30:49Z")

</div>

Hi,

This is a follow-up to my earlier post:  
[https://community.dynatrace.com/t5/Synthetic-Monitoring/Synthetic-monitor-counting-api-fail-by-message-amp-custom-error/td-p/292309](https://community.dynatrace.com/topic/292309)

Could someone please confirm whether it is **possible or not possible to make a synchronous HTTP call** from a **Synthetic Monitor JavaScript execution step**?  
If it _is not possible_, could you please point me to the **official documentation** where this behavior is described?

Thanks!

Regards, Deni

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [January 4, 2026, 7:54pm UTC](https://community.dynatrace.com/t/is-it-possible-to-make-a-synchroniuos-http-call-from-synthetic-monitor-javascript-execution-step/54525/2 "2026-01-04T19:54:24Z")

</div>

[@deni](https://community.dynatrace.com/user/90225)&nbsp; , for HTTP synthetic tests, this is not possible, see this:&nbsp;[Pre- and post-execution scripts for HTTP monitors in Classic — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/http-monitor-pre-post-script#define-pre-and-post-execution-scripts)

> Pre- and post-execution scripts have direct access only to the data retrieved as the result of the current request. In other words, the response details are available only within the same request’s post-execution script. To pass the information to a different request within the same monitor, use a&nbsp;[variable](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/http-monitors-classic/pre-and-post-scripting-for-http-monitors-classic#variables)&nbsp;instead.

For Browser synthetic tests, this is certainly possible, for example, this one taken from the [docs](https://docs.dynatrace.com/docs/shortlink/id-brower-clickpath-events#examples):

```javascript
api.startAsyncSyntheticEvent();
fetch('https://randomuser.me/api/').then((resp) => resp.json()).then(function(data) {
    document.getElementById('firstName').value = data.results[0].name.first;
    document.getElementById('lastName').value = data.results[0].name.lastname;
    api.finish();
}).catch(function(error) {
    api.fail('Fetch request to randomuser.me failed');
});

```

Here you need to call&nbsp;api.startAsyncSyntheticEvent() so that the synthetic engine waits for api.fail() or api.finish() call. See [docs](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/browser-clickpath-events#mark-events-as-failed-or-finished).

---

<div class="post-metadata">

**Author:** ![deni](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/deni/32/163_2.png) [@deni](https://community.dynatrace.com/u/deni)\
**Post date:** [January 5, 2026, 8:32am UTC](https://community.dynatrace.com/t/is-it-possible-to-make-a-synchroniuos-http-call-from-synthetic-monitor-javascript-execution-step/54525/3 "2026-01-05T08:32:16Z")

</div>

Thanks&nbsp;[@Julius\_Loman](https://community.dynatrace.com/user/3364)

My question was related **only to Browser Synthetic Monitors**.

The issue was caused by an incorrect placement of **api.startAsyncSyntheticEvent()**.

In my original script, I had synchronous logic and an early return before calling **api.startAsyncSyntheticEvent()**:

```markup
// Some synchronous code
var text = document.documentElement.innerText || '';
var someCheck = ...;

if (!someCheck) {
    return;
}

api.startAsyncSyntheticEvent(); // ❌ too late

fetch(...)
    .then(function(res) {
        if (!res.ok) {
            api.fail("FAIL_1");
            return;
        }
        api.fail("FAIL_2");
    })
    .catch(function(err) {
        api.fail("FAIL_3");
    });

```

Because **api.startAsyncSyntheticEvent()** was not called at the beginning of the JavaScript execution step, the Synthetic engine treated the step as synchronous and immediately moved on to the next step.  
As a result, the **asynchronous fetch() completed after the step had already finished**, and **api.fail()** was **ignored** , which made it look like synchronous execution was not supported.

Once I moved **api.startAsyncSyntheticEvent()** to the very beginning of the JavaScript execution step and ensured that all execution paths end with either **api.finish()** or **api.fail()**, the monitor behaved as expected and failed on the JavaScript step with the correct failure message.

```markup
api.startAsyncSyntheticEvent();

// logic ...

fetch(...)
    .then(...)
    .catch(...);

```

So async HTTP calls are fully supported in Browser Synthetic Monitors, as long as **api.startAsyncSyntheticEvent()** is invoked before any possible return path.
