Entrega
Añade un endpoint en la consola (Integrations → Webhook). Recibes el secreto una sola vez; guárdalo donde guardes otras credenciales. Las entregas son peticiones POST con cuerpo JSON y tres cabeceras:
POST https://your-server.example/prynt
X-Prynt-Event: reveal.company_identified
X-Prynt-Timestamp: 1762164000
X-Prynt-Signature: sha256=3f2a…9c
Content-Type: application/json
{"type":"reveal.company_identified","data":{…},"createdAt":"2026-11-03T10:00:00Z"}| Cabecera | Significado |
|---|---|
X-Prynt-Event | El tipo de evento: reveal.company_identified, reveal.hot_lead, reveal.person_verified, reveal.session_ended (llegan más con los segmentos; el selector de eventos de la consola es la referencia) |
X-Prynt-Timestamp | Segundos Unix en que se firmó la entrega — rechaza si difiere más de 5 minutos de tu reloj |
X-Prynt-Signature | sha256= + HMAC-SHA256 en hex con tu secreto sobre <timestamp>.<cuerpo en bruto> |
Cuerpo: { "type": "<evento>", "data": { … }, "createdAt": "<ISO 8601>" }. Responde con cualquier 2xx sin demora; una respuesta no 2xx o un timeout se reintenta hasta 3 intentos en total. Cada entrega se ve en la consola con sus intentos, código de estado y una copia enmascarada del payload, y puede repetirse.
Verificar la firma
Calcula HMAC_SHA256(secreto, timestamp + "." + cuerpo_en_bruto) y compáralo en tiempo constante con la cabecera. Usa siempre los bytes **en bruto** de la petición: reserializar el JSON cambia espacios y orden de claves y rompe la firma.
Python (Flask)
import hmac, hashlib, time
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["PRYNT_WEBHOOK_SECRET"] # the endpoint's secret shown once in the console
@app.post("/prynt")
def prynt_webhook():
ts = request.headers.get("X-Prynt-Timestamp", "")
sig = request.headers.get("X-Prynt-Signature", "")
body = request.get_data() # raw bytes — never re-serialise the JSON
if not ts.isdigit() or abs(time.time() - int(ts)) > 300:
abort(400) # replay window: 5 minutes
expected = "sha256=" + hmac.new(SECRET.encode(), f"{ts}.".encode() + body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, sig):
abort(401)
event = request.get_json()
# event["type"], event["data"], event["createdAt"]
return "", 204Node (Express)
import { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';
const app = express();
const SECRET = process.env.PRYNT_WEBHOOK_SECRET;
// Keep the raw body: the signature covers the bytes Prynt sent, not a re-serialised object.
app.post('/prynt', express.raw({ type: '*/*' }), (req, res) => {
const ts = String(req.get('X-Prynt-Timestamp') || '');
const sig = String(req.get('X-Prynt-Signature') || '');
if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return res.sendStatus(400);
const expected = 'sha256=' + createHmac('sha256', SECRET).update(ts + '.').update(req.body).digest('hex');
const a = Buffer.from(expected), b = Buffer.from(sig);
if (a.length !== b.length || !timingSafeEqual(a, b)) return res.sendStatus(401);
const event = JSON.parse(req.body.toString('utf8'));
// event.type, event.data, event.createdAt
res.sendStatus(204);
});PHP
<?php
$secret = getenv('PRYNT_WEBHOOK_SECRET');
$ts = $_SERVER['HTTP_X_PRYNT_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_PRYNT_SIGNATURE'] ?? '';
$body = file_get_contents('php://input'); // raw body
if (!ctype_digit($ts) || abs(time() - (int) $ts) > 300) { http_response_code(400); exit; }
$expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, $secret);
if (!hash_equals($expected, $sig)) { http_response_code(401); exit; }
$event = json_decode($body, true);
// $event['type'], $event['data'], $event['createdAt']
http_response_code(204);Go
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"io"
"math"
"net/http"
"os"
"strconv"
"time"
)
func pryntWebhook(w http.ResponseWriter, r *http.Request) {
secret := os.Getenv("PRYNT_WEBHOOK_SECRET")
ts, sig := r.Header.Get("X-Prynt-Timestamp"), r.Header.Get("X-Prynt-Signature")
body, _ := io.ReadAll(r.Body)
t, err := strconv.ParseInt(ts, 10, 64)
if err != nil || math.Abs(float64(time.Now().Unix()-t)) > 300 {
http.Error(w, "stale", http.StatusBadRequest)
return
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(ts + "."))
mac.Write(body)
expected := "sha256=" + hex.EncodeToString(mac.Sum(nil))
if !hmac.Equal([]byte(expected), []byte(sig)) {
http.Error(w, "bad signature", http.StatusUnauthorized)
return
}
// json.Unmarshal(body, &event) → event.Type, event.Data, event.CreatedAt
w.WriteHeader(http.StatusNoContent)
}Ruby (Sinatra)
require 'openssl'
require 'json'
post '/prynt' do # Sinatra; Rails: request.raw_post + request.headers
secret = ENV.fetch('PRYNT_WEBHOOK_SECRET')
ts = request.env['HTTP_X_PRYNT_TIMESTAMP'].to_s
sig = request.env['HTTP_X_PRYNT_SIGNATURE'].to_s
body = request.body.read # raw body
halt 400 unless ts =~ /\A\d+\z/ && (Time.now.to_i - ts.to_i).abs <= 300
expected = 'sha256=' + OpenSSL::HMAC.hexdigest('SHA256', secret, "#{ts}.#{body}")
halt 401 unless Rack::Utils.secure_compare(expected, sig)
event = JSON.parse(body)
# event['type'], event['data'], event['createdAt']
status 204
end Buenas prácticas
- Responde rápido (2xx) y procesa en segundo plano; un handler lento se reintenta y verás duplicados.
- Sé idempotente: la misma entrega puede llegar dos veces (reintento tras un timeout o repetición manual). Usa
data.account.id+type+createdAtcomo clave. - Rota el secreto desde la consola si se filtra; las entregas antiguas conservan su firma original en el registro.
- Los datos de personas (
reveal.person_verified) solo proceden de identidades de primera parte (tus formularios, logins, importación de CRM); trátalos como datos de tus propios clientes.
Última actualización 2026-11-03 · Límites · Exclusión del visitante