cuil.si for developers
Webhooks
Add an endpoint
A workspace admin adds endpoints in Settings › Developers › Webhooks, or through the API (createWebhook). Each endpoint picks the events it wants, or all of them. The address must be https and reachable from the internet. Up to 20 endpoints per workspace.
Press "Send test event" in the app to get a ping and check your code.
What we send
A JSON POST with the same envelope every time: id, type, created_at, workspace_id and the event's own data. The headers follow the open Standard Webhooks format.
POST /your/endpoint HTTP/1.1
Content-Type: application/json
User-Agent: Ginie-Webhooks/1
webhook-id: evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b
webhook-timestamp: 1761211800
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
{
"id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b",
"type": "generation.completed",
"created_at": "2026-10-27T09:30:00+00:00",
"workspace_id": "5a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
"data": { "id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "kind": "image", "output_asset_ids": ["8d5b7c1e-..."] }
}Events
Open an event to see an example body. New events can be added within v1, so ignore types you don't know.
generation.completedAn image, video, voice-over or transcript finished and was saved to the Library.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "generation.completed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "kind": "image", "mode": "t2i", "source": "api", "model_id": "replicate-flux3-image", "output_asset_ids": [ "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44" ] } }generation.failedAn image, video, voice-over or transcript couldn't be created. Credits were returned.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "generation.failed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "kind": "video", "mode": "t2v", "source": "api", "error": "The video service is busy. Please try again." } }movie.completedA movie finished and the final film is in the Library.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "movie.completed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "title": "Summer launch film", "final_asset_id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "duration_s": 62.5 } }movie.failedA movie stopped before it was finished.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "movie.failed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "title": "Summer launch film", "error": "One of the shots couldn't be created." } }render.completedA video from the editor finished exporting and was saved to the Library.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "render.completed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "timeline_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "preview": false, "output_asset_id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "duration_s": 30 } }render.failedA video from the editor couldn't be exported.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "render.failed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "timeline_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "preview": false, "error": "One of the clips is missing." } }post.publishedA social post went live on one of your connected accounts. For YouTube, account_name and external_url are null: YouTube's rules keep its data in cuil.si.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "post.published", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "post_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "publication_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "network": "instagram", "account_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "account_name": "Sunny Beans Coffee", "external_url": "https://www.instagram.com/p/example/" } }post.failedA social post couldn't be published. For YouTube, account_name is null.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "post.failed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "post_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "publication_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "network": "linkedin", "account_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "account_name": "Sunny Beans Coffee", "error": "LinkedIn asked us to sign in again." } }workflow.run.completedA workflow run finished every step.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "workflow.run.completed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "workflow_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "run_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "status": "succeeded", "trigger_type": "schedule", "credits_used": 12 } }workflow.run.failedA workflow run stopped because a step didn't work.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "workflow.run.failed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "workflow_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "run_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "status": "failed", "trigger_type": "manual", "credits_used": 0, "error": "The HTTP step got an error from the website." } }credits.lowYour workspace's credit balance dropped below 10% of the starting amount.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "credits.low", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "balance": 420, "threshold": 500 } }credits.expiredCredits that weren't used within 12 months of being added expired (we use the oldest credits first).{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "credits.expired", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "credits": 1000, "balance": 3500 } }ads.campaign.alertSomething needs attention on an ad campaign: it was paused by the daily limit or automatic pause, it is waiting for approval, it couldn't launch, or the ad platform didn't approve one of its ads.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "ads.campaign.alert", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "campaign_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "campaign_name": "Summer coffee", "platform": "meta", "kind": "paused_daily_cap", "status": "paused", "message": "Today's spend reached the daily limit." } }lead.createdA new lead was added: from a form, an import, the API, an automation or by hand.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "lead.created", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "name": "Asha Rao", "first_name": "Asha", "last_name": "Rao", "email": "[email protected]", "phone": "+919876543210", "title": "Founder", "company": { "id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "name": "Sunny Beans Coffee", "domain": "sunnybeans.example" }, "source": "form", "stage": "new", "score": 0, "tags": [ "website" ], "created_at": "2026-10-23T09:30:00+00:00" } }lead.updatedA lead's details changed. `changed` lists the fields that changed.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "lead.updated", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "name": "Asha Rao", "first_name": "Asha", "last_name": "Rao", "email": "[email protected]", "phone": "+919876543210", "title": "Founder", "company": null, "source": "form", "stage": "new", "score": 0, "tags": [ "website", "vip" ], "created_at": "2026-10-23T09:30:00+00:00", "changed": [ "title", "tags" ] } }lead.deletedA lead was erased (by a person, or because it had no activity for longer than the workspace keeps leads). Only the id is sent: delete your copy too.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "lead.deleted", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "reason": "erase" } }lead.stage_changedA lead moved to another stage of the pipeline (with its deal, when it has one).{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "lead.stage_changed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "deal_id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "pipeline_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "from_stage": "contacted", "to_stage": "qualified", "deal_value": 5000000, "currency": "INR" } }lead.unsubscribedA lead took back their permission to be contacted (for example with the unsubscribe link).{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "lead.unsubscribed", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "channel": "email", "purpose": "marketing", "source": "unsubscribe_link" } }form.submittedSomeone filled in one of your lead forms.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "form.submitted", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "form_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "form_name": "Website enquiry", "submission_id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "is_new_lead": true, "answers": { "message": "Do you deliver to Pune?" } } }deal.wonA deal moved to a Won stage.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "deal.won", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "deal_id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "company_id": null, "name": "Asha Rao", "value_minor": 5000000, "currency": "INR", "stage": "won" } }deal.lostA deal moved to a Lost stage.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "deal.lost", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "deal_id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "company_id": null, "name": "Asha Rao", "value_minor": 5000000, "currency": "INR", "stage": "lost", "lost_reason": "Chose another supplier" } }lead.importedA CSV import finished (or stopped part way), with how many leads it added and updated. Imports send this one event instead of lead.created or lead.updated for every row: list the leads with GET /leads to sync.{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "lead.imported", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "import_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "file_name": "trade-fair-2026.csv", "status": "done", "counts": { "rows": 120, "created": 98, "updated": 17, "skipped_duplicate": 0, "skipped_do_not_contact": 3, "invalid": 2 }, "list_id": null, "finished_at": "2026-10-23T09:30:00+00:00" } }sale.recordedA sale was recorded for a lead (in cuil.si, through the API, or from your shop).{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "sale.recorded", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "sale_id": "8d5b7c1e-2a4f-4e3b-b1c6-7f9e0a2d3c44", "lead_id": "3f0c2a5e-8f2d-4c1a-9a57-2b8e6d1c4f90", "amount_minor": 249900, "currency": "INR", "amount_text": "₹2,499.00", "product": "Coffee subscription", "order_id": "SHOP-1042", "sold_at": "2026-10-23T09:30:00+00:00", "source": "api" } }pingA test event, sent when you press "Send test event".{ "id": "evt_2b9d6f0e4c1a4f7e8a3b5c6d7e8f9a0b", "type": "ping", "created_at": "2026-10-23T09:30:00+00:00", "workspace_id": "6a1e4b2c-9d3f-4e5a-8b7c-1d2e3f4a5b6c", "data": { "message": "This is a test event from cuil.si." } }
Check the signature
Check every request before you trust it. The signing secret (it starts with whsec_) is on the endpoint's page in Settings › Developers; for safety it can only be seen in the app. Always use the raw body exactly as it arrived, not JSON you parsed and wrote out again.
With the official libraries (easiest)
// npm install standardwebhooks
import { Webhook } from "standardwebhooks";
const webhook = new Webhook(process.env.CUILSI_WEBHOOK_SECRET); // "whsec_..." from Settings > Developers
// Express: keep the raw body, the signature is made over the exact bytes we sent.
app.post("/cuilsi-webhook", express.raw({ type: "application/json" }), (req, res) => {
let event;
try {
event = webhook.verify(req.body.toString("utf8"), req.headers); // throws if it isn't from cuil.si
} catch {
return res.status(400).end();
}
res.status(204).end(); // answer quickly, then do the work
handle(event); // event.id, event.type, event.created_at, event.data
});Or by hand
- Join the
webhook-id, thewebhook-timestampand the raw body with dots. - Sign that text with HMAC-SHA256, using your secret without
whsec_, decoded from base64. - Compare the base64 result with the part after
v1,inwebhook-signature. Refuse timestamps more than 5 minutes old.
import crypto from "node:crypto";
// Use the raw request body (a string), not parsed JSON.
export function isFromCuilsi(rawBody, headers, secret) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
// Ignore requests older than 5 minutes (protects against replays).
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = crypto
.createHmac("sha256", key)
.update(`${id}.${timestamp}.${rawBody}`)
.digest("base64");
return headers["webhook-signature"].split(" ").some((part) => {
const [version, signature] = part.split(",");
return (
version === "v1" &&
signature.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
);
});
}Answers, retries and repeats
Answer with any 2xx status within 10 seconds, then do the slow work. Anything else (an error, a timeout, no answer) counts as failed, and we try again:
| Try | When |
|---|---|
| 1st retry | 1 minute after the first try |
| 2nd retry | 5 minutes later |
| 3rd retry | 30 minutes later |
| 4th retry | 2 hours later |
| 5th retry | 6 hours later |
After that the delivery is marked failed. The delivery log in Settings › Developers shows every try and your server's answer, and you can send any delivery again from there or through the API.
- Deliveries can repeat. A retry has the same
webhook-id(the event'sid), so skip ids you already handled. - Deliveries can arrive out of order. Use
created_atto keep the newest.
// Deliveries can repeat (a retry after a timeout) and can arrive out of order.
async function handle(event) {
if (await alreadyHandled(event.id)) return; // the webhook-id is the same on every retry
const current = await lastSeen(event.data.id);
if (current && current > event.created_at) return; // an older update arrived late: keep the newer one
await save(event);
}Step by step: Verify webhooks.