Integration Examples
SingleForm webhooks work with any server that can receive HTTP POST requests. Below are complete examples showing manual signature verification for Node.js, Python, Ruby, and PHP.
These examples show manual verification. If you’d rather skip the boilerplate, use one of our official middleware libraries for Express, Flask, Django, FastAPI, Rails, or Sinatra.
Full Examples
Node.js (SDK)
// Using the official @singleform/express-webhook middleware
// Install: npm install express @singleform/express-webhook
import express from "express";
import { singleform } from "@singleform/express-webhook";
const app = express();
app.use(express.json());
app.post(
"/webhooks/singleform",
singleform({ secret: process.env.SINGLEFORM_SECRET }),
(req, res) => {
const { formId } = req.singleform;
const { email, firstName, lastName } = req.body;
console.log(`Form: ${formId}`);
console.log("Data:", { email, firstName, lastName });
// Your business logic here
// - Save to database
// - Send email
// - Update CRM
res.singleformSuccess({
submissionId: "12345",
message: "Thank you for your submission!",
});
}
);
app.listen(3000, () => console.log("Webhook server running on port 3000"));Webhook Payload
Your endpoint receives a JSON POST body containing the form field values submitted by the user:
{
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"phone": "+1234567890",
"_meta": {
"formId": "d4e5f6a7-b8c9-4d2e-a1f3-1234567890ab",
"timestamp": "1706400000",
"source": "singleform-mobile",
"version": "1.0.0"
}
}The _meta object contains submission metadata. The timestamp is a Unix timestamp in seconds (as a string). The source indicates where the submission came from (singleform-mobile for app submissions, singleform-test for test webhooks). All other top-level keys are the form field values.
Environment Variables
Set your webhook secret as an environment variable on your server:
# Linux / macOS
export SINGLEFORM_SECRET="sf_secret_your_secret_here"
# Docker
docker run -e SINGLEFORM_SECRET="sf_secret_..." your-image
# .env file (use with dotenv or similar)
SINGLEFORM_SECRET=sf_secret_your_secret_hereTesting Your Integration
- Use debug mode (Express SDK): Set
debug: trueto log each verification step - Check server logs: Look for the submission data after submitting a test form
- Use the
verifySignaturehelper for unit tests:
import { verifySignature } from "@singleform/express-webhook";
const isValid = verifySignature(
"form-id-123",
"1234567890",
"nonce-abc",
"computed-signature-hex",
"sf_secret_your_secret"
);