Doug Applegate
10/06/2025, 6:20 PMMarvin
10/06/2025, 6:20 PMMarvin
10/06/2025, 6:24 PM{
"event": "my.webhook.received",
"payload": {{ body }}
}
- Notes:
- Set your sender to POST application/json so Prefect parses it into body.
- You can also cherry-pick fields, e.g. "payload": {"order_id": "{{ body.order_id }}"}
- You can include headers, etc., in other fields if useful: "resource": {"id": "{{ headers['X-Request-ID'] | default('unknown') }}"}
- Docs: Create a webhook and Webhooks concept
B) Create an Automation to run your deployment
- Trigger: When event equals my.webhook.received (or whatever you set in the webhook template).
- Action: Run deployment → pick your deployment → set Parameters using Jinja to reference the event payload.
Example mapping
Suppose your flow expects:
from prefect import flow
@flow
def process_order(order_id: str, customer_email: str | None = None, raw: dict | None = None):
...
And your webhook sends JSON like:
{
"order_id": "A-123",
"customer": {
"email": "<mailto:alice@example.com|alice@example.com>"
}
}
Then in the Automation “Run deployment” Parameters field, enter valid JSON with Jinja templates:
{
"order_id": "{{ event.payload.order_id }}",
"customer_email": "{{ event.payload.customer.email | default('<mailto:unknown@example.com|unknown@example.com>') }}",
"raw": {{ event.payload }}
}
Important tips
- The Parameters field must render to valid JSON.
- Wrap string values in quotes: "id": "{{ event.payload.id }}"
- Do not quote objects/numbers/booleans: "raw": {{ event.payload }}
- For nested fields use dot notation: {{ event.payload.customer.email }}
- Use filters like default(...) to handle missing keys: {{ event.payload.foo | default('N/A') }}
- If you only need a subset of fields, you can construct a smaller object: "raw": {"id": "{{ event.payload.id }}", "ts": "{{ event.occurred }}"}
- You can also reference other event fields, e.g. {{ event.occurred }} or {{ event.resource.id }}, depending on what you set in the webhook template.
Docs you may find helpful
- Create a webhook: https://docs-3.prefect.io/v3/how-to-guides/cloud/create-a-webhook
- Webhooks concept: https://docs-3.prefect.io/v3/concepts/webhooks
- Automations (creating deployment triggers): https://docs-3.prefect.io/v3/how-to-guides/automations/creating-deployment-triggers
Would you like to pass the entire payload as a single parameter (e.g., raw) or map individual fields to specific parameters? If you share a sample payload and your flow’s parameter names, I can give you the exact JSON to paste into the Automation.