Webhook-uri
Evenimente semnate, verificarea semnăturii, reîncercări, reluare și API-ul de endpoint-uri.
Endpoint-urile webhook sunt disponibile de la Business. Le creezi în Setări → Dezvoltatori → Webhooks sau cu API-ul de mai jos (scope webhooks:manage). Fiecare endpoint se abonează la tipuri de evenimente și, opțional, la anumite formulare.
Evenimente
| Eveniment | Când | Vizibil în GET /events cu |
|---|---|---|
| response.started | un respondent a început formularul | responses:read |
| response.completed | un respondent a trimis formularul (declanșatorul principal) | responses:read |
| response.deleted | un răspuns a fost șters prin API sau MCP (reversibil 30 de zile) | responses:read |
| answer.submitted | un răspuns la o întrebare salvat (volum mare) | responses:read |
| file.uploaded | un respondent a încărcat un fișier (metadate, fără link) | responses:read |
| recording.transcribed | un răspuns vocal a fost transcris | responses:read |
| form.created / form.updated / form.published / form.unpublished / form.deleted | din dashboard, din API sau din MCP | forms:read |
| webhook.test | „Trimite test” sau POST /webhook_endpoints/{id}/test | webhooks:manage |
{
"id": "evt_…", "object": "event", "type": "response.completed", "created": "2026-11-27T10:15:00Z",
"api_version": "v1", "workspace_id": "ws_…", "form_id": "form_…", "source": "respondent",
"data": { "object": { "id": "rsp_…", "object": "response", "status": "completed", "fields": { "qst_…": "…" } } }
}Datele personale apar în payload doar pentru endpoint-urile cu include_personal_data (setarea cere o cheie cu acces la date personale). file.uploaded nu conține niciodată link de descărcare.
Antete
- Mform-Signature: t=<secunde unix>,v1=<hex>
- Mform-Event-Id (evt_…), Mform-Event-Type, Mform-Delivery-Id (wd_…)
- Content-Type: application/json, User-Agent: mform-webhooks/1
Verifică semnătura
v1 = hex HMAC-SHA256(secret, t + "." + corpul brut). Folosește octeții bruți, nu JSON reserializat. Respinge când t e la mai mult de 5 minute de ceasul tău și compară în timp constant. În timpul rotirii secretului antetul are două valori v1=: acceptă oricare.
// use the RAW body (express.raw), not the parsed JSON
import crypto from "node:crypto";
export function verifyMformSignature(rawBody, header, secret, toleranceSec = 300) {
const items = String(header || "").split(",").map((p) => p.trim().split("="));
const t = Number((items.find(([k]) => k === "t") || [])[1]);
if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const want = Buffer.from(expected);
return items.some(([k, v]) => {
if (k !== "v1" || typeof v !== "string") return false;
const got = Buffer.from(v, "utf8"); // byte length, so non-ASCII input cannot make timingSafeEqual throw
return got.length === want.length && crypto.timingSafeEqual(got, want);
});
}
app.post("/webhooks/mform", express.raw({ type: "application/json" }), (req, res) => {
const raw = req.body.toString("utf8");
if (!verifyMformSignature(raw, req.get("Mform-Signature"), process.env.MFORM_WEBHOOK_SECRET)) return res.sendStatus(400);
res.sendStatus(200); // answer fast,
queue.add(JSON.parse(raw)); // process later, dedupe on event.id
});Vector de test — secret whsec_test_4eC39HqLyjWDarjtT1zdp7dc, t=1764238500, corp {"id":"evt_test0000000000000000000001","object":"event","type":"webhook.test"} → v1=d6085e5d7fdd562799a01e8fe07338bf0b633a6fa3cc83b4f2cc15266d34933d. Testele noastre rulează pe el exemplele Node, Python și PHP.
Livrare și reîncercări
- Răspunde 2xx în 10 secunde; orice altceva (sau un timeout) e eșec. Procesează asincron și elimină dublurile după id-ul evenimentului: ordinea nu e garantată.
- Încercări: imediat, apoi după 1 min, 5 min, 30 min, 2 h, 6 h, 12 h și 24 h (8 încercări în circa 45 de ore). După ultima, livrarea e abandonată.
- Un endpoint care eșuează 3 zile la rând e dezactivat (status disabled_by_failures) și proprietarul workspace-ului primește un e-mail. Îl reactivezi cu PATCH status=enabled.
- Fiecare endpoint e livrat independent, cel mult 4 cereri simultane per endpoint.
- Doar URL-uri https publice: adresele private, loopback și link-local sunt refuzate, și după rezolvarea DNS; ne conectăm la adresa validată și nu urmăm redirecționări.
Reluare și recuperare
- GET /webhook_endpoints/{id}/deliveries listează încercările, cele mai noi primele (status pending, succeeded sau abandoned; eroarea și codul de răspuns, niciodată corpul receptorului).
- POST …/deliveries/{delivery_id}/retry pune o livrare din nou la coadă imediat.
- GET /events păstrează fiecare eveniment 30 de zile: folosește-l ca să reconstruiești ce a pierdut receptorul.
- Rotește secretul cu POST /webhook_endpoints/{id}/rotate_secret: secretul anterior rămâne valabil expire_previous_in_hours (implicit 24, 0–168).
- Endpoint-urile create înainte de v1 păstrează payload-ul vechi și X-Megaforms-Signature, plus Mform-Signature, până le treci pe v1 (vezi Migrarea webhook-urilor vechi).
# What did my receiver miss during the outage? (events are kept 30 days)
curl "https://mform.md/api/public/v1/events?type=response.completed&created_after=2026-11-27T08:00:00Z&limit=100" \
-H "Authorization: Bearer $MFORM_API_KEY"
# Or re-send failed deliveries of one endpoint (webhooks:manage, Business+)
curl "https://mform.md/api/public/v1/webhook_endpoints/we_…/deliveries?status=abandoned" -H "Authorization: Bearer $MFORM_API_KEY"
curl -X POST "https://mform.md/api/public/v1/webhook_endpoints/we_…/deliveries/wd_…/retry" -H "Authorization: Bearer $MFORM_API_KEY"API-ul de endpoint-uri
get/webhook_endpoints
List webhook endpoints listWebhookEndpoints
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
limit | query | integer | nu | Page size, 1–100. |
cursor | query | string | nu | The `next_cursor` of the previous page. Bound to the same filters and the same key's workspace. |
curl https://mform.md/api/public/v1/webhook_endpoints \
-H "Authorization: Bearer $MFORM_API_KEY"Răspuns 200
{
"object": "list",
"data": [
{
"id": "we_8Hq2LmZ71cX",
"object": "webhook_endpoint",
"url": "https://example.com/webhooks/mform",
"description": "How was your visit?",
"events": [
"response.started"
],
"form_ids": [
"form_8Hq2LmZ71cX"
],
"include_personal_data": false,
"status": "enabled",
"api_version": "v1",
"secret_rotation_ends_at": "2026-11-27T10:15:00Z",
"last_delivery_at": "2026-11-27T10:15:00Z",
"last_status_code": 1,
"failing_since": "2026-11-27T10:15:00Z",
"created_at": "2026-11-27T10:15:00Z"
}
],
"has_more": false,
"next_cursor": "example"
}post/webhook_endpoints
Create a webhook endpoint createWebhookEndpoint
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP · acceptă Idempotency-Key
`url` must be public `https://` (private, loopback and link-local addresses are refused, also after DNS resolution). The `secret` (`whsec_…`) is returned only in this response. Zapier and Make "instant" triggers call this on subscribe and `DELETE` on unsubscribe. Plan feature `webhooks` (Business and up).
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
Idempotency-Key | header | string | nu | Any unique string (a UUID). The first result is kept 24 hours and replayed for the same key and body (`Idempotent-Replayed: true`); a different body returns `409 idempotency_key_reused`. |
Corp (JSON)
| Nume | Tip | Obligatoriu | Descriere |
|---|---|---|---|
url | string (uri) | da | |
description | string | nu | |
events | "response.started" | "response.completed" | "response.deleted" | "answer.submitted" | "file.uploaded" | "recording.transcribed" | "form.created" | "form.updated" | "form.published" | "form.unpublished" | "form.deleted" | "webhook.test"[] | da | |
form_ids | form_… id[] | null | nu | Only events of these forms. `null` = every form the key can see. |
include_personal_data | boolean | nu | Put respondent name, e-mail, phone and contact answers in the payload. Requires `responses:pii`. Default = whether the key has `responses:pii`. |
curl -X POST https://mform.md/api/public/v1/webhook_endpoints \
-H "Authorization: Bearer $MFORM_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/webhooks/mform","events":["response.started"]}'Răspuns 201
{
"id": "we_8Hq2LmZ71cX",
"object": "webhook_endpoint",
"url": "https://example.com/webhooks/mform",
"description": "How was your visit?",
"events": [
"response.started"
],
"form_ids": [
"form_8Hq2LmZ71cX"
],
"include_personal_data": false,
"status": "enabled",
"api_version": "v1",
"secret_rotation_ends_at": "2026-11-27T10:15:00Z",
"last_delivery_at": "2026-11-27T10:15:00Z",
"last_status_code": 1,
"failing_since": "2026-11-27T10:15:00Z",
"created_at": "2026-11-27T10:15:00Z",
"secret": "example"
}get/webhook_endpoints/{endpoint_id}
Retrieve a webhook endpoint getWebhookEndpoint
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
endpoint_id | path | we_… id | da |
curl https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX \
-H "Authorization: Bearer $MFORM_API_KEY"Răspuns 200
{
"id": "we_8Hq2LmZ71cX",
"object": "webhook_endpoint",
"url": "https://example.com/webhooks/mform",
"description": "How was your visit?",
"events": [
"response.started"
],
"form_ids": [
"form_8Hq2LmZ71cX"
],
"include_personal_data": false,
"status": "enabled",
"api_version": "v1",
"secret_rotation_ends_at": "2026-11-27T10:15:00Z",
"last_delivery_at": "2026-11-27T10:15:00Z",
"last_status_code": 1,
"failing_since": "2026-11-27T10:15:00Z",
"created_at": "2026-11-27T10:15:00Z"
}patch/webhook_endpoints/{endpoint_id}
Update a webhook endpoint updateWebhookEndpoint
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP
Re-enabling an endpoint disabled after failures resets its failure counter.
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
endpoint_id | path | we_… id | da |
Corp (JSON)
| Nume | Tip | Obligatoriu | Descriere |
|---|---|---|---|
url | string (uri) | nu | |
description | string | nu | |
events | "response.started" | "response.completed" | "response.deleted" | "answer.submitted" | "file.uploaded" | "recording.transcribed" | "form.created" | "form.updated" | "form.published" | "form.unpublished" | "form.deleted" | "webhook.test"[] | nu | |
form_ids | form_… id[] | null | nu | |
include_personal_data | boolean | nu | |
status | "enabled" | "disabled" | nu |
curl -X PATCH https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX \
-H "Authorization: Bearer $MFORM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/webhooks/mform"}'Răspuns 200
{
"id": "we_8Hq2LmZ71cX",
"object": "webhook_endpoint",
"url": "https://example.com/webhooks/mform",
"description": "How was your visit?",
"events": [
"response.started"
],
"form_ids": [
"form_8Hq2LmZ71cX"
],
"include_personal_data": false,
"status": "enabled",
"api_version": "v1",
"secret_rotation_ends_at": "2026-11-27T10:15:00Z",
"last_delivery_at": "2026-11-27T10:15:00Z",
"last_status_code": 1,
"failing_since": "2026-11-27T10:15:00Z",
"created_at": "2026-11-27T10:15:00Z"
}delete/webhook_endpoints/{endpoint_id}
Delete a webhook endpoint deleteWebhookEndpoint
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP
Pending deliveries are cancelled. Endpoints are configuration, not customer data, so they can be deleted.
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
endpoint_id | path | we_… id | da |
curl -X DELETE https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX \
-H "Authorization: Bearer $MFORM_API_KEY"Răspuns 200
{
"id": "example",
"object": "example",
"deleted": true
}post/webhook_endpoints/{endpoint_id}/rotate_secret
Rotate the signing secret rotateWebhookSecret
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP · acceptă Idempotency-Key
Returns a new `whsec_…` secret (shown once). For `expire_previous_in_hours` (default 24, 0–168) every delivery is signed with both secrets (two `v1=` values), so receivers can switch without downtime.
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
endpoint_id | path | we_… id | da |
Corp (JSON)
| Nume | Tip | Obligatoriu | Descriere |
|---|---|---|---|
expire_previous_in_hours | integer | nu |
curl -X POST https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX/rotate_secret \
-H "Authorization: Bearer $MFORM_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'Răspuns 200
{
"id": "we_8Hq2LmZ71cX",
"object": "webhook_endpoint",
"url": "https://example.com/webhooks/mform",
"description": "How was your visit?",
"events": [
"response.started"
],
"form_ids": [
"form_8Hq2LmZ71cX"
],
"include_personal_data": false,
"status": "enabled",
"api_version": "v1",
"secret_rotation_ends_at": "2026-11-27T10:15:00Z",
"last_delivery_at": "2026-11-27T10:15:00Z",
"last_status_code": 1,
"failing_since": "2026-11-27T10:15:00Z",
"created_at": "2026-11-27T10:15:00Z",
"secret": "example"
}post/webhook_endpoints/{endpoint_id}/test
Send a test event testWebhookEndpoint
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP · acceptă Idempotency-Key
Sends a signed `webhook.test` event now and returns the delivery. 10 per minute.
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
endpoint_id | path | we_… id | da |
curl -X POST https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX/test \
-H "Authorization: Bearer $MFORM_API_KEY" \
-H "Idempotency-Key: $(uuidgen)"Răspuns 200
{
"id": "wd_8Hq2LmZ71cX",
"object": "webhook_delivery",
"endpoint_id": "example",
"event_id": "example",
"event_type": "response.started",
"status": "pending",
"attempts": 1,
"next_attempt_at": "2026-11-27T10:15:00Z",
"last_attempt_at": "2026-11-27T10:15:00Z",
"response_status": 1,
"duration_ms": 1,
"error": "example",
"created_at": "2026-11-27T10:15:00Z"
}get/webhook_endpoints/{endpoint_id}/deliveries
List deliveries of an endpoint listWebhookDeliveries
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP
Newest first. The receiver's response body is never stored or returned.
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
endpoint_id | path | we_… id | da | |
limit | query | integer | nu | Page size, 1–100. |
cursor | query | string | nu | The `next_cursor` of the previous page. Bound to the same filters and the same key's workspace. |
status | query | "pending" | "succeeded" | "failed" | "abandoned" | nu | The v1 delivery worker writes `pending` (waiting, or failed and scheduled for another attempt, with `error` set), `succeeded` and `abandoned` (all 8 attempts failed). Use `abandoned` to find deliveries to re-send. `failed` is accepted but no current sender writes it, so it returns an empty list. |
curl https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX/deliveries \
-H "Authorization: Bearer $MFORM_API_KEY"Răspuns 200
{
"object": "list",
"data": [
{
"id": "wd_8Hq2LmZ71cX",
"object": "webhook_delivery",
"endpoint_id": "example",
"event_id": "example",
"event_type": "response.started",
"status": "pending",
"attempts": 1,
"next_attempt_at": "2026-11-27T10:15:00Z",
"last_attempt_at": "2026-11-27T10:15:00Z",
"response_status": 1,
"duration_ms": 1,
"error": "example",
"created_at": "2026-11-27T10:15:00Z"
}
],
"has_more": false,
"next_cursor": "example"
}post/webhook_endpoints/{endpoint_id}/deliveries/{delivery_id}/retry
Retry a delivery now retryWebhookDelivery
Scope: webhooks:manage · Plan: Business și peste · Unealtă MCP: nu e expusă prin MCP · acceptă Idempotency-Key
Re-sends the same event (same `id`, fresh signature). Receivers must de-duplicate on the event `id`.
Parametri
| Nume | Unde | Tip | Obligatoriu | Descriere |
|---|---|---|---|---|
endpoint_id | path | we_… id | da | |
delivery_id | path | wd_… id | da |
curl -X POST https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX/deliveries/wd_8Hq2LmZ71cX/retry \
-H "Authorization: Bearer $MFORM_API_KEY" \
-H "Idempotency-Key: $(uuidgen)"Răspuns 200
{
"id": "wd_8Hq2LmZ71cX",
"object": "webhook_delivery",
"endpoint_id": "example",
"event_id": "example",
"event_type": "response.started",
"status": "pending",
"attempts": 1,
"next_attempt_at": "2026-11-27T10:15:00Z",
"last_attempt_at": "2026-11-27T10:15:00Z",
"response_status": 1,
"duration_ms": 1,
"error": "example",
"created_at": "2026-11-27T10:15:00Z"
}