Create a heartbeat
curl --request POST \
--url https://api.phare.io/uptime/heartbeats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Nightly backup",
"display_name": "Backups",
"interval": 86400,
"grace": 300,
"incident_confirmations": 1,
"recovery_confirmations": 1,
"tags": [
"environment:production"
]
}
'import requests
url = "https://api.phare.io/uptime/heartbeats"
payload = {
"name": "Nightly backup",
"display_name": "Backups",
"interval": 86400,
"grace": 300,
"incident_confirmations": 1,
"recovery_confirmations": 1,
"tags": ["environment:production"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Nightly backup',
display_name: 'Backups',
interval: 86400,
grace: 300,
incident_confirmations: 1,
recovery_confirmations: 1,
tags: ['environment:production']
})
};
fetch('https://api.phare.io/uptime/heartbeats', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phare.io/uptime/heartbeats",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Nightly backup',
'display_name' => 'Backups',
'interval' => 86400,
'grace' => 300,
'incident_confirmations' => 1,
'recovery_confirmations' => 1,
'tags' => [
'environment:production'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phare.io/uptime/heartbeats"
payload := strings.NewReader("{\n \"name\": \"Nightly backup\",\n \"display_name\": \"Backups\",\n \"interval\": 86400,\n \"grace\": 300,\n \"incident_confirmations\": 1,\n \"recovery_confirmations\": 1,\n \"tags\": [\n \"environment:production\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.phare.io/uptime/heartbeats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Nightly backup\",\n \"display_name\": \"Backups\",\n \"interval\": 86400,\n \"grace\": 300,\n \"incident_confirmations\": 1,\n \"recovery_confirmations\": 1,\n \"tags\": [\n \"environment:production\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phare.io/uptime/heartbeats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Nightly backup\",\n \"display_name\": \"Backups\",\n \"interval\": 86400,\n \"grace\": 300,\n \"incident_confirmations\": 1,\n \"recovery_confirmations\": 1,\n \"tags\": [\n \"environment:production\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"name": "Nightly backup",
"display_name": "Backups",
"interval": 86400,
"grace": 300,
"incident_confirmations": 1,
"recovery_confirmations": 1,
"id": 1,
"project_id": 1,
"status": "waiting",
"paused": false,
"ping_url": "https://beacon.phare.io/heartbeats/tVcyL8FuedAF3RzKgdXxYzznLkXIpo2364OqgVhi4a95ccf5",
"tags": [
"environment:production"
],
"last_pinged_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"message": "Unauthenticated."
}{
"message": "A scale plan is required to use this feature"
}{
"message": "The monitors:write permission is required to perform this action."
}{
"message": "<string>",
"errors": {
"key": [
"The key field is required"
]
}
}Heartbeats
Create a heartbeat
Create a heartbeat expecting a ping from a cron job or a worker at a regular interval, it opens an incident once the missed or failed pings are confirmed. The job requests its ping_url with GET, HEAD or POST when it succeeds, with /fail appended when it fails. It stays waiting without any incident until its first ping.
Requires the heartbeats:write permission.
POST
/
uptime
/
heartbeats
Create a heartbeat
curl --request POST \
--url https://api.phare.io/uptime/heartbeats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Nightly backup",
"display_name": "Backups",
"interval": 86400,
"grace": 300,
"incident_confirmations": 1,
"recovery_confirmations": 1,
"tags": [
"environment:production"
]
}
'import requests
url = "https://api.phare.io/uptime/heartbeats"
payload = {
"name": "Nightly backup",
"display_name": "Backups",
"interval": 86400,
"grace": 300,
"incident_confirmations": 1,
"recovery_confirmations": 1,
"tags": ["environment:production"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Nightly backup',
display_name: 'Backups',
interval: 86400,
grace: 300,
incident_confirmations: 1,
recovery_confirmations: 1,
tags: ['environment:production']
})
};
fetch('https://api.phare.io/uptime/heartbeats', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.phare.io/uptime/heartbeats",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Nightly backup',
'display_name' => 'Backups',
'interval' => 86400,
'grace' => 300,
'incident_confirmations' => 1,
'recovery_confirmations' => 1,
'tags' => [
'environment:production'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.phare.io/uptime/heartbeats"
payload := strings.NewReader("{\n \"name\": \"Nightly backup\",\n \"display_name\": \"Backups\",\n \"interval\": 86400,\n \"grace\": 300,\n \"incident_confirmations\": 1,\n \"recovery_confirmations\": 1,\n \"tags\": [\n \"environment:production\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.phare.io/uptime/heartbeats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Nightly backup\",\n \"display_name\": \"Backups\",\n \"interval\": 86400,\n \"grace\": 300,\n \"incident_confirmations\": 1,\n \"recovery_confirmations\": 1,\n \"tags\": [\n \"environment:production\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.phare.io/uptime/heartbeats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Nightly backup\",\n \"display_name\": \"Backups\",\n \"interval\": 86400,\n \"grace\": 300,\n \"incident_confirmations\": 1,\n \"recovery_confirmations\": 1,\n \"tags\": [\n \"environment:production\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"name": "Nightly backup",
"display_name": "Backups",
"interval": 86400,
"grace": 300,
"incident_confirmations": 1,
"recovery_confirmations": 1,
"id": 1,
"project_id": 1,
"status": "waiting",
"paused": false,
"ping_url": "https://beacon.phare.io/heartbeats/tVcyL8FuedAF3RzKgdXxYzznLkXIpo2364OqgVhi4a95ccf5",
"tags": [
"environment:production"
],
"last_pinged_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"message": "Unauthenticated."
}{
"message": "A scale plan is required to use this feature"
}{
"message": "The monitors:write permission is required to perform this action."
}{
"message": "<string>",
"errors": {
"key": [
"The key field is required"
]
}
}Authorizations
Headers
Body
application/json
Heartbeat request
Response
Success, heartbeat created
Last modified on November 25, 2026
Was this page helpful?