curl --request POST \
--url https://app.blockgence.com/v1/guard/webhooks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"url": "<string>",
"scope": "mine",
"watch_id": 123,
"min_severity": "high",
"description": ""
}
'import requests
url = "https://app.blockgence.com/v1/guard/webhooks"
payload = {
"url": "<string>",
"scope": "mine",
"watch_id": 123,
"min_severity": "high",
"description": ""
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
scope: 'mine',
watch_id: 123,
min_severity: 'high',
description: ''
})
};
fetch('https://app.blockgence.com/v1/guard/webhooks', 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://app.blockgence.com/v1/guard/webhooks",
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([
'url' => '<string>',
'scope' => 'mine',
'watch_id' => 123,
'min_severity' => 'high',
'description' => ''
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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://app.blockgence.com/v1/guard/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"scope\": \"mine\",\n \"watch_id\": 123,\n \"min_severity\": \"high\",\n \"description\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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://app.blockgence.com/v1/guard/webhooks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"scope\": \"mine\",\n \"watch_id\": 123,\n \"min_severity\": \"high\",\n \"description\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.blockgence.com/v1/guard/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"scope\": \"mine\",\n \"watch_id\": 123,\n \"min_severity\": \"high\",\n \"description\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"detail": "<string>",
"error": "<string>"
}{
"detail": "<string>",
"error": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"detail": "<string>",
"error": "<string>"
}Crear un webhook
Crea un webhook firmado que recibe las alertas de Guard por POST con un cuerpo JSON.
Cuerpo del pedido: {"url": "https://…", "scope": "mine", "watch_id": null, "min_severity": "high", "description": "…"}.
scope: qué alertas recibe.mine(valor por defecto): las de las vigilancias de las que quien lo crea es dueño.org: las de las vigilancias compartidas de la organización, no las privadas de cada persona. Lo crea un administrador de la organización, y deja de recibir si esa persona ya no está activa en ella.watch: las de una vigilancia y sus derivadas, indicada enwatch_id. Lo crea quien puede editar esa vigilancia.min_severity: la severidad mínima que se avisa (low,medium,highocritical); por defecto,high.url:https, en el puerto 443, sin usuario ni contraseña y con un host que resuelva a direcciones IP públicas. Se valida al crear el webhook y en cada envío.
Hasta 10 webhooks por organización.
Responde el webhook con el secret completo una sola vez (secret_shown_once: true). Después, el secreto se
muestra enmascarado.
Mensajes. Se envía un POST por alerta y por evento. type es guard.alert.created (alerta nueva),
guard.alert.retracted (una reorganización de la cadena sacó la transacción), guard.alert.revived (la
transacción volvió a entrar), guard.alert.updated (una persona cambió la alerta) o guard.test. El cuerpo
incluye type, timestamp, api_version y data, con alert (el mismo facts que
GET /v1/guard/alerts/{aid} y status al momento del envío), watch y webhook. guard.alert.updated agrega
data.change, con quién hizo el cambio y qué campos cambió; de un comentario indica solo que se agregó. El
cuerpo no incluye correos ni nombres de personas.
Firma (Standard Webhooks). Cada mensaje trae tres encabezados:
webhook-id: el id del mensaje. Es el mismo en cada reintento; úselo para no procesar un mensaje dos veces.webhook-timestamp: el momento del envío, en segundos unix.webhook-signature:v1,<base64>, el HMAC-SHA256 de"{webhook-id}.{webhook-timestamp}.{cuerpo}". La clave son los bytes en base64 que siguen awhsec_en el secreto.
Para verificar un mensaje: calcule la firma sobre el cuerpo crudo, antes de interpretar el JSON; compárela en
tiempo constante con cada v1,… del encabezado; rechace un webhook-timestamp con más de 5 minutos de
diferencia, y descarte un webhook-id ya procesado. Las bibliotecas de Standard Webhooks hacen esta verificación
con el mismo secreto.
Entrega. Cuenta como entregada cualquier respuesta 2xx. Ante otra respuesta o sin respuesta, se reintenta
a los 30 s, 2 min, 10 min, 30 min, 1 h, 2 h, 4 h y 8 h (unas 15 horas en total), con el mismo webhook-id; luego
la entrega queda failed. Un aviso que no se pudo enviar en 3 días vence (expired). El orden se respeta dentro
de una misma alerta, pero no entre alertas distintas: use data.alert.id y timestamp. Una respuesta
410 Gone o 30 fallas seguidas desactivan el webhook. No se siguen redirecciones.
Errores:
400: URL inválida o no pública, alcance o severidad inválidos,scope: "watch"sinwatch_id, owatch_idcon otro alcance.403: alcanceorgsin ser administrador de la organización, una vigilancia que quien consulta no puede editar, el límite de webhooks alcanzado, o una clave de API no asignada a una persona.404: una vigilancia que quien consulta no ve.422: el cuerpo del pedido trae un campo desconocido.
Costo: sin cargo.
curl --request POST \
--url https://app.blockgence.com/v1/guard/webhooks \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"url": "<string>",
"scope": "mine",
"watch_id": 123,
"min_severity": "high",
"description": ""
}
'import requests
url = "https://app.blockgence.com/v1/guard/webhooks"
payload = {
"url": "<string>",
"scope": "mine",
"watch_id": 123,
"min_severity": "high",
"description": ""
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: '<string>',
scope: 'mine',
watch_id: 123,
min_severity: 'high',
description: ''
})
};
fetch('https://app.blockgence.com/v1/guard/webhooks', 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://app.blockgence.com/v1/guard/webhooks",
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([
'url' => '<string>',
'scope' => 'mine',
'watch_id' => 123,
'min_severity' => 'high',
'description' => ''
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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://app.blockgence.com/v1/guard/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"scope\": \"mine\",\n \"watch_id\": 123,\n \"min_severity\": \"high\",\n \"description\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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://app.blockgence.com/v1/guard/webhooks")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"scope\": \"mine\",\n \"watch_id\": 123,\n \"min_severity\": \"high\",\n \"description\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.blockgence.com/v1/guard/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"scope\": \"mine\",\n \"watch_id\": 123,\n \"min_severity\": \"high\",\n \"description\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"detail": "<string>",
"error": "<string>"
}{
"detail": "<string>",
"error": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"detail": "<string>",
"error": "<string>"
}Autorizaciones
Encabezados
Cuerpo
Respuesta
Respuesta correcta.