# Webhooks

Source: https://modulify.ai/docs/automations/webhooks

Get an HTTP call at your own endpoint every time this site publishes.

A webhook is the opposite of a cron. Instead of Modulify calling your URL on a clock, it calls your URL when something happens to the site. Today that something is publishing.

Webhooks belong to a project. Any member of the workspace that owns the project with the Editor [role on the site](https://modulify.ai/docs/editor/settings#member-access) can add, test and delete them, while revealing, copying and rotating a signing secret need the **Delete projects** permission.

## Before you begin

The endpoint has to be public and use `https`. A private address or a `http` URL is rejected when you save.

Your endpoint has to answer with a status in the 200 to 299 range within **5 seconds**. A redirect counts as a failure: the delivery records "Endpoint attempted a redirect, which is not allowed."

## Open the Webhooks tab

Click **More** in the tab strip, then **Webhooks**. The address ends in `/webhooks`.

Four tabs sit under the heading:

- **Webhooks**, the endpoints on this site
- **Insights**, the counts and a chart for the period you pick
- **Deliveries**, every attempt and what came back
- **Settings**, export and the danger zone

An empty site shows **No webhooks** with the line "Send publish updates to external services."

A site can hold **10 webhooks**. At the limit the **Add webhook** button is disabled and a warning tells you to remove one to add another, or to contact support to request a higher limit. The **contact support** link in the warning opens the [support chat](https://modulify.ai/docs/reference/support-chat), or the contact page when the chat is not available.

## Add a webhook

Click **Add webhook**. The form has four fields.

**Name** is how the list and the delivery log refer to this endpoint, up to 64 characters.

**Endpoint URL** is where the request goes, up to 2,048 characters.

**Payload format** is one of **Raw JSON**, **Slack**, **Discord** or **Ping**. Raw JSON is the default and the one to use for your own server.

**Events** is a set of checkboxes. At least one has to be ticked. **Publish succeeded** is ticked for you.

The button reads **Add webhook**, and **Save changes** when you are editing an existing one.

## The events

| Event | When it fires |
|---|---|
| `publish.succeeded` | A publish finished and the site is live |
| `publish.failed` | A publish stopped with an error |
| `publish.cancelled` | Someone stopped a publish that was running |
| `payment.succeeded` | A visitor's payment on the site went through |
| `payment.refunded` | A payment on the site was refunded, in full or in part |
| `payment.disputed` | A visitor opened a dispute on a payment on the site |

A webhook only receives the events it is subscribed to, and only while its switch is on.

The three payment events only show in the **Webhooks** tab on a site that has [Payments](https://modulify.ai/docs/built-in/payments), which are in alpha.

## The payload

A **Raw JSON** webhook receives a `POST` with `Content-Type: application/json` and this body.

```json
{
    "schemaVersion": "1.0",
    "event": "publish.succeeded",
    "success": true,
    "deliveryId": "0f2a6c1e-4f6b-4a2f-9b41-2b0f0a8c9d33",
    "timestamp": "2026-08-25T09:14:02.881Z",
    "environment": "production",
    "trigger": "manual",
    "test": false,
    "project": {
        "id": "665f1c9a4d2b8e0012ab34cd",
        "name": "Pottery Studio",
        "slug": "pottery-studio",
        "url": "https://pottery.example.com",
        "subdomain": "pottery-studio",
        "subdomainUrl": "https://pottery-studio.modulify.website",
        "customDomain": "pottery.example.com",
        "customDomainUrl": "https://pottery.example.com",
        "domains": [
            "pottery.example.com",
            "pottery-studio.com",
            "www.pottery-studio.com"
        ]
    },
    "deployment": {
        "id": "665f1d114d2b8e0012ab3501",
        "buildId": "k3f9xq1a",
        "status": "ready",
        "startedAt": "2026-08-25T09:12:40.102Z",
        "finishedAt": "2026-08-25T09:14:02.640Z"
    },
    "publishedBy": {
        "id": "6650aa3e4d2b8e0012ab1122",
        "name": "Ana"
    },
    "dashboardUrl": "https://modulify.ai/dashboard/projects/pottery-studio",
    "error": null
}
```

`success` is true only for `publish.succeeded` and `payment.succeeded`. `trigger` is `manual` when a person started the publish, `deploy-hook` when a [deploy hook](https://modulify.ai/docs/automations/deploy-hooks) started it, and `system` when the platform finalised it. A publish started by calling a hook's URL has no person behind it, so its `publishedBy` is `null`. `project.customDomain` is the site's [primary domain](https://modulify.ai/docs/publish/custom-domains#the-primary-domain): the first custom domain, in the order you added them, that is connected, else the first connected www variant, or `null` while none is connected, and `project.customDomainUrl` is its address. `project.domains` lists every connected custom domain, www variants included, with the primary first, and is empty while none is connected. `project.url` is the primary domain's address when there is one, otherwise the Modulify subdomain. `deployment` and `publishedBy` are `null` when there is nothing to report, and `error` carries the failure reason on `publish.failed`.

### Payment events

The three payment events describe a payment a visitor made on a site that takes payments. Payments are in alpha and open on a few sites, so only those sites send them. They carry a `payment` object in place of a publish. `deployment` and `publishedBy` are `null` for them, and `project` is the same as for a publish.

- `id` is the Stripe payment ID.
- `status` is `paid` or `failed`.
- `amountCents` is what the visitor was charged, and `amountRefundedCents` is the total refunded so far. Both are in the currency's smallest unit.
- `currency` is an upper case code, for example `USD`.
- `disputed` is `true` once a dispute has been opened on the payment.
- `livemode` is `false` for a test payment.
- `reference` is the reference the site sent when it created the checkout, or `null`.

A payment event fires once for each change. `payment.succeeded` fires when a payment first goes through, `payment.refunded` when the refunded amount goes up, and `payment.disputed` when a dispute first opens. A payment that went through never goes back to `failed`, even when an earlier failed attempt is reported late. When Modulify could not hand an event to your webhooks, it sends it again later, so the same event can reach you twice: make the code that handles it do nothing on a repeat. A payment older than the time it shows in the payments list, 1 year, sends no more events.

A payment event carries no buyer details. Keep the buyer's name, email and address with the order on your site, and find the order from `reference`. [Payments](https://modulify.ai/docs/built-in/payments#payment-links-from-your-sites-code) shows the whole flow.

### The other formats

**Slack** posts `{"text": "..."}` and **Discord** posts `{"content": "..."}`. Both carry the same short message: a title line such as `✅ Publish succeeded: Pottery Studio`, then the site URL, then the error if there was one. A payment event has its own title with the amount, such as `💰 Payment received: $45.00 on Pottery Studio`, `↩️ Payment refunded: $15.00 on Pottery Studio` or `⚠️ Payment disputed: $45.00 on Pottery Studio`, followed by the payment's reference when it has one and `Stripe test mode` for a test payment. A test event prefixes the title with `[Test]`. Point either one at an incoming webhook URL from that service and the message appears in the channel.

**Ping** sends an empty body. Use it when you only care that something happened and your endpoint reads the headers.

## The headers

Every delivery carries these headers.

| Header | Value |
|---|---|
| `X-Modulify-Event` | The event name, for example `publish.succeeded` |
| `X-Modulify-Delivery` | The delivery id, stable across retries of the same delivery |
| `X-Modulify-Attempt` | Which attempt this is, starting at 1 |
| `X-Modulify-Timestamp` | Unix seconds at the moment the request was signed |
| `X-Modulify-Signature` | `sha256=` followed by the hex signature |

`X-Modulify-Delivery` is the field to deduplicate on. A retry reuses it, so seeing the same id twice means the same event, not a new one.

## Verify the signature

Each webhook has its own signing secret, shown in the row as `whsec_` followed by dots. The eye icon reveals it, the copy icon copies it, and the circular arrow rotates it. All three need the **Delete projects** permission, and without it they are disabled with the tooltip "You do not have permission to do this."

The signature is an HMAC SHA-256, in hex, of the timestamp and the raw body joined by a period, keyed with the secret.

```javascript
import { createHmac, timingSafeEqual } from 'crypto'

const Verify = (rawBody, headers, secret) => {
    const timestamp = headers['x-modulify-timestamp']
    const received = headers['x-modulify-signature']

    const expected = 'sha256=' + createHmac('sha256', secret)
        .update(`${timestamp}.${rawBody}`)
        .digest('hex')

    if (received.length !== expected.length) return false

    return timingSafeEqual(Buffer.from(received), Buffer.from(expected))
}
```

Sign the body exactly as it arrived, before any JSON parsing. Rotating the secret invalidates the old one immediately, so update your endpoint straight after you rotate. The circular arrow asks first, **Rotate signing secret?**: "The current secret stops working immediately. Update your endpoint with the new secret afterwards." The toast that follows, **Signing secret rotated**, reminds you to reveal the new secret with the eye icon to copy it.

## Send a test event

Open the three dots menu on a webhook and choose **Send test event**. It delivers a `publish.succeeded` payload for this project with `"test": true`, using the real URL, format and secret. A webhook subscribed only to payment events gets its first payment event instead, with a sample `payment` of 25.00 US dollars, the reference `test-reference` and `livemode` set to `false`, so you can try the code that handles payments without taking one. Make that code skip events whose `test` is `true`, so a sample payment never fulfils an order.

The toast tells you what happened: **Test event delivered** with "Your endpoint accepted the test event." if your endpoint accepted it, or **Test event not accepted** with "Test event sent, but the endpoint did not accept it." if it did not. Either way the attempt appears in the **Deliveries** tab tagged **Test**.

Test deliveries are never retried, and they do not count towards the sent and failed totals on the row or towards the auto-disable threshold.

## Retries and auto-disable

A failed delivery is retried up to **5 attempts** in total, waiting 1 minute before the second attempt, 5 minutes before the third, 30 minutes before the fourth and 120 minutes before each one after that. In the delivery log the states read:

| State | Meaning |
|---|---|
| Pending | Recorded, not yet answered |
| Delivered | The endpoint accepted it |
| Retrying | This attempt failed and another is scheduled |
| Failed | Every attempt was used up |

Retries stop if you turn the webhook off in the meantime.

A delivery only counts as a failure once all 5 attempts are used up. After **20 such failures in a row** the webhook disables itself and the row reads "Auto-disabled after repeated delivery failures." in amber. A successful delivery resets the count. Flip the switch back on once your endpoint is healthy.

## Read the insights

The **Insights** tab reads "Every delivery to this site's webhooks." Next to the heading sits the date picker the **Analytics** tab uses: **Today** (from midnight UTC), **Last day** (the default, the last 24 hours), **Last week**, **Last month**, **Last 3 months**, **Last year**, **All time** or **Custom range**. The cards and the chart follow the period you pick, and so does the **Deliveries** tab.

Four cards count the chosen period across every webhook on the site: **Deliveries**, **Delivered**, **In progress** and **Failed**. **In progress** is a delivery that is still pending or still being retried, and **Failed** is one that used up its attempts. Test deliveries count like any other. Under the cards, the **Deliveries over time** chart covers the same period, split into delivered, in progress and failed. It draws one bar per hour for **Today**, **Last day** and a custom range of a single day, one per day for **Last week**, **Last month**, **Last 3 months** and custom ranges up to 92 days, and one per month for anything longer. Hovering a bar shows the time and the three counts. Time is counted in UTC.

The tab keeps itself up to date while it is open, checking again every 15 seconds, so new deliveries show up without reloading the page. It pauses while the browser tab is in the background.

With nothing logged in the period the chart shows **No deliveries**, "Counts appear once a webhook fires." If the counts cannot be read the four cards show a dash and the chart shows **Could not load chart**, "Check your connection and try again.", with a **Try again** button. A delivery removed from the log drops out of the counts too.

## Read the delivery log

The **Deliveries** tab lists attempts newest first: the state, the event name, the response status, the endpoint name, the error if there was one, how long ago it happened and the duration in milliseconds.

The date picker from **Insights** comes first and keeps only the attempts in that period, starting at **Last day**. Three dropdowns filter it further: by endpoint (**All webhooks**), by event (**All events**, the three publish events, the three payment events on a site with [Payments](https://modulify.ai/docs/built-in/payments), or **Test events**) and by order (**Newest first**, **Oldest first**). The list shows 30 attempts a page, with page numbers under it once there is more than one page. The page you are on is part of the address, such as `?page=3`, so a refresh, the back button and a shared link keep it, and the page numbers are links, so cmd-click opens a page in a new tab. A link past the last page opens the last one. Changing the period or any of the three dropdowns goes back to the first page. With nothing in the period the list shows **No deliveries**, `Pick a longer period to see more.`, and with **All time** picked it reads "Delivery attempts appear here."

The list keeps itself up to date while it is open, checking the page you are on again every 15 seconds, so new attempts and finished retries show up without reloading the page. It pauses while the browser tab is in the background.

Hovering a row reveals a small trash icon that removes that single attempt from the log. It asks first, **Remove this delivery?**: "It disappears from the delivery log. The webhook itself is untouched and keeps firing on publish."

Deliveries are kept until you remove them or clear the log. A removed or cleared attempt leaves the log at once, and Modulify keeps it, hidden.

## What the row tells you

Back on the **Webhooks** tab, each row shows the format badge, the endpoint URL as a link, one chip per subscribed event, a count of how many deliveries were sent, a count of how many failed, and when the last delivery landed with a green or red dot.

The switch pauses the endpoint without deleting it. The three dots menu holds **Edit**, **Send test event** and **Delete**. Deleting asks you to confirm, and the dialog explains that the endpoint will no longer receive publish events.

## Export and clear

The **Settings** tab holds three things.

**Export webhooks** downloads every webhook on the site as JSON, including its URL and events. Signing secrets are never included.

**Clear delivery log** reads "Remove every recorded attempt from the Deliveries tab. Your webhooks keep firing on publish." Its **Clear log** button asks **Clear the delivery log?** with "Every recorded delivery attempt for this site is removed from the log. Your webhooks keep firing on publish." The toast reads **Delivery log cleared** with a count, such as `Cleared 3 deliveries from the log.`, or **Nothing to clear** when the log was already empty.

**Delete all webhooks** reads "Permanently delete every webhook on this site and its delivery log. Nothing will be notified when this site publishes afterwards." Its **Delete all webhooks** button asks **Delete every webhook?** with "This permanently deletes every webhook on this site along with its delivery log, and cannot be undone. Nothing will be notified when this site publishes afterwards." The toast reads **Webhooks deleted**, or **Nothing to delete** when the site had none.

Both danger zone buttons are disabled unless your workspace role holds the **Delete projects** permission, with the tooltip "You do not have permission to do this.", and both ask you to confirm first.

## What the AI can do

The AI in the editor chat can list your webhook endpoints, their recent delivery attempts and the delivery counts for the last 30 days when you ask about them. It counts the deliveries over any other period you name too, and pages further back through the delivery log for one endpoint or one event. So "did my webhook fire?", "why is this endpoint failing?", "why did Modulify turn it off?" and "how many fired last week?" are questions it can answer from the same records this tab shows you.

It changes them too when you ask. It adds an endpoint with the events and payload format you want, edits one, turns one on or off, sends a test, deletes one, removes a single attempt from the delivery log and clears the log, with the same limits and checks as this tab. It asks you first before deleting an endpoint, removing an attempt or clearing the delivery log. Treat the URL you give it like a password: chat never repeats it back in full.

It can also delete every webhook at once, after you confirm, with the same **Delete projects** permission as the Settings tab. It is never handed a signing secret. It rotates one after asking you first. To see a secret or export the webhooks, it shows you a card that reveals the secret or downloads the file, and the secret never passes through chat, see [Keys, exports and account changes from chat](https://modulify.ai/docs/build/site-chat#keys-exports-and-account-changes-from-chat).

Chat reads and changes [scheduled jobs](https://modulify.ai/docs/automations/scheduled-jobs) and [deploy hooks](https://modulify.ai/docs/automations/deploy-hooks) in the same way.

## From an AI client over MCP

Everything on this page is reachable from a connected AI client through 14 tools:

- `list_site_webhooks`, `list_webhook_deliveries`, `get_webhook_delivery_stats` and `export_site_webhooks` read the endpoints, the log and the counts over time, and need `config:read`
- `create_site_webhook`, `update_site_webhook`, `toggle_site_webhook`, `test_site_webhook`, `delete_site_webhook`, `delete_all_site_webhooks`, `delete_webhook_delivery` and `clear_webhook_deliveries` change them, and need `config:write`
- `get_site_webhook_secret` and `rotate_site_webhook_secret` read and replace the signing secret in plain text, and need `credentials:reveal` and the **Delete projects** permission

`config:write` and `credentials:reveal` are unticked by default. See [MCP tools](https://modulify.ai/docs/mcp/tools#webhooks).

## Next

- [Scheduled jobs](https://modulify.ai/docs/automations/scheduled-jobs) call your URL on a clock instead of on an event.
- [Publish a site](https://modulify.ai/docs/publish/publish-a-site) is the action that fires these events.
- [Publish history](https://modulify.ai/docs/publish/publish-history) is the same record kept inside Modulify.
- [Deploy hooks](https://modulify.ai/docs/automations/deploy-hooks) go the other way: your systems call Modulify to start a publish.