# Prefect webhooks

Prefect webhooks are HTTP requests that a Custom Webhook notification block makes to your endpoint when an automation's notification action fires, or when your code calls `notify()`.

These pages cover requests a Prefect automation sends through a Custom Webhook notification block. To send events into Prefect, see [Prefect Cloud webhooks](https://www.prefect.io/docs/v3/concepts/webhooks). The separate [Call a webhook](https://www.prefect.io/docs/v3/concepts/automations#actions) action uses a different block and isn't covered here.

Agent skill: `npx skills add hookdeck/webhook-skills --skill prefect-webhooks` ([details](https://hookdeck.com/webhooks/prefect/skill))

> Independent reference generated from hookdeck/webhook-registry (commit ff7f882, 20 Nov 2026). [Prefect's official docs](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/notifications.py).

[Overview](https://hookdeck.com/webhooks/prefect) · [MCP events](https://hookdeck.com/webhooks/prefect/mcp-events) · [Verify signatures](https://hookdeck.com/webhooks/prefect/verify) · [Production guide](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts) · [Agent skill](https://hookdeck.com/webhooks/prefect/skill)

## Key facts

| Fact | Value | Source |
|---|---|---|
| Signature header | `None (unsigned)` | [Prefect docs](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/notifications.py) |
| How events are identified | `Not sent: route on a field you add to the template` | [Prefect docs](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/notifications.py) |
| Body format | `SENDER-DEFINED` | [Prefect docs](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/notifications.py) |
| Other headers | `user-agent` | [Prefect docs](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/blocks/notifications.py) |
| Agent skill | `npx skills add hookdeck/webhook-skills --skill prefect-webhooks` | [Agent skill →](https://hookdeck.com/webhooks/prefect/skill) |

[Verify Prefect webhooks](https://hookdeck.com/webhooks/prefect/verify)

## How Prefect webhooks work

An automation pushes to your service when its trigger matches, so you don't have to poll Prefect for run states. Triggers cover flow run state changes, work pool, work queue and deployment status, metric thresholds and custom events, and they can also fire when an expected event doesn't happen. The **Send a notification** action names a saved block and supplies a subject and body written in Jinja, which Prefect renders before the block sends the request.

You write the request. The block sets the method (`POST` by default), URL, query params, headers, cookies and either `json_data` or `form_data`, and substitutes `{{subject}}`, `{{body}}`, `{{name}}` and any key in its `secrets`. Prefect adds only `User-Agent: Prefect Notifications`, so there are no event names, no event header and no version to read. Names such as `prefect.flow-run.Failed` are what triggers match on, and they aren't sent. To tell deliveries apart, put `{{ automation.name }}` or `{{ flow_run.state.name }}` in the automation's message, or give each automation its own block with a fixed field in `json_data`.

## Setting up Prefect webhooks

- Create a **Custom Webhook** block with your endpoint as the **Webhook URL** and your body under **JSON Data**. Add a secret under **Custom Secret Values**, then send it from **Headers**, for example as `X-Prefect-Secret: {{webhook_secret}}`.
- Add a **Send a notification** action to an automation, choose the block and write the subject and body. Without a subject, Prefect uses `Prefect automated notification`.
- To test without an automation, call `CustomWebhookNotificationBlock.load("my-block").notify("test")`, which raises an error on a failed send. `hookdeck listen 3000 prefect --path /webhooks/prefect` gives you a public URL that forwards to your machine.
- Prefect documents no way to resend a notification, so a resend means firing the automation again. Routing through Hookdeck adds replay. On a Prefect source, enter the header name and the secret's real value, not the placeholder.

## Delivery behaviour

- **Timeout:** 10 seconds. by default, and you can change it with the block's `timeout` field. [Guide](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#timeouts)
- **Retries:** not documented. so plan for a lost notification and for a repeat. [Guide](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#retries)
- **After a failure:** an error. for any response outside 2xx, including a redirect, or a timeout. Nothing is sent to your service. [Guide](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#retries)
- **Duplicates:** not documented. and nothing identifies a delivery, so put your own key in the message. [Guide](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#duplicates)

## Known failure modes

1. **A notification can be lost while your endpoint is down.** The block treats any response outside 2xx as an error, and Prefect's docs don't say a failed notification is sent again. Reconcile against the Prefect API, for example by querying recent failed flow runs, so a missed notification is caught. [Plan for failed sends](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#retries)
2. **The request doesn't say what fired it.** Prefect sends no event name, flow run ID or state unless your template includes them, and `{{body}}` is free text by default. Add `{{ flow_run.id }}`, `{{ flow_run.state.name }}` and `{{ automation.name }}` to the automation's message. [Design requests you can route](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#choosing-events)
3. **A flow run variable in the block is rejected.** A Custom Webhook block accepts only `{{subject}}`, `{{body}}`, `{{name}}` and keys in its `secrets`, and raises an error on anything else when it's created. Put Jinja variables such as `{{ flow_run.id }}` in the automation's subject or body instead. [Use the right template](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#choosing-events)
4. **A slow handler counts as a failed notification.** The block allows 10 seconds by default, and a timeout is an error even if your handler finishes the work afterwards. Store the request, respond and do the work from a queue. [Respond in time](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#timeouts)

From [Hookdeck's Prefect guide](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts).

## Prefect webhook best practices

- **[Put the identifiers in the automation's message](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#choosing-events).** The block only accepts `subject`, `body`, `name` and its own secrets as placeholders, so `{{ flow_run.id }}` and similar variables belong in the action's subject or body.
- **[Deduplicate on your own key](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#duplicates).** Prefect adds no delivery ID. Include `{{ automation.name }}` and `{{ event.id }}` in the message, and skip a pair you've already processed.
- **[Respond inside the block's timeout](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#timeouts).** The block allows 10 seconds by default. Store the request, respond and do the work from a queue.
- **[Plan for a lost notification](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#retries).** Prefect's docs don't say a failed notification is sent again, so reconcile against the Prefect API rather than relying on every request arriving.
- **[Keep the secret in `secrets`](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts#other-limits).** Reference it as a placeholder in the header, so it stays out of the block's plain configuration and rotating it is one change.

## In this hub

- [MCP events](https://hookdeck.com/webhooks/prefect/mcp-events): How an agent subscribes to Prefect events as MCP events.
- [Verify signatures](https://hookdeck.com/webhooks/prefect/verify): Signature facts, verification code and common failures.
- [Production guide](https://hookdeck.com/webhooks/prefect/guide-duplicates-ordering-retries-timeouts): Production problems, such as timeouts and retries, and how to handle them.
- [Agent skill](https://hookdeck.com/webhooks/prefect/skill): Install the webhook skill in your coding agent. `npx skills add hookdeck/webhook-skills --skill prefect-webhooks`
---

Not affiliated with Prefect. Facts are compiled from public sources and linked inline. [View as JSON](https://hookdeck.com/webhooks/prefect.json) · [Report a correction](https://hookdeck.com/contact)
