Overview
How webhooks work and when to use them.
Updated
On this page
What Are Webhooks?
Webhooks let your application receive real-time notifications when events happen in your store. Instead of polling the API for changes, DashForDevs sends an HTTP POST request to your server when events like new orders, customer signups, or inventory changes occur.
How It Works
1. You register a webhook URL in the dashboard
2. An event occurs (e.g., new order placed)
3. DashForDevs sends a POST request to your URL
4. Your server processes the event and responds with 200 OK
Setting Up Webhooks
- Go to Settings → Webhooks in the dashboard
- Click Add Webhook
- Enter your endpoint URL (must be HTTPS)
- Select which events to subscribe to
- Copy the signing secret for verification
Webhook Payload
Every webhook request includes:
{
"event": "order.created",
"timestamp": "2025-01-15T10:30:00Z",
"data": {
"id": "ord_abc123",
"order_number": "ORD-1042",
"status": "pending",
"total": "77.73",
"customer": { ... },
"items": [ ... ]
}
}
Example Handler (Next.js API Route)
// app/api/webhooks/dash4devs/route.ts
import { NextRequest, NextResponse } from "next/server"
import crypto from "crypto"
const WEBHOOK_SECRET = process.env.DASH4DEVS_WEBHOOK_SECRET!
export async function POST(req: NextRequest) {
const body = await req.text()
const signature = req.headers.get("x-dash4devs-signature")
// Verify the signature
const expected = crypto
.createHmac("sha256", WEBHOOK_SECRET)
.update(body)
.digest("hex")
if (signature !== expected) {
return NextResponse.json({ error: "Invalid signature" }, { status: 401 })
}
const event = JSON.parse(body)
switch (event.event) {
case "order.created":
// Handle new order
console.log("New order:", event.data.order_number)
break
case "customer.created":
// Handle new customer
break
}
return NextResponse.json({ received: true })
}
Retry Policy
If your endpoint returns a non-2xx status or times out (30 seconds), DashForDevs will retry:
- 1st retry: 1 minute after failure
- 2nd retry: 5 minutes after
- 3rd retry: 30 minutes after
- 4th retry: 2 hours after
- Final retry: 24 hours after
After 5 failed attempts, the webhook is marked as failing and you'll receive a notification in the dashboard.
Next Steps
- Event Types — All available webhook events
- Verifying Signatures — Secure webhook handling
- Security: Webhook Signatures — In-depth security guide