Webhook Testing
Dashboard Testing
The easiest way to test your webhooks is directly from the DeePsy dashboard.
Built-in Test Feature
Once your webhook is created and authorized, you can test it directly from the dashboard:
- Go to your webhook settings at deepsy.fr/dashboard/user/webhooks
- Click on your webhook
- Use the test feature to send sample events
- View both the request payload and your server's response
The test feature uses real data when available, falling back to realistic fake data when needed. This gives you a true representation of what your webhook will receive in production.
Local Development Setup
Making Your Local Server Accessible
For development and testing, you need to expose your local server to the internet. See our Setup Guide for detailed instructions on using ngrok, serveo, or other tunneling solutions.
Test Webhook Server
You can use the webhook servers from our Setup Guide for testing. They're designed to log all incoming requests and responses, making debugging easy.
Alternatively, here's a simple test server:
- JavaScript
- cURL Receiver
const express = require('express');
const app = express();
// Use raw body parser for signature verification
app.use('/webhooks/deepsy', express.raw({type: 'application/json'}));
app.post('/webhooks/deepsy', (req, res) => {
console.log('=== Webhook Received ===');
console.log('Headers:', req.headers);
console.log('Raw Body:', req.body.toString());
try {
const event = JSON.parse(req.body);
console.log('Parsed Event:', JSON.stringify(event, null, 2));
} catch (e) {
console.log('Failed to parse JSON:', e.message);
}
console.log('========================');
// Always respond with 200
res.status(200).send('OK');
});
// Health check endpoint
app.get('/health', (req, res) => {
res.status(200).json({
status: 'ok',
timestamp: new Date().toISOString()
});
});
const port = process.env.PORT || 1234;
app.listen(port, () => {
console.log(`Test webhook server running on port ${port}`);
});
#!/bin/bash
# Simple webhook receiver using netcat
# Save as webhook-receiver.sh and run: chmod +x webhook-receiver.sh && ./webhook-receiver.sh
PORT=1234
echo "Starting webhook receiver on port $PORT"
echo "Press Ctrl+C to stop"
while true; do
echo "Waiting for webhook..."
echo -e "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 15\r\n\r\n{\"status\":\"ok\"}" | nc -l -p $PORT -q 1
echo "Webhook received at $(date)"
echo "---"
done
API Testing
Built-in Test Endpoint
DeePsy provides a test endpoint to send sample events to your webhook:
- cURL
- JavaScript
- PHP
curl -X POST "https://deepsy.fr/api/v1/webhooks/{webhook_id}/test-with-real-data" \
-H "Authorization: Bearer deepsy-dev-your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"event_type": "candidate.test_completed",
"company_id": "company-uuid"
}'
const response = await fetch(`https://deepsy.fr/api/v1/webhooks/${webhookId}/test-with-real-data`, {
method: 'POST',
headers: {
'Authorization': 'Bearer deepsy-dev-your-api-key-here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
event_type: 'candidate.test_completed',
company_id: 'company-uuid'
})
});
const result = await response.json();
console.log('Test result:', result);
<?php
$webhookId = 'your-webhook-id';
$data = [
'event_type' => 'candidate.test_completed',
'company_id' => 'company-uuid'
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://deepsy.fr/api/v1/webhooks/$webhookId/test-with-real-data",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer deepsy-dev-your-api-key-here',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$result = json_decode($response, true);
curl_close($curl);
print_r($result);
?>
Testing Different Event Types
Test various event types to ensure your webhook handles them correctly:
# Test email events
curl -X POST "https://deepsy.fr/api/v1/webhooks/{webhook_id}/test-with-real-data" \
-H "Authorization: Bearer deepsy-dev-your-api-key-here" \
-H "Content-Type: application/json" \
-d '{"event_type": "email.delivered", "company_id": "company-uuid"}'
# Test campaign events
curl -X POST "https://deepsy.fr/api/v1/webhooks/{webhook_id}/test-with-real-data" \
-H "Authorization: Bearer deepsy-dev-your-api-key-here" \
-H "Content-Type: application/json" \
-d '{"event_type": "campaign.created", "company_id": "company-uuid"}'
# Test candidate events
curl -X POST "https://deepsy.fr/api/v1/webhooks/{webhook_id}/test-with-real-data" \
-H "Authorization: Bearer deepsy-dev-your-api-key-here" \
-H "Content-Type: application/json" \
-d '{"event_type": "candidate.evaluation_completed", "company_id": "company-uuid"}'
Automated Testing
Unit Tests for Webhook Handlers
const { expect } = require('chai');
const { verifyWebhookSignature, processWebhookEvent } = require('./webhook-handler');
describe('Webhook Handler', () => {
describe('Signature Verification', () => {
it('should verify valid signatures', () => {
const payload = '{"event":"test"}';
const secret = 'whsec_test123';
const signature = createTestSignature(payload, secret);
expect(verifyWebhookSignature(payload, signature, secret)).to.be.true;
});
it('should reject invalid signatures', () => {
const payload = '{"event":"test"}';
const secret = 'whsec_test123';
const invalidSignature = 'sha256=invalid';
expect(verifyWebhookSignature(payload, invalidSignature, secret)).to.be.false;
});
});
describe('Event Processing', () => {
it('should process candidate.test_completed events', () => {
const event = {
event: 'candidate.test_completed',
company_id: 'test-company',
data: {
candidate_id: 'test-candidate',
campaign_id: 'test-campaign',
raw_score: 85.5
}
};
const result = processWebhookEvent(event);
expect(result.processed).to.be.true;
expect(result.event).to.equal('candidate.test_completed');
});
});
});
function createTestSignature(payload, secret) {
const crypto = require('crypto');
const hash = crypto.createHmac('sha256', secret).update(payload).digest('hex');
return `sha256=${hash}`;
}
Integration Tests
const request = require('supertest');
const app = require('./app');
describe('Webhook Endpoint Integration', () => {
it('should accept valid webhook requests', async () => {
const payload = {
event: 'candidate.test_completed',
company_id: 'test-company',
timestamp: new Date().toISOString(),
data: {
candidate_id: 'test-candidate'
}
};
const response = await request(app)
.post('/webhooks/deepsy')
.send(payload)
.set('Content-Type', 'application/json')
.set('X-Webhook-Signature', createValidSignature(payload));
expect(response.status).toBe(200);
});
it('should reject requests with invalid signatures', async () => {
const payload = { event: 'test' };
const response = await request(app)
.post('/webhooks/deepsy')
.send(payload)
.set('Content-Type', 'application/json')
.set('X-Webhook-Signature', 'invalid-signature');
expect(response.status).toBe(401);
});
});
Testing Tools and Services
Webhook Testing Services
ngrok.com
Paid service for exposing local servers to the internet, we already talked about it in the Setup Guide.
serveo.net
Free alternative to ngrok, though it can be unstable. We also mentioned it in the Setup Guide.
webhook.site
Free service for testing webhooks:
- Visit webhook.site
- Copy the unique URL provided
- Use this URL as your webhook endpoint during testing
- View received requests in real-time
RequestBin
We haven't test it ourselves, but it seems like another webhook testing service:
- Visit requestbin.com
- Create a new bin
- Use the bin URL for webhook testing
Debug Logging
Add comprehensive logging to your webhook handler:
const debug = require('debug')('webhook');
app.post('/webhooks/deepsy', (req, res) => {
debug('Received webhook request');
debug('Headers: %O', req.headers);
debug('Body: %O', req.body);
try {
const isValid = verifySignature(req.body, req.headers['x-webhook-signature']);
debug('Signature valid: %s', isValid);
if (!isValid) {
debug('Signature verification failed');
return res.status(401).send('Unauthorized');
}
processWebhookEvent(req.body);
debug('Event processed successfully');
res.status(200).send('OK');
} catch (error) {
debug('Error processing webhook: %O', error);
res.status(500).send('Error');
}
});
Production Monitoring
For production webhook monitoring and troubleshooting common issues, see our dedicated Troubleshooting Guide.
Next Steps
Now that you know how to test webhooks:
- Review Available Events to understand all event types
- Implement Security Verification for production
- Check Troubleshooting for common issues
- Set up monitoring and alerting for your webhook endpoints
Need Help?
If you encounter issues during testing:
- Check our Troubleshooting Guide for solutions
- Contact our development team at dev@deepsy.fr
- Reach out via deepsy.fr/contact