Falkenstein, Germany · Hetzner Online GmbH
FormHaven

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.

server.mjs
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. 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. 2

    Paste your endpoint

    Open the form, go to the Webhook tab, paste your https:// address and press Save webhook.

  3. 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. 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.

POST body
{
  "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.

formhaven-webhook.php
<?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.

Terminal
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

HTML form to emailThe form the webhook starts from Astro contact formA Contact.astro component for a static Astro site Static site contact formOne form for Astro, Hugo, Eleventy, Jekyll or plain HTML Hugo contact formA partial and a shortcode for a static Hugo site Lovable contact formOne prompt for a site built with Lovable GDPR compliant contact formEU storage, a DPA and retention you set Kontaktformular nach DSGVOAuf Deutsch: gespeichert in Deutschland, mit AVV JavaScript contact formA fetch script that keeps the visitor on the page Vercel contact formFor plain HTML, Astro or Next.js hosted on Vercel FormSubmit not workingThe usual causes of a silent FormSubmit form Web3Forms not workingThe usual causes of a silent Web3Forms form Eleventy contact formAn include for a static Eleventy (11ty) site Formspree not workingThe usual causes of a silent Formspree form Export from FormspreeEvery Formspree submission, as a file Export from FormsparkEvery Formspark submission, as a file EmailJS not workingThe usual causes of a silent EmailJS form Form backend for AI agentsThe start request, every REST route and MCP tool Claude Code contact formOne prompt, then press Activate Cursor contact formThe prompt and the .cursor/mcp.json entry Contact form privacy policyThe paragraph to copy, in 8 languages GitHub Pages contact formFor user, organisation and project sites on github.io Cloudflare Pages contact formFor sites on pages.dev or your own domain Netlify contact formFor sites on netlify.app or your own domain React contact formOne component for Vite and other React apps Next.js contact formA client component that works with output: export Send form submissions to multiple emailsUp to 5 confirmed addresses per form, plus yours SvelteKit contact formOne Svelte 5 component, any adapter Nuxt contact formOne Vue component for Nuxt 4 and 3 Gatsby contact formOne component for a Gatsby 5 site Jekyll contact formAn include for Jekyll, on GitHub Pages or any host Angular contact formA standalone component that posts with HttpClient Contact form spamWhy forms get spam, and the layers that stop it Contact form honeypotThe hidden field that catches bots, and how to hide it Contact form without PHPFor hosts with no PHP, or mail() that lands in spam HTML form mailtoWhy action="mailto:" fails on webmail visitors, and the one-line fix Contact form templateThe same form in plain HTML Pricing€1 per form a month, €0.50 from the 11th

Get your form address in a minute

14 days free, no card. Then €1 per form a month, €0.50 from the 11th form.

Start your 14-day trial