Charles Pereira
04/20/2026, 8:38 PMMarvin
04/20/2026, 8:38 PMMarvin
04/20/2026, 8:43 PMblock_document_id with your notification block’s UUID.
name: "Notify on flw-A failure"
description: "Send a notification when flow 'flw-A' fails"
enabled: true
trigger:
type: "event"
posture: "Reactive"
expect:
- "prefect.flow-run.Failed"
match: {}
match_related:
prefect.resource.role: "flow"
prefect.resource.name: "flw-A"
threshold: 1
actions:
- type: "send-notification"
block_document_id: "REPLACE_WITH_BLOCK_UUID"
subject: "Flow failed: {{ flow.name }} (run {{ flow_run.name }})"
body: |
Flow '{{ flow.name }}' run {{ flow_run.name }} has failed.
State: {{ flow_run.state.name }}
Message: {{ flow_run.state.message }}
View: {{ flow_run|ui_url }}
Apply it with:
prefect automation create -f automation.yaml
Helpful docs:
- Automations concepts
- Creating automationsCharles Pereira
04/20/2026, 8:46 PMCharles Pereira
04/20/2026, 8:46 PMCharles Pereira
04/20/2026, 8:46 PMMarvin
04/20/2026, 8:46 PMMarvin
04/20/2026, 8:49 PMname: "Email on flw-A failure via webhook"
description: "Send an email when flow 'flw-A' fails using a generic email API"
enabled: true
trigger:
type: "event"
posture: "Reactive"
expect:
- "prefect.flow-run.Failed"
match: {}
match_related:
prefect.resource.role: "flow"
prefect.resource.name: "flw-A"
threshold: 1
actions:
- type: "call-webhook"
block_document_id: "REPLACE_WITH_WEBHOOK_BLOCK_UUID"
payload: |
{
"to": "<mailto:alerts@example.com|alerts@example.com>",
"from": "<mailto:prefect@example.com|prefect@example.com>",
"subject": "Flow failed: {{ flow.name }} (run {{ flow_run.name }})",
"text": "Flow '{{ flow.name }}' run {{ flow_run.name }} has failed.\nState: {{ flow_run.state.name }}\nMessage: {{ flow_run.state.message }}\nView: {{ flow_run|ui_url }}"
}
How to apply:
- Create a Webhook block pointing at your email API endpoint (e.g., Mailgun/SendGrid HTTP API) with necessary headers and method. Then copy its block_document_id.
- Apply the automation:
prefect automation create -f automation.yaml
If you’re open to using a notification block (the simplest path for email), create a “SendGrid Email” notification block with your recipients and use send-notification instead.
Docs:
- Automations concepts
- Custom notifications (webhooks, templating)
If you tell me which email provider you use (SendGrid, Mailgun, SES, etc.), I can provide the exact Webhook block config and payload format.Charles Pereira
04/20/2026, 8:57 PMMarvin
04/20/2026, 8:57 PMCharles Pereira
04/20/2026, 8:58 PMMarvin
04/20/2026, 8:58 PMprefect block ls
prefect block inspect sendgrid-email/<your-block-name>
3) Use it in your automation YAML:
name: "Email on flw-A failure"
description: "Send an email when flow 'flw-A' fails"
enabled: true
trigger:
type: "event"
posture: "Reactive"
expect:
- "prefect.flow-run.Failed"
match: {}
match_related:
prefect.resource.role: "flow"
prefect.resource.name: "flw-A"
threshold: 1
actions:
- type: "send-notification"
block_document_id: "REPLACE_WITH_SENDGRID_BLOCK_UUID"
subject: "Flow failed: {{ flow.name }} (run {{ flow_run.name }})"
body: |
Flow '{{ flow.name }}' run {{ flow_run.name }} has failed.
State: {{ flow_run.state.name }}
Message: {{ flow_run.state.message }}
View: {{ flow_run|ui_url }}
Apply it:
prefect automation create -f automation.yaml
Docs:
- Automations concepts
- Custom notificationsCharles Pereira
04/20/2026, 8:59 PMMarvin
04/20/2026, 9:00 PMMarvin
04/20/2026, 9:00 PMname: "Email on flw-A failure"
description: "Send an email when flow 'flw-A' fails"
enabled: true
trigger:
type: "event"
posture: "Reactive"
expect:
- "prefect.flow-run.Failed"
match: {}
match_related:
prefect.resource.role: "flow"
prefect.resource.name: "flw-A"
threshold: 1
actions:
- type: "send-notification"
block_document_id: "REPLACE_WITH_SENDGRID_BLOCK_UUID"
subject: "Flow failed: {{ flow.name }} (run {{ flow_run.name }})"
body: |
Flow '{{ flow.name }}' run {{ flow_run.name }} has failed.
State: {{ flow_run.state.name }}
Message: {{ flow_run.state.message }}
View: {{ flow_run|ui_url }}
To set up the block:
- Create a SendGrid Email block (set sender_email, to_emails, api_key) in the UI, then copy its ID.
- Apply the automation:
prefect automation create -f automation.yaml
References:
- Automations concepts
- Creating automations
- Custom notifications
If avoiding blocks entirely is a hard requirement, Prefect’s automations can’t send email directly. The only other automation-based route is a call-webhook action to an email API (which you said you don’t want). If you’d like, I can help you set up the SendGrid block quickly or suggest an in-flow notification pattern instead.