Checkly has some great documentation and example code as well related to this here. * I am no way shape or form affiliated with Checkly but I have found their documentation and examples extremely helpful. They have a YouTube channel as well that is very helpful.