Send every form submission to your own code
Paste an https address into your form's settings and every real submission is posted to it as JSON within seconds, signed so you know it came from us. From there your code files it wherever it belongs. Spam is left out, and a failed delivery is tried again.
Webhooks come with every form. Paste your endpoint in the form's Webhook tab.
import crypto from "node:crypto";
import express from "express";
const app = express();
const SECRET = process.env.FORMHAVEN_WEBHOOK_SECRET;
app.post("/hooks/formhaven", express.raw({ type: "application/json" }), (req, res) => {
const [t, v1] = (req.get("FormHaven-Signature") ?? "").split(",").map((part) => part.split("=")[1]);
const expected = crypto.createHmac("sha256", SECRET).update(`${t}.${req.body}`).digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
if (v1?.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected)) || !fresh) {
return res.status(401).send("Bad signature");
}
const submission = JSON.parse(req.body);
if (!submission.test) {
console.log(submission.form.name, submission.reply_to, submission.fields);
}
res.sendStatus(204);
});
app.listen(3000);
Set it up
-
1
Create a form in FormHaven
Sign up, press New form and put its address in your HTML form's action. It looks like https://formhaven.net/f/YOUR_FORM_ID.
-
2
Paste your endpoint
Open the form, go to the Webhook tab, paste your https:// address and press Save webhook.
-
3
Copy the signing secret
Press Show or Copy under Signing secret and store it as FORMHAVEN_WEBHOOK_SECRET where your endpoint runs. It stays the same when you change the address.
-
4
Send a test event
Press Send a test event. The tab tells you the HTTP status your endpoint answered. The test has the same shape as a real submission, with test set to true.
What your endpoint receives
One JSON object per submission, sent with Content-Type: application/json. fields holds every input by its name, exactly as the visitor filled it in. reply_to is the address from the email field, page is where the form was sent from, and both can be null.
{
"event": "submission.created",
"id": "118",
"test": false,
"form": { "id": "YOUR_FORM_ID", "name": "Contact form on example.nl" },
"received_at": "2026-11-20T19:50:33+00:00",
"reply_to": "visitor@example.com",
"page": "example.nl/contact",
"fields": { "email": "visitor@example.com", "message": "Grüße, café" }
}
Check the signature in PHP
The FormHaven-Signature header is t=<unix time>,v1=<signature>. The signature is the hex HMAC-SHA256 of the time, a dot and the raw body, keyed with your signing secret. Read the raw body before decoding it, and refuse a time more than five minutes old.
<?php
$secret = getenv('FORMHAVEN_WEBHOOK_SECRET');
$body = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_FORMHAVEN_SIGNATURE'] ?? ''), $signature);
$expected = hash_hmac('sha256', ($signature['t'] ?? '').'.'.$body, $secret);
if (! hash_equals($expected, $signature['v1'] ?? '') || abs(time() - (int) ($signature['t'] ?? 0)) > 300) {
http_response_code(401);
exit('Bad signature');
}
$submission = json_decode($body, true);
// $submission['fields'], $submission['reply_to'], ...
http_response_code(204);
Set the webhook from code or an agent
The REST API takes webhook_url on any form, and its answer carries webhook_signing_secret once. Through our MCP server, update_form does the same, so an agent can wire the form to your endpoint while it builds the site.
curl -X PATCH https://formhaven.net/api/v1/forms/YOUR_FORM_ID \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"webhook_url": "https://example.com/hooks/formhaven"}'
Questions about this setup
- What counts as delivered?
- Any 2xx answer within 10 seconds. Anything else is tried again 4 times over about 37 minutes, and the Webhook tab shows the last status and error.
- Is spam sent to my webhook?
- No. Only messages that pass the spam filter are sent, so your endpoint never has to sort them.
- Can I keep no submissions and still use the webhook?
- Yes. The JSON is built the moment a message arrives, so it is still delivered after a form that keeps nothing has deleted the answers.
- Does the email still arrive?
- Yes. The webhook is sent next to the email, never instead of it, so a broken endpoint never costs you a message.
- Which addresses are allowed?
- A public https:// address. Redirects are not followed, and addresses on a private or local network are refused.
More to read
Get your form address in a minute
14 days free, no card. Then €1 per form a month, €0.50 from the 11th form.