Eden Gen

Webhooks into your pipeline

Drop finished takes straight into your project folder, Slack or n8n.

  1. 1
    Create the take with a webhook
    js
    const TAKES = "https://edengen.ai/v1";
    const H = { Authorization: `Bearer ${process.env.TAKES_API_KEY}`, "Content-Type": "application/json" };
    
    const res = await fetch(`${TAKES}/takes`, {
      method: "POST",
      headers: { ...H, Prefer: "wait=60" },
      body: JSON.stringify({
        model: "kling-3",
        prompt: "A small white creature looks up at the lightning and blinks, no music",
        resolution: "720p",
        duration: 5,
        webhook_url: "https://your.app/hooks/takes",
      }),
    });
    const take = await res.json();
    console.log(take.status, take.cost_usd, take.output?.url);
  2. 2
    Receive and verify
    server.js
    import express from "express";
    import { verify } from "./verify.js";            // from the Webhooks page
    
    const app = express();
    app.post("/hooks/takes", express.raw({ type: "application/json" }), async (req, res) => {
      if (!verify(req.body.toString(), req.get("X-Takes-Signature"), process.env.TAKES_WEBHOOK_SECRET)) return res.sendStatus(401);
      const { event, take } = JSON.parse(req.body);
      res.sendStatus(200);                              // answer fast, work after
      if (event === "take.completed") await saveToDrive(take.output.url, take.output.filename);
      else await notify(`Take ${take.id} failed and was refunded: ${take.error}`);
    });
    app.listen(3000);
  3. 3
    n8n or Make

    Use a Webhook trigger node as the webhook_url, then an HTTP node to fetch take.output.url with your key. Verify the signature in a Code node with the same function.

Webhooks into your pipeline · Docs · Eden Gen