New to Kestra?
Use blueprints to kickstart your first workflows.
Send a SendGrid email when a Kestra workflow fails. Automate failure notifications to alert your team of pipeline issues via email in real time.
id: sendgrid-notify-on-failure
namespace: company.team
tasks:
- id: send_email_notification
type: io.kestra.plugin.twilio.sendgrid.SendGridMailExecution
to:
- hello@kestra.io
from: hello@kestra.io
subject: "Kestra Workflow Failure: {{ trigger.executionId }} has failed on {{
taskrun.startDate }}"
sendgridApiKey: "{{ secret('SENDGRID_API_KEY') }}"
executionId: "{{ trigger.executionId }}"
triggers:
- id: on_failure
type: io.kestra.plugin.core.trigger.Flow
conditions:
- type: io.kestra.plugin.core.condition.ExecutionStatus
in:
- FAILED
- WARNING
- type: io.kestra.plugin.core.condition.ExecutionNamespace
namespace: company
comparison: PREFIX
Catch pipeline failures the moment they happen by sending a SendGrid email alert whenever any Kestra workflow in your namespace fails or finishes with a warning. This system flow centralizes failure notifications so your team is paged through email instead of discovering broken data pipelines hours later. It uses a Flow trigger to listen across every execution under a namespace prefix, then delivers a transactional email through the SendGrid API, turning silent execution failures into immediate, actionable alerts.
io.kestra.plugin.core.trigger.Flow trigger named on_failure listens
to executions across your instance.io.kestra.plugin.core.condition.ExecutionStatus
fires only on FAILED or WARNING executions, and
io.kestra.plugin.core.condition.ExecutionNamespace matches the company
namespace with comparison: PREFIX so every nested child namespace is
covered too.send_email_notification task of type
io.kestra.plugin.twilio.sendgrid.SendGridMailExecution sends an email
whose subject embeds {{ trigger.executionId }} and the failure timestamp,
and passes executionId so recipients can jump straight to the failed run.SendGrid sends email, but it has no awareness of your pipeline runs. Kestra closes that gap: the event-driven Flow trigger reacts to execution state in real time, conditions scope alerts to the right namespaces, and the whole setup is declarative YAML you can version and review. You also gain retries, execution lineage, and a single system flow that supersedes scattered per-pipeline notification code.
SENDGRID_API_KEY: your SendGrid API key used to authenticate the send.SENDGRID_API_KEY secret to your Kestra instance.to and from to your verified SendGrid sender and recipients.ExecutionNamespace condition to match your namespace prefix.to array.WARNING only.