Receive real-time event notifications via HTTP callbacks
Manage your webhook endpoints and view delivery history
Loading webhooks...
Learn how to receive and verify webhook payloads
All webhook payloads follow the same structure:
{
"id": "evt_1234567890",
"type": "device.updated",
"created_at": "2024-01-15T10:30:00Z",
"data": {
"id": "device_abc123",
"name": "Farm Sensor 01",
"status": "active",
// ... event-specific data
},
"metadata": {
"user_id": "user_123",
"farm_id": "farm_456"
}
}Always verify the webhook signature to ensure the request came from Precifarm:
// Node.js example
const crypto = require('crypto');
function verifySignature(payload, signature, secret) {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(payload, 'utf8')
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(`sha256=${expectedSignature}`)
);
}
// Usage
app.post('/webhooks', (req, res) => {
const signature = req.headers['x-precifarm-signature'];
const isValid = verifySignature(
JSON.stringify(req.body),
signature,
process.env.WEBHOOK_SECRET
);
if (!isValid) {
return res.status(401).send('Invalid signature');
}
// Process webhook...
res.status(200).send('OK');
});Automatic Retries
Respond Quickly
Return a 200 status within 30 seconds
Handle Duplicates
Use the event ID for idempotency
Process Async
Queue events for background processing
Verify Signatures
Always validate the request origin