Crie seu primeiro webhook para receber notificações em tempo real sobre seus pedidos.
X-Webhook-Signature:
sha256=<hex>
X-Webhook-Event:
X-Webhook-Delivery:
X-Webhook-Timestamp:
Content-Type:
User-Agent:
{ "event": "order.created", "timestamp": "2025-01-15 10:30:00", "webhook_id": 123, "delivery_id": 456, "data": { "id": "240115001", "type": "letter", "status": 0, "recipient": { "name": "João Silva", "addr1": "Rua das Flores, 123", "city": "São Paulo", "state": "SP", "zip": "01234-567" }, "value": 15.50, "created_at": "2024-01-15 10:30:00", "paymentMethod": "invoice" } }
<?php $secret = 'SEU_SEGREDO_AQUI'; $payload = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? ''; $expected = 'sha256=' . hash_hmac('sha256', $payload, $secret); if (!hash_equals($expected, $signature)) { http_response_code(401); exit('Assinatura inválida'); } // Payload é válido — processe normalmente $data = json_decode($payload, true); http_response_code(200);
const crypto = require('crypto'); const express = require('express'); const app = express(); const SECRET = 'SEU_SEGREDO_AQUI'; app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => { const signature = req.header('X-Webhook-Signature') || ''; const expected = 'sha256=' + crypto .createHmac('sha256', SECRET) .update(req.body) .digest('hex'); if (!crypto.timingSafeEqual( Buffer.from(signature), Buffer.from(expected))) { return res.status(401).send('Invalid signature'); } const data = JSON.parse(req.body.toString()); res.status(200).send('ok'); } );
import hmac, hashlib from flask import Flask, request, abort SECRET = b'SEU_SEGREDO_AQUI' app = Flask(__name__) @app.post('/webhook') def webhook(): signature = request.headers.get('X-Webhook-Signature', '') expected = 'sha256=' + hmac.new( SECRET, request.get_data(), hashlib.sha256).hexdigest() if not hmac.compare_digest(expected, signature): abort(401) data = request.get_json() return '', 200
Nenhuma atividade registrada ainda.
Use este valor para verificar a assinatura HMAC-SHA256 enviada no header X-Webhook-Signature.
X-Webhook-Signature