Hyperjump Tech
Published in

Hyperjump Tech

Use Previous Requests’ Response as Request Body in Monika

Photo by Karine Avetisyan on Unsplash

Previously, we covered how to chain requests in Monika. In the previous article, we could only use previous requests’ responses in the subsequent request’s URL and Headers.

We’ve got some feedback from a user on our GitHub Discussion page to be able to use previous requests’ responses in the request body, not only URL and headers. So we made it, and you can use the feature in Monika 1.9.0+.

This article will show you how to do it. So, without further ado:

Let’s go!

Use Previous Requests’ Responses in Request Body

Monika is an open-source and free synthetic monitoring command-line application. Monika stands for “Monitoring Berkala”, which means “periodic monitoring” in the Indonesian language.

With Monika, you can add as many websites as you want to monitor. You can monitor several conditions such as service outages or slow services. Also, you can configure Monika to send notifications of the incidents on your services through your favorite communication tools like SMTP mail, WhatsApp (it’s free!), Microsoft Teams, Slack, and many more.

There are many ways to install Monika, from Node Package Manager (NPM), downloading binaries from the Monika release page, to package managers such as Homebrew or Snapcraft.

If we take a look at the config from the previous article:

Let me explain briefly about this configuration:

  • We are going to hit the “login” API with a JSON request body
  • After we have the token, it will hit the “get user by user ID” API using the token from the first request
  • Each request will have its own alerts and one global alert to check if hitting any of the APIs takes you more than ten seconds, then it’s probably your internet.

As you can see, you can use the previous request’s response to the next request’s headers. So how do we achieve a similar approach, but using the request body? Let’s take a look at the configuration below:

If we take a look at the configuration above:

  • The first request will create a user with the name morpheus and job leader
  • The first request will return the ID of the newly created user
  • The second request will edit the user with the ID from the previous request’s response, then will update the user with the name from the previous request’s response and job zion president
  • It will alert if the response time is longer than 500ms or the status code is larger than 204
  • It will trigger the incident and recovery notification if there is an incident or recovery at least once

Let’s run Monika with the configuration above:

Up and running!

Congratulations! You have successfully used previous requests’ responses to the next request’s body!


We personally thank the users who gave us feedback about Monika. It helps us develop Monika even better. With the functionality of using previous requests’ responses to be used in other requests, you can chain requests better than before.

If you’re having a problem with using Monika, don’t hesitate to create an issue on Monika’s Github Issue Page. If you like this article, don’t forget to clap and share this article with your friends!

That’s it for today, see you next time!

Hyperjump is an open-source-first company providing engineering excellence service. We aim to build and commercialize open-source tools to help companies streamline, simplify, and secure the most important aspects of their modern DevOps practices.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store