FormData
Webhook pushes each user-submitted form information to your CRM or other app in real time in JSON format. In your webhook, you can save the information to your database, trigger an email or any other action.
Setting up a Webhook
To set up a Webhook:
- Log on to
ezsite
and click setting. - Click the webhook menu
- Input the webhook URL of the Endpoint you configured in the Webhook tab.
- click save.
Once the webhook URL is entered, the webhook Sign Key is automatically generated. Copy and save it if you wish to use it to ensure the request is from ezsite.ai. Another way is to set our Trigger IPs in your whitelist.
Receiving Endpoint
Gain confidence in the authenticity of your webhooks when you use a webhook signing key that mentioned above, a unique secret key shared between your application and ezsite
, to verify the events sent to your endpoints. The webhook signing key will produce theX-Webhook-Signature
, which you can use to compare against an expected webhook signature, to verify events from ezsite
.
X-Webhook-Signature
When ezsite
sends your app a webhook, it will include theX-Webhook-Signature
header in the following format:
X-Webhook-Signature: t=1492774577,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
Compare the X-Webhook-Signature
, prefixed by v1=
, to the expected signature. If they match, then you can trust that the event payload was issued by ezsite
and has not been tampered with.
const crypto = require('crypto');
// Your application's webhook signing key
const webhookSigningKey = ({}).WEBHOOK_SIGNING_KEY;
// Extract the timestamp and signature from the header
const newoaksSignature = req.get('X-Webhook-Signature');
const { t, signature } = newoaksSignature.split(',').reduce((acc, currentValue) => {
const [key, value] = currentValue.split('=');
if (key === 't') {
// UNIX timestamp
acc.t = value;
}
if (key === 'v1') {
acc.signature = value
}
return acc;
}, {
t: '',
signature: ''
});
if (!t || !signature) throw new Error('Invalid Signature');
// Create the signed payload by concatenating the timestamp (t), the character '.' and the request body's JSON payload.
const data = t + '.' + JSON.stringify(req.body);
const expectedSignature = crypto.createHmac('sha256', webhookSigningKey).update(data, 'utf8').digest('hex');
// Determine the expected signature by computing an HMAC with the SHA256 hash function.
if (expectedSignature !== signature) {
// Signature is invalid!
throw new Error('Invalid Signature');
}
Listening for form submissions
When an event occurs, it is notified to your configured webhook URL. Push any new formdata immediately,
Notification Details - HTTP POST Request
Method | POST |
---|---|
Content-Type | application/json |
JSON Body
{
// string - Project Name
"ProjectName": "Market survey questionnaire",
// long - UTC time zone timestamp
"Timestamp": 1741770951,
// string - Data source url
"Source": "https://www.ezsite.ai",
// string - Submitted form table name
"TableName": "contact_submissions",
// object - Submitted form content
"FormData": {...}
}
Error retry
Data response: {"status":"success"}
or {"status":"Success: test request received"}
(case-sensitive,the return value required for a successful callback), returning other values is considered a failure. After failure, retry within 1 minute and 3 minutes.