Вебхуки
Подписанные события, проверка подписи, повторы, повторная отправка и API эндпоинтов.
Вебхук-эндпоинты доступны с тарифа Business. Создавайте их в Настройки → Разработчикам → Webhooks или через API ниже (scope webhooks:manage). Каждый эндпоинт подписывается на типы событий и, при желании, на отдельные формы.
События
| Событие | Когда | Видно в GET /events с |
|---|---|---|
| response.started | респондент начал заполнять форму | responses:read |
| response.completed | респондент отправил форму (главный триггер) | responses:read |
| response.deleted | ответ удалён через API или MCP (обратимо 30 дней) | responses:read |
| answer.submitted | сохранён ответ на один вопрос (большой объём) | responses:read |
| file.uploaded | респондент загрузил файл (метаданные, без ссылки) | responses:read |
| recording.transcribed | голосовой ответ расшифрован | responses:read |
| form.created / form.updated / form.published / form.unpublished / form.deleted | из панели, через API или MCP | forms:read |
| webhook.test | «Отправить тест» или 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_…": "…" } } }
}Персональные данные попадают в payload только для эндпоинтов с include_personal_data (для этой настройки нужен ключ с доступом к персональным данным). file.uploaded никогда не содержит ссылку на скачивание.
Заголовки
- Mform-Signature: t=<unix-секунды>,v1=<hex>
- Mform-Event-Id (evt_…), Mform-Event-Type, Mform-Delivery-Id (wd_…)
- Content-Type: application/json, User-Agent: mform-webhooks/1
Проверка подписи
v1 = hex HMAC-SHA256(secret, t + "." + сырое тело). Используйте исходные байты, а не пересериализованный JSON. Отклоняйте, если t отличается от ваших часов больше чем на 5 минут, сравнивайте за постоянное время. Во время замены секрета в заголовке два значения v1=: принимайте любое.
// 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
});Тестовый вектор — secret whsec_test_4eC39HqLyjWDarjtT1zdp7dc, t=1764238500, тело {"id":"evt_test0000000000000000000001","object":"event","type":"webhook.test"} → v1=d6085e5d7fdd562799a01e8fe07338bf0b633a6fa3cc83b4f2cc15266d34933d. Наши тесты прогоняют на нём примеры на Node, Python и PHP.
Доставка и повторы
- Ответьте 2xx в течение 10 секунд; всё остальное (или таймаут) — ошибка. Обрабатывайте асинхронно и устраняйте дубли по id события: порядок не гарантирован.
- Попытки: сразу, затем через 1 мин, 5 мин, 30 мин, 2 ч, 6 ч, 12 ч и 24 ч (8 попыток примерно за 45 часов). После последней доставка отменяется (abandoned).
- Эндпоинт, который не отвечает 3 дня подряд, отключается (status disabled_by_failures), владелец пространства получает письмо. Включите его снова через PATCH status=enabled.
- Каждый эндпоинт доставляется независимо, не более 4 одновременных запросов на эндпоинт.
- Только публичные https-URL: частные, loopback и link-local адреса отклоняются, в том числе после DNS; мы подключаемся к проверенному адресу и не следуем редиректам.
Повторная отправка и восстановление
- GET /webhook_endpoints/{id}/deliveries перечисляет попытки, сначала новые (status pending, succeeded или abandoned; ошибка и код ответа, но никогда не тело ответа приёмника).
- POST …/deliveries/{delivery_id}/retry сразу ставит доставку в очередь снова.
- GET /events хранит каждое событие 30 дней: по нему можно восстановить всё, что пропустил приёмник.
- Замена секрета: POST /webhook_endpoints/{id}/rotate_secret; прежний секрет действует expire_previous_in_hours (по умолчанию 24, 0–168).
- Эндпоинты, созданные до v1, сохраняют старый payload и X-Megaforms-Signature, плюс Mform-Signature, пока вы не переведёте их на v1 (см. Миграция старых вебхуков).
# 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 эндпоинтов
get/webhook_endpoints
List webhook endpoints listWebhookEndpoints
Scope: webhooks:manage · Тариф: Business и выше · Инструмент MCP: не доступна через MCP
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
limit | query | integer | нет | Page size, 1–100. |
cursor | query | string | нет | 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"Ответ 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 · Тариф: Business и выше · Инструмент MCP: не доступна через MCP · поддерживает 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).
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
Idempotency-Key | header | string | нет | 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`. |
Тело (JSON)
| Имя | Тип | Обязательный | Описание |
|---|---|---|---|
url | string (uri) | да | |
description | string | нет | |
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"[] | да | |
form_ids | form_… id[] | null | нет | Only events of these forms. `null` = every form the key can see. |
include_personal_data | boolean | нет | 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"]}'Ответ 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 · Тариф: Business и выше · Инструмент MCP: не доступна через MCP
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
endpoint_id | path | we_… id | да |
curl https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX \
-H "Authorization: Bearer $MFORM_API_KEY"Ответ 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 · Тариф: Business и выше · Инструмент MCP: не доступна через MCP
Re-enabling an endpoint disabled after failures resets its failure counter.
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
endpoint_id | path | we_… id | да |
Тело (JSON)
| Имя | Тип | Обязательный | Описание |
|---|---|---|---|
url | string (uri) | нет | |
description | string | нет | |
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"[] | нет | |
form_ids | form_… id[] | null | нет | |
include_personal_data | boolean | нет | |
status | "enabled" | "disabled" | нет |
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"}'Ответ 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 · Тариф: Business и выше · Инструмент MCP: не доступна через MCP
Pending deliveries are cancelled. Endpoints are configuration, not customer data, so they can be deleted.
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
endpoint_id | path | we_… id | да |
curl -X DELETE https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX \
-H "Authorization: Bearer $MFORM_API_KEY"Ответ 200
{
"id": "example",
"object": "example",
"deleted": true
}post/webhook_endpoints/{endpoint_id}/rotate_secret
Rotate the signing secret rotateWebhookSecret
Scope: webhooks:manage · Тариф: Business и выше · Инструмент MCP: не доступна через MCP · поддерживает 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.
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
endpoint_id | path | we_… id | да |
Тело (JSON)
| Имя | Тип | Обязательный | Описание |
|---|---|---|---|
expire_previous_in_hours | integer | нет |
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 '{}'Ответ 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 · Тариф: Business и выше · Инструмент MCP: не доступна через MCP · поддерживает Idempotency-Key
Sends a signed `webhook.test` event now and returns the delivery. 10 per minute.
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
endpoint_id | path | we_… id | да |
curl -X POST https://mform.md/api/public/v1/webhook_endpoints/we_8Hq2LmZ71cX/test \
-H "Authorization: Bearer $MFORM_API_KEY" \
-H "Idempotency-Key: $(uuidgen)"Ответ 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 · Тариф: Business и выше · Инструмент MCP: не доступна через MCP
Newest first. The receiver's response body is never stored or returned.
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
endpoint_id | path | we_… id | да | |
limit | query | integer | нет | Page size, 1–100. |
cursor | query | string | нет | The `next_cursor` of the previous page. Bound to the same filters and the same key's workspace. |
status | query | "pending" | "succeeded" | "failed" | "abandoned" | нет | 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"Ответ 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 · Тариф: Business и выше · Инструмент MCP: не доступна через MCP · поддерживает Idempotency-Key
Re-sends the same event (same `id`, fresh signature). Receivers must de-duplicate on the event `id`.
Параметры
| Имя | Где | Тип | Обязательный | Описание |
|---|---|---|---|---|
endpoint_id | path | we_… id | да | |
delivery_id | path | wd_… id | да |
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)"Ответ 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"
}