TownHall Webhooks API
Send form submissions to any URL. Build custom integrations, trigger serverless functions, or connect to your own backend.
Features
How to set up
Set Up Your Endpoint
Create an HTTP endpoint on your server to receive webhook payloads.
Add Webhook URL
In TownHall form settings, add your endpoint URL to the webhooks section.
Verify Signatures
Implement signature verification to ensure webhooks are from TownHall.
Handle the Payload
Process the JSON payload and perform your custom logic.
Code example
// Webhook signature verification (Node.js)
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return signature === `sha256=${expectedSignature}`;
}
// Express webhook handler
app.post('/webhook', (req, res) => {
const signature = req.headers['x-townhall-signature'];
const payload = JSON.stringify(req.body);
if (!verifyWebhook(payload, signature, process.env.WEBHOOK_SECRET)) {
return res.status(401).send('Invalid signature');
}
// Process the submission
const { form, submission } = req.body;
console.log('New submission:', submission.data);
res.status(200).send('OK');
});Use cases
Related integrations
Zapier
Connect TownHall to 5,000+ apps through Zapier. Automate workflows, sync data, a...
automationMake (Integromat)
Build sophisticated automations with Make (formerly Integromat). Create multi-st...
notificationsSlack
Get instant Slack notifications for every form submission. Route messages to dif...