StatusCake API Quick Guides – Adding an Uptime Test

At StatusCake we’ve got a powerful and ever-growing API which allows you to automate many tasks, and also to take advantage of functions that are not available in-app.

The Basics

You can communicate with our API through most common coding languages, through this article we will provide code examples in terminal bash, PHP, and Python, as well as an example of how to manually run the commands through a common tool for such tasks: PostMan.

The first thing you need to bear in mind when using the API is that all of your calls will need to be validated using the Username and API key, both of these details can be found in the user details section of your account, here for the username, and here for the API key

For the full list of settings that can be added along with your new test please check this page.

  1. Adding with PHP via a curl

When using a the PHP curl method you’ll want something very similar to the code shown below, just replace the values with your desired parameters. You can see a full list of the available parameters here.

[blockquote align=”left” reverse=”off”]
// Enter your personal API key and Username to use for authentication , and also the data to insert
$API = “l6OxVJilcD2cETMoNRvn”;
$Username = “StatusCake”;
$InsertData = array(“WebsiteName”:”My new test”, “Paused” : 0, “WebsiteURL”: “”, “CheckRate” : “60”, “TestType” : “HTTP”);
// Create the CURL, set the options, remember to use the PUT request type and add the Username and API values to an array.
$ch = curl_init(“”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($InsertData));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
“API: “.$API,
“Username: “.$Username
// For Debugging, find out if something is going wrong
$Response = curl_exec($ch);
$Response = json_decode($Response);
// Check to see if everything has worked, and print a message indicating whether this was the case
if ($Response->Success == 1) {
echo ‘Inserted Test!’;
} else {
echo ‘Something Went Wrong<BR>’;
echo $Response->Message;


  1. Adding through a terminal with bash

With this method we are looking at significantly less typing, it’s very important once again to ensure that this is always sent as a PUT request. The command should be run from a linux based system accessed through SSH or something similar.

[blockquote align=”left” reverse=”off”]

curl -H “API: APIKEY” -H “Username: USERNAME” -d “WebsiteName=MyNewSite&CheckRate=60&TestType=HTTP” -X PUT


  1. Adding with a Python script

To send a the HTTP PUT request required for this functionality with Python we need to import and use the “requests” package. 

[blockquote align=”left” reverse=”off”]

import requests
payload = {‘WebsiteName’:’MySite’, ‘TestType’:’HTTP’, ‘CheckRate’:60, ‘WebsiteURL’:’’}
headers = {‘API’: ‘KEYHERE’, ‘Username’: ‘USERNAMEHERE’}
url = ‘’
r = requests.put(url, headers=headers, data=payload)


  1. Adding using the PostMan software

Using Postman can be a good manual method, and a way of testing your settings before automating them. Below we’ve included an image showing an example of how to enter the details into the Postman software, API key and Username should be entered separately in the “Headers” section.


Share this

More from StatusCake

How To

Using Social Media for Affiliate Marketing

7 min read Today, social media uses a wide range of different social networking platforms to help its users with the creation and sharing of ideas, information, personal interests and hobbies by establishing virtual networks. Affiliates can benefit from these groups that use web-based applications to communicate, interact and connect.

How To

How to Improve User Experience

4 min read One of the biggest eCommerce questions – how do you improve user experience? Here are all the top tips for a better UX design to help you drive revenue.

Product & Updates

How Page Speed Affects SEO

2 min read We all know page speed is crucial but not just for you brand – it affects SEO so hugely that it can make your pages drop in ranking.


How to Reduce Bounce Rate

5 min read Learn what bounce rate is and how it is measured, what a good bounce rate looks like, and the actionable steps you can take to improve the bounce rate on your website.


What Causes Website Downtime?

3 min read Website downtime no longer needs to be this big mystery that keeps you up at night. Here are the top causes for website downtime AND how to fix them.


Over 40% of Online Advertisements are Too Large and Slow Down Websites

2 min read Large ads have been a major issue with online publishers who have been struggling with how to curtail what many call “fat ads.” The oversized ads have a major impact on the ability of website visitors to see them as they can’t view them if they don’t load properly.