Node / JS (fetch)
import fetch from "node-fetch";
const apiKey = "ipk_xxxxxx";
async function sendAlert() {
const res = await fetch("https://your-backend.com/webhooks/incidents", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
service: "checkout",
severity: "high",
message: "Error rate exceeded 5%"
})
});
if (!res.ok) throw new Error(`Failed: ${res.status}`);
}
sendAlert();
Python (requests)
import requests
api_key = "ipk_xxxxxx"
url = "https://your-backend.com/webhooks/incidents"
payload = {
"service": "checkout",
"severity": "high",
"message": "Error rate exceeded 5%"
}
resp = requests.post(
url,
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
json=payload,
timeout=10,
)
resp.raise_for_status()
Go (net/http)
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]string{
"service": "checkout",
"severity": "high",
"message": "Error rate exceeded 5%",
})
req, _ := http.NewRequest("POST", "https://your-backend.com/webhooks/incidents", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer ipk_xxxxxx")
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)
}
PHP (cURL)
$apiKey = "ipk_xxxxxx";
$url = "https://your-backend.com/webhooks/incidents";
$payload = [
"service" => "checkout",
"severity" => "high",
"message" => "Error rate exceeded 5%",
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $apiKey",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
]);
$resp = curl_exec($ch);
curl_close($ch);
C# (HttpClient)
using var client = new HttpClient();
var req = new HttpRequestMessage(HttpMethod.Post, "https://your-backend.com/webhooks/incidents");
req.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "ipk_xxxxxx");
req.Content = new StringContent("{\"service\":\"checkout\",\"severity\":\"high\",\"message\":\"Error rate exceeded 5%\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
resp.EnsureSuccessStatusCode();
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
var client = HttpClient.newHttpClient();
var body = """
{\"service\":\"checkout\",\"severity\":\"high\",\"message\":\"Error rate exceeded 5%\"}
""";
var req = HttpRequest.newBuilder()
.uri(URI.create("https://your-backend.com/webhooks/incidents"))
.header("Authorization", "Bearer ipk_xxxxxx")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
if (resp.statusCode() >= 400) throw new RuntimeException("Failed: " + resp.statusCode());
}
}
Rust (reqwest)
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client
.post("https://your-backend.com/webhooks/incidents")
.bearer_auth("ipk_xxxxxx")
.json(&json!({
"service": "checkout",
"severity": "high",
"message": "Error rate exceeded 5%"
}))
.send()
.await?;
res.error_for_status()?;
Ok(())
}