Passer au contenu principal
POST
/
api
/
v2
/
alerts
Créer une alerte
curl --request POST \
  --url https://api.hyperdx.io/api/v2/alerts \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "channel": {
    "type": "webhook",
    "webhookId": "65f5e4a3b9e77c001a789012"
  },
  "dashboardId": "65f5e4a3b9e77c001a567890",
  "interval": "1h",
  "message": "Error rate has exceeded 100 in the last hour",
  "name": "Error Spike Alert",
  "source": "tile",
  "threshold": 100,
  "thresholdType": "above",
  "tileId": "65f5e4a3b9e77c001a901234"
}
'
import requests

url = "https://api.hyperdx.io/api/v2/alerts"

payload = {
    "channel": {
        "type": "webhook",
        "webhookId": "65f5e4a3b9e77c001a789012"
    },
    "dashboardId": "65f5e4a3b9e77c001a567890",
    "interval": "1h",
    "message": "Error rate has exceeded 100 in the last hour",
    "name": "Error Spike Alert",
    "source": "tile",
    "threshold": 100,
    "thresholdType": "above",
    "tileId": "65f5e4a3b9e77c001a901234"
}
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({
    channel: {type: 'webhook', webhookId: '65f5e4a3b9e77c001a789012'},
    dashboardId: '65f5e4a3b9e77c001a567890',
    interval: '1h',
    message: 'Error rate has exceeded 100 in the last hour',
    name: 'Error Spike Alert',
    source: 'tile',
    threshold: 100,
    thresholdType: 'above',
    tileId: '65f5e4a3b9e77c001a901234'
  })
};

fetch('https://api.hyperdx.io/api/v2/alerts', 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.hyperdx.io/api/v2/alerts",
  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([
    'channel' => [
        'type' => 'webhook',
        'webhookId' => '65f5e4a3b9e77c001a789012'
    ],
    'dashboardId' => '65f5e4a3b9e77c001a567890',
    'interval' => '1h',
    'message' => 'Error rate has exceeded 100 in the last hour',
    'name' => 'Error Spike Alert',
    'source' => 'tile',
    'threshold' => 100,
    'thresholdType' => 'above',
    'tileId' => '65f5e4a3b9e77c001a901234'
  ]),
  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.hyperdx.io/api/v2/alerts"

	payload := strings.NewReader("{\n  \"channel\": {\n    \"type\": \"webhook\",\n    \"webhookId\": \"65f5e4a3b9e77c001a789012\"\n  },\n  \"dashboardId\": \"65f5e4a3b9e77c001a567890\",\n  \"interval\": \"1h\",\n  \"message\": \"Error rate has exceeded 100 in the last hour\",\n  \"name\": \"Error Spike Alert\",\n  \"source\": \"tile\",\n  \"threshold\": 100,\n  \"thresholdType\": \"above\",\n  \"tileId\": \"65f5e4a3b9e77c001a901234\"\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.hyperdx.io/api/v2/alerts")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"channel\": {\n    \"type\": \"webhook\",\n    \"webhookId\": \"65f5e4a3b9e77c001a789012\"\n  },\n  \"dashboardId\": \"65f5e4a3b9e77c001a567890\",\n  \"interval\": \"1h\",\n  \"message\": \"Error rate has exceeded 100 in the last hour\",\n  \"name\": \"Error Spike Alert\",\n  \"source\": \"tile\",\n  \"threshold\": 100,\n  \"thresholdType\": \"above\",\n  \"tileId\": \"65f5e4a3b9e77c001a901234\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.hyperdx.io/api/v2/alerts")

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  \"channel\": {\n    \"type\": \"webhook\",\n    \"webhookId\": \"65f5e4a3b9e77c001a789012\"\n  },\n  \"dashboardId\": \"65f5e4a3b9e77c001a567890\",\n  \"interval\": \"1h\",\n  \"message\": \"Error rate has exceeded 100 in the last hour\",\n  \"name\": \"Error Spike Alert\",\n  \"source\": \"tile\",\n  \"threshold\": 100,\n  \"thresholdType\": \"above\",\n  \"tileId\": \"65f5e4a3b9e77c001a901234\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "channel": {
      "type": "webhook",
      "webhookId": "65f5e4a3b9e77c001a789012"
    },
    "createdAt": "2023-01-01T00:00:00.000Z",
    "dashboard": "65f5e4a3b9e77c001a567890",
    "groupBy": "<string>",
    "id": "65f5e4a3b9e77c001a123456",
    "interval": "15m",
    "message": "Error rate exceeds threshold",
    "name": "High Error Rate",
    "savedSearch": "<string>",
    "silenced": true,
    "source": "tile",
    "state": "inactive",
    "team": "65f5e4a3b9e77c001a345678",
    "threshold": 100,
    "thresholdType": "above",
    "tileId": "65f5e4a3b9e77c001a901234",
    "updatedAt": "2023-01-01T00:00:00.000Z"
  }
}
{
  "message": "<string>"
}
{
  "message": "<string>"
}

Autorisations

Authorization
string
header
requis

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Corps

application/json
channel
object
requis
interval
string
requis
Exemple:

"1h"

source
enum<string>
requis
Options disponibles:
tile,
search
Exemple:

"tile"

threshold
number
requis
Exemple:

100

thresholdType
enum<string>
requis
Options disponibles:
above,
below
Exemple:

"above"

dashboardId
string
Exemple:

"65f5e4a3b9e77c001a567890"

message
string
Exemple:

"Test Alert Message"

name
string
Exemple:

"Test Alert"

tileId
string
Exemple:

"65f5e4a3b9e77c001a901234"

Réponse

Alerte créée avec succès

data
object
Dernière modification le 29 juin 2026