<@ULVA73B9P> I would like to know if is possible ...
# marvin-ai
j
@Marvin I would like to know if is possible create personalized blocks of webhooks for prefect self hosted deploy. The webhook feature for OSS is been developed? If the questions before are negative, are there some resource of prefect that I can use to receive external requests and do actions from this?
m
thought for 397.3 seconds
Short answer - Inbound webhooks: In Prefect 3.x today, public inbound webhooks (i.e., URLs you can POST to that trigger actions/automations) are a Prefect Cloud feature, not available in OSS/self-hosted. - “Personalized webhook blocks”: You can create custom Blocks in OSS, but Blocks are for configuration and outbound actions (e.g., sending a webhook), not for receiving inbound HTTP requests. - Alternatives in OSS: Yes—there are solid patterns to receive external requests and trigger flows using the Prefect REST API or Python client. Details and options 1) Creating custom “webhook” blocks in OSS - You can build and register your own Blocks in OSS (including ones that send webhooks). - Prefect includes outbound webhook blocks you can use or copy as a starting point: -
prefect.blocks.webhook.Webhook
(stores URL, headers, method, etc.) -
prefect.blocks.notifications.CustomWebhookNotificationBlock
(send notifications to arbitrary webhook endpoints) - Register your custom block types so they appear in the UI:
Copy code
prefect block register -m your_package.blocks
- Docs: Blocks overview 2) Inbound webhooks (Cloud-only) - If you need a public URL managed by Prefect to receive events and trigger actions/flows, that’s available in Cloud: - Create a webhook (Cloud) - This capability is not available in OSS right now. There isn’t a public timeline for OSS parity. If this is important to you, I’m happy to pass your feedback along. 3) OSS patterns to receive external requests and trigger flows If you’re self-hosting, you can still handle inbound requests—you’ll just run the endpoint yourself and call Prefect to start a flow run. A. Minimal FastAPI (or any web framework) service that calls Prefect’s Python client - Handle the external HTTP request, parse/validate payload, then trigger a deployment via the client:
Copy code
from fastapi import FastAPI, Request
  import os
  from prefect import get_client

  app = FastAPI()
  DEPLOYMENT_ID = os.environ["PREFECT_DEPLOYMENT_ID"]

  @app.post("/webhook")
  async def receive(request: Request):
      payload = await request.json()
      async with get_client() as client:
          run = await client.create_flow_run_from_deployment(
              deployment_id=DEPLOYMENT_ID,
              parameters={"payload": payload},
              tags=["webhook"],
          )
      return {"flow_run_id": str(run.id)}
- You can add HMAC validation, IP allowlists, retries, etc., as needed. B. Call the Prefect REST API directly from your external system - Your service (or the third party) can POST to the Prefect Server API to create flow runs. - REST reference: Create a flow run (REST) Notes and clarifications - Automations/event-driven features in the UI (including inbound webhooks) are Cloud features today. - Outbound webhooks/notifications are fully usable in OSS via Blocks. - If you tell me more about the external system and your security constraints (e.g., need for signed payloads/HMAC, rate limits, required response times), I can sketch a concrete setup (FastAPI example, infra notes, and how to pass parameters into your deployment).