Login  |  Sign Up           1-866-744-6591

Website Monitoring Webhook

When a site goes down, often it is enough to just send a quick alert to the admin or host. But, there may be situations where you need more advanced alert handling.

Maybe you need to display an alert in a control panel or change to a backup DNS or integrate the alerts into your inhouse ticket system. That is where our website monitoring webhook comes in.

Available at no extra charge for all Standard and Pro users, the Webhook makes it easy to customize your alert handling.

What is a Webhook?

A webhook is a way for SiteUptime to trigger a script on your site when an event occurs, such as a site monitor failing.

All we need is the URL for your script. Then, when a site monitor fails, the SiteUptime system will send JSON data to the URL you provide.

Sample Alert JSON Data:

    "MonitorId": "1234",
    "MonitorName": "Main server",
    "Host_Url": "domain.com",
    "Service": "http",
    "Date": "2014-07-25 10:24:01",
    "Result": "Failed",
    "Error": "Connection timed out"

What do I do with the data?

Once you have the data from the monitor, you can do just about anything:

  • Log the data
  • Send an email to your webhost with your account info
  • Display messages or send alerts to your users
  • Switch to a backup server
  • Trigger events in 3rd party notification systems, CRM's, etc.

Using the Webhook:

Creating Your Script

First, you need a file on your site that will process the results. Once you create the file, upload it to your site. The URL for this file is where our system will send the data.

Below is a sample PHP script that that writes to a log and sends an email for DOWN alerts.

if (get_magic_quotes_gpc()) {
$AlertInfo = stripslashes($_GET['AlertInfo']);
else {
$AlertInfo = $_GET['AlertInfo'];
} if(strlen($AlertInfo)) { $AlertInfo = @json_decode($AlertInfo, true); if(is_array($AlertInfo)) { //Process alert if($AlertInfo['Result']=='Failed') { //Process DOWN alert @mail('admin@somesite.com', $AlertInfo['MonitorName'].' is DOWN', $_GET['AlertInfo']); @file_put_contents('logs/siteuptime-alerts.log', $AlertInfo['Date'].':'.$AlertInfo['MonitorName']." is DOWN\n",FILE_APPEND); } else { //Process UP alert @file_put_contents('logs/siteuptime-alerts.log', $AlertInfo['Date'].':'.$AlertInfo['MonitorName']." is OK\n",FILE_APPEND); } } }

Entering Your Webhook URL

Next, you have to tell the SiteUptime system where to send the data.

1) Log into your dashboard - or - Register for a new account.

2) Upgrade to a Standard or Pro plan if you haven't already. (view plans)

3) Click on "My Profile" on the side, enter your callback URL into the "Webhook URL" field, and save the form.

4) Click on "My Monitors" on the side, click the link to add a new monitor or the link to edit an exiting one. Click the "Advanced" button to view more options, check the box to "Send Alert To Webhook URL", and save the form.


Using our API

If you're using our SiteUptime API, simply specify SendUrlAlert=1 and set the CustomUrlAlert variable to your webhook endpoint when creating or editing a monitor.


Slack Integration

Slack is a popular team communication, messaging and search platform that integrates smoothly with the SiteUptime monitors.

Follow the steps below to send your SiteUptime alerts to Slack.

1) Log into your Slack control panel.

2) Select one of your #channels.

3) Click "+ Add a service integration" link.

4) Select "Incoming WebHooks" in the list.

5) Click "Add Incoming WebHooks Integration" button and copy the webhook URL.

6) Log into your SiteUptime account, click on "My Settings" on the side and select "Edit Account Settings".

7) Paste the Slack webhook URL into the "Webhook URL" field and click the "Update" button to save it.

8) To enable the web hook for a monitor, go to "My Monitors" and add or edit a monitor.

9) Click the "Advanced" button, scroll down to the "Send Alert To Webhook URL", check the box to enable the webhook feature, and save your changes.



Slashes in the JSON Data

If quotes are appearing as \" in your data, it may be because you have MagicQuotes turned on in your PHP config. Not a problem...Just use stripslashes() to remove the slash as we did in the first line of our PHP example code:

if (get_magic_quotes_gpc()) {
$AlertInfo = stripslashes($_GET['AlertInfo']);
else {
$AlertInfo = $_GET['AlertInfo'];

Testing Your Webhook

If you'd like to test the webhook functionality, or verify that your webhooks are being sent, we recommend using a service like RequestBin: https://requestbin.com

Just go to the site, click the "Create a RequestBin" button, then copy the URL from the big text box at the top of the page.

Then, in your SiteUptime control panel, specify the URL you copied as your webhook URL and send a test alert for one of your monitors (on the add/edit monitor page).

Once you refresh the RequestBin page (the one where you copied the URL from the big text box), you'll see the raw JSON data as well as details about the webhook. These details should give you an idea of how you'll need to prepare your endpoint to listen for the SiteUptime webhook.

After you've finished your testing, just remove the RequestBin URL from your SiteUptime control panel, and replace it with your application's webhook receiver.

Privacy Policy   |  Contact Us  |  Terms of Use Copyright 2003-2022 SiteUptime