Skip to main content

Webhook Setup Guide

Prerequisites

Before setting up webhooks, make sure you have:

  • Dashboard Access: You need access to deepsy.fr/dashboard
  • HTTPS Endpoint: A publicly accessible HTTPS URL to receive webhook events (or a tunneling solution like ngrok for testing)

Step 1: Create Your Webhook in the Dashboard​

Head over to the webhook section in your user settings at deepsy.fr/dashboard/user/webhooks

You'll see a Create button there. Click it and you'll be able to:

  • Give your webhook a name and description
  • Set the URL where you want to receive events
  • Choose which events you want to subscribe to
  • Select which companies you want to monitor

If you're not an administrator of the companies you selected, someone with admin permissions needs to authorize your webhook. They'll need to go to Company Settings → Webhooks and approve your webhook request.


Step 2: Create Your Webhook Endpoint​

Now you need to create an endpoint in your application to receive webhook events. Here are examples in different languages:

const http = require('http');
const url = require('url');

const PORT = 1234;

const server = http.createServer((req, res) => {
const timestamp = new Date().toISOString();
const method = req.method;
const requestUrl = req.url;
const headers = req.headers;

console.log('\n' + '='.repeat(80));
console.log(`[${timestamp}] Incoming ${method} request to ${requestUrl}`);
console.log('='.repeat(80));

// Log headers
console.log('\nšŸ“‹ HEADERS:');
console.log('-'.repeat(40));
Object.entries(headers).forEach(([key, value]) => {
console.log(`${key}: ${value}`);
});

// Collect request body
let body = '';
req.on('data', chunk => {
body += chunk.toString();
});

req.on('end', () => {
// Log request body
console.log('\nšŸ“¦ REQUEST BODY:');
console.log('-'.repeat(40));
if (body) {
try {
// Try to pretty-print JSON
const jsonBody = JSON.parse(body);
console.log(JSON.stringify(jsonBody, null, 2));
} catch (e) {
// If not JSON, log as plain text
console.log(body);
}
} else {
console.log('(empty body)');
}

// Log query parameters if any
const parsedUrl = url.parse(requestUrl, true);
if (Object.keys(parsedUrl.query).length > 0) {
console.log('\nšŸ” QUERY PARAMETERS:');
console.log('-'.repeat(40));
Object.entries(parsedUrl.query).forEach(([key, value]) => {
console.log(`${key}: ${value}`);
});
}

console.log('\n' + '='.repeat(80));

// Send response
res.writeHead(200, {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization'
});

res.end(JSON.stringify({
status: 'success',
message: 'Webhook received successfully',
timestamp: timestamp,
method: method,
url: requestUrl
}, null, 2));
});
});

// Handle OPTIONS requests for CORS
server.on('request', (req, res) => {
if (req.method === 'OPTIONS') {
res.writeHead(200, {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization'
});
res.end();
}
});

server.listen(PORT, 'localhost', () => {
console.log(`šŸš€ Webhook server running on http://localhost:${PORT}`);
console.log('šŸ“” Ready to receive webhook requests...');
console.log('Press Ctrl+C to stop the server\n');
});

// Graceful shutdown
process.on('SIGINT', () => {
console.log('\n\nšŸ›‘ Shutting down webhook server...');
server.close(() => {
console.log('āœ… Server closed successfully');
process.exit(0);
});
});

Step 3: Make Your Endpoint Publicly Accessible​

Your webhook endpoint needs to be accessible from the internet. Here are some options:

Development & Testing​

For development and testing, you can use tunneling services to expose your local server:

ngrok provides reliable tunneling with HTTPS support:

# Install ngrok and create a tunnel to your local server
ngrok http 1234

This gives you a public HTTPS URL like https://abc123.ngrok.io that forwards to your local server.

serveo (Free Alternative)​

serveo is a free alternative, though it can be unstable:

# Create a tunnel using SSH
ssh -R 80:localhost:1234 serveo.net
serveo Stability

serveo is incredibly unstable compared to ngrok. While it's free, ngrok provides a much better and more reliable service.

For production use, always use ngrok or deploy to a proper hosting service. For development and testing, serveo is more than enough.

Learn more about serveo at serveo.net and their tutorial blog.

CLI Tool Alternative​

If you'd prefer a CLI tool to test webhooks without using tunneling services, tell us about it at dev@deepsy.fr, we might create one.

Step 4: Company Authorization​

After creating a webhook, company administrators must authorize it:

Dashboard Authorization​

Company administrators need to go to Company Settings → Webhooks (deepsy.fr/dashboard/company/settings/webhooks) and authorize your webhook request.

If all companies refuse your webhook, it will be automatically deleted.

You'll receive notifications in your dashboard about authorization status.


Step 5: Test Your Webhook​

Once your webhook is authorized, you can test it directly from the dashboard. Click on your webhook and use the test feature to send sample events.

The test will show you both the request payload sent to your endpoint and the response your server returned.

Configuration Options​

When creating webhooks, you can configure:

Required Settings​

  • Name: Human-readable name for your webhook
  • URL: HTTPS endpoint URL to receive events
  • Events: Which event types you want to subscribe to
  • Companies: Which companies you want to monitor

Optional Settings​

  • Description: Detailed description of the webhook's purpose
  • Signature Verification: Enable HMAC signature verification (recommended)
  • Max Retries: Number of retry attempts for failed deliveries (0-5)
  • Metadata: Custom key-value pairs for your reference

Best Practices​

Endpoint Design​

  1. Always Return 200: Return HTTP 200 for successful processing
  2. Process Quickly: Handle events quickly to avoid timeouts (30-second limit)
  3. Handle Duplicates: Process duplicate events gracefully
  4. Log Everything: Log all received events for debugging

Security​

  1. Use HTTPS: Webhook URLs must use HTTPS
  2. Verify Signatures: Always verify webhook signatures when enabled - see our Security Guide
  3. Validate Data: Validate event data before processing
  4. Rate Limiting: Implement rate limiting on your webhook endpoints

Monitoring​

  1. Track Deliveries: Monitor webhook delivery success rates
  2. Set Up Alerts: Alert on webhook endpoint failures
  3. Review Logs: Regularly check webhook logs in the dashboard

Next Steps​

Now that your webhook is set up:

Need Help?​

If you encounter any issues: