Doug Applegate
11/18/2025, 3:42 PMMarvin
11/18/2025, 3:42 PMMarvin
11/18/2025, 3:47 PMevent.payload (or from event.resource labels if you only need strings)
Here’s a minimal end-to-end example.
1) Webhook: map the POST body into the event
- In the webhook template (Automations -> Webhooks), you have Jinja access to body, headers, and method
- Preserve the full structure by putting the body on the event payload
{
"event": "myapp.webhook.received",
"resource": {
"prefect.resource.id": "myapp/webhook/{{ body.id | default('unknown') }}",
"source": "myapp"
},
"payload": {{ body | tojson }}
}
Notes:
- tojson ensures the payload is valid JSON on the event
- If you only need a few fields as strings, you can also add resource labels like "user": "{{ body.user.name }}", but labels are strings only; use payload for structured data
2) Automation: Run the deployment with parameters from the event
- Create an Automation with an Event Trigger that matches myapp.webhook.received
- Add a RunDeployment action
- In Parameters, switch to JSON and toggle “Use Jinja input”
- Option A: Pass specific fields
{
"__prefect_kind": "jinja",
"user": "{{ event.payload.user.name }}",
"count": "{{ event.payload.count }}",
"source": "{{ event.resource.source }}"
}
- Option B: Pass the entire webhook body as one parameter
{
"__prefect_kind": "jinja",
"payload": {{ event.payload | tojson }}
}
Tip: When passing structured values (dicts/lists), render them with tojson and do not wrap them in quotes so the rendered JSON becomes a real object in your flow’s parameters.
3) Flow parameters
Make sure your flow’s signature matches what you pass:
from prefect import flow, get_run_logger
@flow
def process_webhook(user: str = "", count: int = 0, payload: dict | None = None):
logger = get_run_logger()
<http://logger.info|logger.info>(f"user={user}, count={count}, payload_keys={list((payload or {}).keys())}")
That’s it: POST → Webhook → Event (payload contains the body) → Automation trigger → RunDeployment with Jinja-templated parameters.
Useful docs:
- Webhooks overview: Webhooks concept
- Create a webhook: How to create a webhook
- Use parameters in Jinja templates: Access parameters in templates
- Automations and triggers: Create deployment triggers
- Jinja filters (including tojson): Jinja filters reference
If you share a sample of the webhook body you’re receiving, I can sketch an exact webhook template and parameter block for your deployment.