Examples
Working code for Zoie webhooks: receivers in Node.js and Python that check X-Zoie-Webhook-Secret, a curl test for your endpoint, posting leads to a workflow Webhook trigger, connecting Zapier both ways, and calling the website lead webhook.
The examples use placeholder IDs and URLs. The payloads and responses are the real shapes described in Payloads.
Receive a Send webhook call
A receiver should check the secret first, answer quickly, and do its real work afterwards. Zoie waits up to 10 seconds for a response and treats any status of 400 or above as a failed step.
import crypto from 'node:crypto';
import express from 'express';
const app = express();
const SECRET = process.env.ZOIE_WEBHOOK_SECRET;
// Hash both sides so the comparison is constant-time and the lengths always match.
function secretMatches(provided) {
if (typeof provided !== 'string' || !SECRET) return false;
const a = crypto.createHash('sha256').update(provided).digest();
const b = crypto.createHash('sha256').update(SECRET).digest();
return crypto.timingSafeEqual(a, b);
}
async function handleLead(workflow, lead) {
// Your logic: upsert into your CRM, notify a channel, and so on.
console.log(`Workflow ${workflow.id} sent lead ${lead.id} (${lead.lead_status})`);
}
// Use app.put instead if the step's method is PUT.
app.post('/hooks/zoie', express.json({ limit: '100kb' }), (req, res) => {
if (!secretMatches(req.get('X-Zoie-Webhook-Secret'))) {
return res.status(401).end();
}
const { event, workflow, lead } = req.body ?? {};
if (event !== 'workflow.action.webhook' || !lead?.id) {
return res.status(400).end();
}
// Answer first, then work, so a slow job can't time out the step.
res.status(200).json({ ok: true });
setImmediate(() => handleLead(workflow, lead).catch(console.error));
});
app.listen(3000);import hmac
import os
from flask import Flask, abort, jsonify, request
app = Flask(__name__)
SECRET = os.environ["ZOIE_WEBHOOK_SECRET"].encode()
@app.post("/hooks/zoie")
def zoie_webhook():
provided = request.headers.get("X-Zoie-Webhook-Secret", "").encode()
if not hmac.compare_digest(provided, SECRET):
abort(401)
body = request.get_json(silent=True) or {}
lead = body.get("lead") or {}
if body.get("event") != "workflow.action.webhook" or not lead.get("id"):
abort(400)
# Hand the work to a queue or background worker here, then answer.
app.logger.info("Workflow %s sent lead %s", body["workflow"]["id"], lead["id"])
return jsonify(ok=True), 200Handle repeats
There’s no delivery ID, and the same lead can arrive more than once: a workflow set to Every time runs again on the next event, and Retry failed step resends with a new sent_at. Build an idempotency key from the fields that make an event unique for you. For a Lead Status Changed workflow, for example:
const key = `${workflow.id}:${lead.id}:${lead.lead_status}`;
if (await alreadyProcessed(key)) return; // your own store, such as a database table with a unique index
await markProcessed(key);
Test your endpoint
Send your receiver the same request Zoie makes, before you wire up a workflow:
curl -i -X POST "https://example.com/hooks/zoie" \
-H "Content-Type: application/json" \
-H "X-Zoie-Webhook-Secret: $ZOIE_WEBHOOK_SECRET" \
-d '{
"event": "workflow.action.webhook",
"workflow": { "id": 87, "name": "New leads to our CRM" },
"sent_at": "2026-10-02T09:14:09.120Z",
"lead": {
"id": 18342,
"business_id": 42,
"first_name": "Jane",
"last_name": "Smith",
"email": "[email protected]",
"phone_number": "+15551234567",
"lead_status": "New",
"lead_source": null,
"labels": null
}
}'
Then try it without the header and check you get 401. A workflow’s Test run won’t call your endpoint: it only describes the step. To test end to end, publish the workflow and trigger it with a test lead, then check the run on the Executions tab.
Send leads to a Webhook trigger
Copy the URL from the workflow’s Webhook trigger and keep it in your server’s secrets. Send one request before you publish, then click Fetch sample and map the fields on the Create lead step.
curl -i -X POST "$ZOIE_WORKFLOW_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"contact": {
"first_name": "Jane",
"last_name": "Smith",
"email": "[email protected]",
"phone": "+15551234567"
},
"interest": "Teeth Whitening",
"utm_source": "newsletter"
}'// Server-side (Node 18+). The URL is a credential: never send it to a browser.
export async function sendToZoie(payload) {
const res = await fetch(process.env.ZOIE_WORKFLOW_WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
if (res.status === 429) {
const waitSeconds = Number(res.headers.get('Retry-After') ?? 60);
throw new Error(`Rate limited by Zoie, retry in ${waitSeconds}s`);
}
const body = await res.json();
if (res.status !== 202) throw new Error(`Zoie answered ${res.status}: ${body.message}`);
return body; // { received: true, ran: true } once the workflow is live
}With this body, map contact.first_name to First Name, contact.last_name to Last Name, contact.email to Email, contact.phone to Phone Number, interest to Service and utm_source to UTM Source. Auto-map by name fills in most of these for you.
Tools that can only send form fields work too:
curl -i -X POST "$ZOIE_WORKFLOW_WEBHOOK_URL" \
--data-urlencode "first_name=Jane" \
--data-urlencode "[email protected]" \
--data-urlencode "phone=+15551234567"
Connect Zapier
Zoie has no Zapier app, but Zapier’s built-in webhook steps connect to workflows in both directions.
Zoie to Zapier
- In Zapier, start a Zap with Webhooks by Zapier → Catch Hook and copy the hook URL it gives you.
- In Zoie, add a Send webhook step to your workflow with method POST and that URL, and publish.
- Trigger the workflow once with a test lead, then test the trigger in Zapier to pull in that call as a sample. The
leadandworkflowfields are then available to the Zap’s later steps.
Zapier’s hook URL is itself the credential on that side, so a Zoie Secret is optional here.
Zapier to Zoie
- In Zoie, create a workflow with the Webhook trigger and a Create lead step, and copy the trigger URL.
- In Zapier, add an action Webhooks by Zapier → POST. Paste the trigger URL, set Payload Type to JSON, and add the fields to send, such as
email,phoneandfirst_name. - Test the action, then click Fetch sample in Zoie and map the fields.
Post to the website lead webhook
Only for websites Zoie support has set up with a website_user_name. For new integrations, use a Webhook trigger or the Forms API instead. See Security.
curl -i -X POST "https://api-us.zoie.ai/api/v1/auth/form-leads-webhook" \
-H "Content-Type: application/json" \
-d '{
"website_user_name": "<your website identifier>",
"first_name": "Jane",
"last_name": "Smith",
"email": "[email protected]",
"phone_number": "+15551234567",
"treatment": "Dental Implants",
"utm_source": "google",
"utm_campaign": "implants-q4",
"ip_address": "203.0.113.24"
}'
{ "message": "Lead stored successfully", "id": 18342 }
This creates a real lead and can start AI outreach to the phone number and email in the body. Use your own details when testing.