---
title: "Webhooks"
description: "With webhooks, you can receive real-time HTTP notifications when specific objects change in your Formbricks environment. This allows you to stay updated and trigger automated actions based on these events."
icon: "webhook"
---

### **Webhook Triggers**

Webhooks are configured to send notifications based on trigger events. The available triggers include:

- **`responseCreated`**

- **`responseUpdated`**

- **`responseFinished`**

---

## **Creating Webhooks**

You can create webhooks either through the **Formbricks App UI** or programmatically via the **Webhook API**.

## **Creating Webhooks via UI**

- **Log in to Formbricks**
  and click on the `Configuration` tab in the left sidebar and then click on the `Integrations` tab.

![Step one](/images/platform/features/integrations/webhooks/integrations-tab.webp)

- Click on **Manage Webhooks** & then **Add Webhook** button:

![Step two](https://res.cloudinary.com/dwdb9tvii/image/upload/v1738094259/j4a92z2q43twgamogpny.webp)

- Add your webhook listener endpoint and test it to make sure the endpoint is reachable and accepts `POST`
  requests.

![Step three](https://res.cloudinary.com/dwdb9tvii/image/upload/v1738094617/image_kubsnz.jpg)

- Now add the triggers you want to listen to and the surveys!

- That’s it! Your webhooks will now start receiving data as soon as it arrives!

![Step five](https://res.cloudinary.com/dwdb9tvii/image/upload/v1738094816/image_xvrel1.jpg)

## **Creating Webhooks via API**

Use our documented methods on the **Creation**, **List**, and **Deletion** endpoints of the Webhook API mentioned in our [API v2 playground](https://formbricks.com/docs/api-v2-reference/management-api-%3E-webhooks/get-webhooks).

## Testing Webhooks Locally

If you want to test a webhook consumer running on your machine before deploying it, you can expose your local
endpoint with [ngrok](https://ngrok.com/docs/universal-gateway/http).

<Steps>
  <Step title="Start your local webhook listener">
    Run your local endpoint on a port like `3000`.
  </Step>
  <Step title="Expose it with ngrok">
    Create a public HTTPS URL for your local service, for example with `ngrok http http://localhost:3000`.
  </Step>

  <Step title="Use the public URL in Formbricks">
    Paste the ngrok URL into your webhook endpoint, click **Test Endpoint**, and then save the webhook once the
    endpoint is reachable.
  </Step>
</Steps>

<Note>
  To avoid sending unwanted test responses to production workflows, create a separate test survey in your
  Workspace and use that survey copy in your development workflow while validating the webhook setup.
</Note>

### Allowing Internal URLs (Self-Hosted Only)

By default, Formbricks blocks webhook URLs that point to private or internal IP addresses (e.g. `localhost`, `192.168.x.x`, `10.x.x.x`) to prevent [SSRF attacks](https://owasp.org/www-community/attacks/Server-Side_Request_Forgery). If you are self-hosting Formbricks and need to send webhooks to internal services, you can set the following environment variable:

```sh
DANGEROUSLY_ALLOW_WEBHOOK_INTERNAL_URLS=1
```

This switch applies to the Webhooks integration only. Workflow HTTP request steps have their own,
`DANGEROUSLY_ALLOW_WORKFLOW_INTERNAL_URLS`.

<Warning>
  Only enable this on trusted, self-hosted environments. Enabling this on a publicly accessible instance exposes your server to SSRF risks.
</Warning>

If you encounter any issues or need help setting up webhooks, feel free to reach out to us on [GitHub Discussions](https://github.com/formbricks/formbricks/discussions). 😃

---

## Delivery and Retries

Formbricks delivers webhooks asynchronously from a background job runner, one delivery per webhook and event,
so a slow or unavailable receiver never delays other webhooks or the rest of response processing.

- A delivery counts as successful when your endpoint answers with any `2xx` status within the delivery timeout
  (5 seconds by default; self-hosters can change it with `WEBHOOK_DELIVERY_TIMEOUT_MS`).
- Network errors, timeouts, redirects, and `408`, `429` or `5xx` responses are **attempted up to 5 times** with an
  exponential backoff starting at 30 seconds — roughly 30 seconds, then 1, 2 and 4 minutes after the first
  attempt. After the last attempt the event is dropped; Formbricks does not replay exhausted deliveries.
- Any other `4xx` response is treated as a rejection of the request and is **not** retried. Respond with `2xx`
  as soon as you have durably accepted the event, and do your own processing afterwards.
- Every attempt of the same event carries the same `webhook-id` header, so you can safely deduplicate
  retries on your side.
- Deleting a webhook, or removing a trigger or survey from it, also cancels deliveries that are still queued or
  retrying for it.

## Webhook Security with Standard Webhooks

Formbricks implements the [Standard Webhooks](https://github.com/standard-webhooks/standard-webhooks) specification to ensure webhook requests can be verified as genuinely originating from Formbricks.

### Webhook Headers

Every webhook request includes the following headers:

| Header              | Description                                          | Example                                |
| ------------------- | ---------------------------------------------------- | -------------------------------------- |
| `webhook-id`        | Unique message identifier                            | `019ba292-c1f6-7618-aaf2-ecf8e39d1cc7` |
| `webhook-timestamp` | Unix timestamp (seconds) when the webhook was sent   | `1704547200`                           |
| `webhook-signature` | HMAC-SHA256 signature (only if secret is configured) | `v1,K3Q2bXlzZWNyZXQ=`                  |

### Signing Secret

When you create a webhook (via the UI or API), Formbricks automatically generates a unique signing secret for that webhook. The secret follows the Standard Webhooks format: `whsec_` followed by a base64-encoded random value.

**Via UI:** After creating a webhook, the signing secret is displayed immediately. Copy and store it securely—you can also view it later in the webhook settings.

**Via API:** The signing secret is returned in the webhook creation response.

This secret is used to generate the HMAC signature included in each webhook request, allowing you to verify the authenticity of incoming webhooks.

### Signature Verification

The signature is computed as follows:

```
signed_content = "{webhook-id}.{webhook-timestamp}.{body}"
signature = base64(HMAC-SHA256(secret, signed_content))
header_value = "v1,{signature}"
```

### Validating Webhooks

To validate incoming webhook requests:

1. Extract the `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers
2. Verify the timestamp is within an acceptable tolerance (e.g., 5 minutes) to prevent replay attacks
3. Decode the secret by stripping the `whsec_` prefix and base64 decoding the rest
4. Compute the expected signature using HMAC-SHA256 with the decoded secret
5. Compare your computed signature with the received signature (after stripping the `v1,` prefix)

### Node.js Verification Functions

```javascript
const crypto = require("crypto");

const WEBHOOK_TOLERANCE_IN_SECONDS = 300; // 5 minutes

/**
 * Decodes a Formbricks webhook secret (whsec_...) to raw bytes
 */
function decodeSecret(secret) {
  const base64 = secret.startsWith("whsec_") ? secret.slice(6) : secret;
  return Buffer.from(base64, "base64");
}

/**
 * Verifies the webhook timestamp is within tolerance
 * @throws {Error} if timestamp is too old or too new
 */
function verifyTimestamp(timestampHeader) {
  const now = Math.floor(Date.now() / 1000);
  const timestamp = parseInt(timestampHeader, 10);

  if (isNaN(timestamp)) {
    throw new Error("Invalid timestamp");
  }

  if (Math.abs(now - timestamp) > WEBHOOK_TOLERANCE_IN_SECONDS) {
    throw new Error("Timestamp outside tolerance window");
  }

  return timestamp;
}

/**
 * Computes the expected signature for a webhook payload
 */
function computeSignature(webhookId, timestamp, body, secret) {
  const signedContent = `${webhookId}.${timestamp}.${body}`;
  const secretBytes = decodeSecret(secret);
  return crypto.createHmac("sha256", secretBytes).update(signedContent).digest("base64");
}

/**
 * Verifies a Formbricks webhook request
 * @param {string} body - Raw request body as string
 * @param {object} headers - Object containing webhook-id, webhook-timestamp, webhook-signature
 * @param {string} secret - Your webhook secret (whsec_...)
 * @returns {boolean} true if valid
 * @throws {Error} if verification fails
 */
function verifyWebhook(body, headers, secret) {
  const webhookId = headers["webhook-id"];
  const webhookTimestamp = headers["webhook-timestamp"];
  const webhookSignature = headers["webhook-signature"];

  if (!webhookId || !webhookTimestamp || !webhookSignature) {
    throw new Error("Missing required webhook headers");
  }

  // Verify timestamp
  const timestamp = verifyTimestamp(webhookTimestamp);

  // Compute expected signature
  const expectedSignature = computeSignature(webhookId, timestamp, body, secret);

  // Extract signature from header (format: "v1,{signature}")
  const receivedSignature = webhookSignature.split(",")[1];

  if (!receivedSignature) {
    throw new Error("Invalid signature format");
  }

  // Use constant-time comparison to prevent timing attacks
  const expectedBuffer = Buffer.from(expectedSignature, "utf8");
  const receivedBuffer = Buffer.from(receivedSignature, "utf8");

  if (
    expectedBuffer.length !== receivedBuffer.length ||
    !crypto.timingSafeEqual(expectedBuffer, receivedBuffer)
  ) {
    throw new Error("Invalid signature");
  }

  return true;
}

module.exports = { verifyWebhook, decodeSecret, computeSignature, verifyTimestamp };
```

**Usage:**

```javascript
// In your webhook handler, use the raw body (not parsed JSON)
try {
  verifyWebhook(rawBody, req.headers, process.env.FORMBRICKS_WEBHOOK_SECRET);
  const payload = JSON.parse(rawBody);
  // Process verified webhook...
} catch (error) {
  // Verification failed - reject the request
  console.error("Webhook verification failed:", error.message);
}
```

<Note>
  Always use the **raw request body** (as a string) for signature verification, not the parsed JSON object.
  Parsing and re-stringifying can change the formatting and break signature validation.
</Note>

### Using Standard Webhooks Libraries

You can also use the official [Standard Webhooks libraries](https://github.com/standard-webhooks/standard-webhooks#libraries) available for various languages:

- **Node.js**: `npm install standardwebhooks`
- **Python**: `pip install standardwebhooks`
- **Go, Ruby, Java, Kotlin, PHP, Rust**: See the [Standard Webhooks GitHub](https://github.com/standard-webhooks/standard-webhooks)

---

## Reading answers by question code

Every response payload carries the answers twice, inside the response object (`data` of the request body):

- `data.data` holds the answers keyed by **Question ID**, as before. Existing receivers keep working.
- `data.dataByQuestionCode` holds the same answers keyed by **question code**, such as `visit_reason`. Codes are readable, you choose them in the survey editor, and they do not change once the survey is active.

Every question that has a question code is listed. A question the respondent has not answered yet has the value `null`, so the keys are the same in all three events. Cards that are not questions, such as the welcome card, and hidden fields stay in `data.data` only. Hidden fields and variables keep their own names.

Tools such as Make only show the first level of the response object, so `dataByQuestionCode` gives them readable keys without digging into `data`.

Two more keys are new in the response object:

- `dataByQuestionCode`: the answers by question code, as above.
- `outcome`: `null` for a normal response, or `"lowQuality"` when a reviewer marked the response as Low quality. Marking or restoring a response sends a `responseUpdated` event. Webhooks keep sending Low quality responses, so filter on `outcome` in your receiver if you want to skip them.

<Warning>
  Both keys are additive. If your receiver validates the payload against a strict schema, allow unknown keys, or add `dataByQuestionCode` and `outcome` to the schema. A webhook that was queued before an update can arrive without `dataByQuestionCode`.
</Warning>

`data.variables` holds the calculated fields. A text field's value is a string and a number field's is a number. A true/false field's value is a JSON boolean, `true` or `false`, so a receiver that validates `variables` against a strict schema must allow booleans.

<Note>
  Zapier, Make, n8n and Activepieces show the fields of the last sample they received. After you update Formbricks or add questions, re-test the trigger to see the new fields.
</Note>

## Cal.com booking details

The answer to a [Schedule a meeting](/surveys/question-type/schedule-a-meeting) question stays the string `booked` in `data.data` and `data.dataByQuestionCode`. When the respondent booked, the response object also carries `calBookingsByQuestionId`, keyed by **Question ID**, with the details Cal.com reported:

```json
"calBookingsByQuestionId": {
  "cm9k2v7q00004": {
    "status": "booked",
    "startTime": "2026-11-05T10:00:00.000Z",
    "endTime": "2026-11-05T10:30:00.000Z",
    "title": "Intro call between Alex and Sam",
    "uid": "mWd8k2xYpQ",
    "videoCallUrl": "https://app.cal.com/video/mWd8k2xYpQ"
  }
}
```

The key is only there when the response holds a booking, so no other webhook changes. It is additive: if your receiver validates the payload against a strict schema, allow unknown keys. The details are reported by the respondent's browser and are not verified.

## Example Webhook Payloads

We provide the following webhook payloads, `responseCreated`, `responseUpdated`, and `responseFinished`.

In these examples the question IDs (`cm9k2v7q00003`) are generated, and the questions carry the question codes `visit_reason` and `newsletter_consent`. The welcome card is not a question, so it has an answer under `data` but no entry in `dataByQuestionCode`. See [Reading answers by question code](#reading-answers-by-question-code).

### Response Created

Example of Response Created webhook payload:

```json
{
  "data": {
    "contact": null,
    "contactAttributes": null,
    "createdAt": "2025-07-24T07:47:29.507Z",
    "data": {
      "welcome_card_cta": "clicked"
    },
    "dataByQuestionCode": {
      "newsletter_consent": null,
      "visit_reason": null
    },
    "displayId": "displayId",
    "endingId": null,
    "finished": false,
    "id": "responseId",
    "language": "en",
    "meta": {
      "country": "DE",
      "url": "https://app.formbricks.com/s/surveyId",
      "userAgent": {
        "browser": "Chrome",
        "device": "desktop",
        "os": "macOS"
      }
    },
    "outcome": null,
    "singleUseId": null,
    "survey": {
      "createdAt": "2025-07-20T10:30:00.000Z",
      "status": "inProgress",
      "title": "Customer Satisfaction Survey",
      "type": "link",
      "updatedAt": "2025-07-24T07:45:00.000Z"
    },
    "surveyId": "surveyId",
    "tags": [],
    "ttc": {
      "welcome_card_cta": 2154.700000047684
    },
    "updatedAt": "2025-07-24T07:47:29.507Z",
    "variables": {}
  },
  "event": "responseCreated",
  "webhookId": "webhookId"
}
```

### Response Updated

Example of Response Updated webhook payload:

```json
{
  "data": {
    "contact": null,
    "contactAttributes": null,
    "createdAt": "2025-07-24T07:47:29.507Z",
    "data": {
      "cm9k2v7q00003": "Just browsing",
      "welcome_card_cta": "clicked"
    },
    "dataByQuestionCode": {
      "newsletter_consent": null,
      "visit_reason": "Just browsing"
    },
    "displayId": "displayId",
    "endingId": null,
    "finished": false,
    "id": "responseId",
    "language": "en",
    "meta": {
      "country": "DE",
      "url": "https://app.formbricks.com/s/surveyId",
      "userAgent": {
        "browser": "Chrome",
        "device": "desktop",
        "os": "macOS"
      }
    },
    "outcome": null,
    "singleUseId": null,
    "survey": {
      "createdAt": "2025-07-20T10:30:00.000Z",
      "status": "inProgress",
      "title": "Customer Satisfaction Survey",
      "type": "link",
      "updatedAt": "2025-07-24T07:45:00.000Z"
    },
    "surveyId": "surveyId",
    "tags": [],
    "ttc": {
      "cm9k2v7q00003": 3855.799999952316,
      "welcome_card_cta": 2154.700000047684
    },
    "updatedAt": "2025-07-24T07:47:33.696Z",
    "variables": {}
  },
  "event": "responseUpdated",
  "webhookId": "webhookId"
}
```

### Response Finished

Example of Response Finished webhook payload:

```json
{
  "data": {
    "contact": null,
    "contactAttributes": null,
    "createdAt": "2025-07-24T07:47:29.507Z",
    "data": {
      "cm9k2v7q00004": "accepted",
      "cm9k2v7q00003": "Just browsing",
      "welcome_card_cta": "clicked"
    },
    "dataByQuestionCode": {
      "newsletter_consent": "accepted",
      "visit_reason": "Just browsing"
    },
    "displayId": "displayId",
    "endingId": "endingId",
    "finished": true,
    "id": "responseId",
    "language": "en",
    "meta": {
      "country": "DE",
      "url": "https://app.formbricks.com/s/surveyId",
      "userAgent": {
        "browser": "Chrome",
        "device": "desktop",
        "os": "macOS"
      }
    },
    "outcome": null,
    "singleUseId": null,
    "survey": {
      "createdAt": "2025-07-20T10:30:00.000Z",
      "status": "inProgress",
      "title": "Customer Satisfaction Survey",
      "type": "link",
      "updatedAt": "2025-07-24T07:45:00.000Z"
    },
    "surveyId": "surveyId",
    "tags": [],
    "ttc": {
      "_total": 4947.899999035763,
      "cm9k2v7q00004": 2793.199999988079,
      "cm9k2v7q00003": 3855.799999952316,
      "welcome_card_cta": 2154.700000047684
    },
    "updatedAt": "2025-07-24T07:47:56.116Z",
    "variables": {}
  },
  "event": "responseFinished",
  "webhookId": "webhookId"
}
```
