Slackbot
10/13/2025, 8:34 AMMarvin
10/13/2025, 8:34 AMMarvin
10/13/2025, 8:39 AMfrom prefect.blocks.notifications import CustomWebhookNotificationBlock
# Create or update (overwrite) the block named "my-webhook"
block = CustomWebhookNotificationBlock(
url="<https://example.com/webhook>",
method="POST", # or GET/PUT/PATCH/DELETE
headers={"Content-Type": "application/json"},
json_data={"text": "Hello from Prefect!"},
# params={"key": "value"},
# form_data={"key": "value"},
# cookies={"session": "abc"},
# timeout=10,
)
# Save will create if it doesn't exist, or update if it does when overwrite=True
block.save("my-webhook", overwrite=True)
Notes:
- The block type slug for this class is custom-webhook-notification
, so the full slug is custom-webhook-notification/my-webhook
.
- If you prefer to inspect what you have first:
- List all blocks: prefect block ls
- Inspect a specific block: prefect block inspect custom-webhook-notification/my-webhook
- If your code runs in an async context, use await block.save(...)
. In a normal script, block.save(...)
is fine.
If you’re comfortable sharing: are you on Prefect Cloud or OSS UI? And is the entire form read-only or just some fields? I can tailor the guidance further (e.g., mapping current values, migrating secrets, etc.).