Entrega
Adicione um endpoint no console (Integrations → Webhook). Você recebe o segredo uma única vez; guarde-o onde guarda outras credenciais. As entregas são requisições POST com corpo JSON e três cabeçalhos:
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"}| Cabeçalho | Significado |
|---|---|
X-Prynt-Event | O tipo de evento: reveal.company_identified, reveal.hot_lead, reveal.person_verified, reveal.session_ended (mais chegam com os segmentos; o seletor de eventos do console é a referência) |
X-Prynt-Timestamp | Segundos Unix em que a entrega foi assinada — rejeite se diferir mais de 5 minutos do seu relógio |
X-Prynt-Signature | sha256= + HMAC-SHA256 em hex com seu segredo sobre <timestamp>.<corpo bruto> |
Corpo: { "type": "<evento>", "data": { … }, "createdAt": "<ISO 8601>" }. Responda com qualquer 2xx sem demora; uma resposta não 2xx ou um timeout é reenviada até 3 tentativas no total. Cada entrega aparece no console com suas tentativas, código de status e uma cópia mascarada do payload, e pode ser reenviada.
Verificar a assinatura
Calcule HMAC_SHA256(segredo, timestamp + "." + corpo_bruto) e compare em tempo constante com o cabeçalho. Use sempre os bytes **brutos** da requisição: reserializar o JSON muda espaços e ordem das chaves e quebra a assinatura.
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 Boas práticas
- Responda rápido (2xx) e processe de forma assíncrona; um handler lento é reenviado e você verá duplicatas.
- Seja idempotente: a mesma entrega pode chegar duas vezes (reenvio após timeout ou replay manual). Use
data.account.id+type+createdAtcomo chave. - Rotacione o segredo pelo console se vazar; entregas antigas mantêm sua assinatura original no registro.
- Dados de pessoas (
reveal.person_verified) vêm apenas de identidades de primeira parte (seus formulários, logins, importação de CRM); trate-os como dados dos seus próprios clientes.
Última atualização 2026-11-03 · Limites · Exclusão do visitante