DashForDevsDocs
DocsNewsAPI v1
dashfordevs.comSign in

© 2026 DashForDevs

DocsNewsdashfordevs.comLegalStatus
DocsWebhooksVerifying Signatures
Introduction
Getting Started
Authentication
Products
Categories
Cart
Checkout
Blog
Reviews
Webhooks
OverviewEvent TypesVerifying Signatures
Customers
Orders
Inventory
Shipping
Discounts
Affiliates
Email
Media & Files
Analytics & Tracking
Locations
Tax
Global Data
SEO
Error Handling
Geography
Finance
Automations
Page Types
Surveys
Billing & Subscriptions
Storefront Payments
SDK Reference
REST API
Storefront Architecture
Notifications
Security
Team & Permissions
Migrations & Import
Calendar & Appointments
Contact Forms
AI Bots
Dashboard API
Deployment
Changelog
Troubleshooting
Recipes
CLI & Deployment
Image Pipeline
White-label Platforms
Records Engine
Platform Modules
Platform Security
Site Keys & Client Sites
Use Cases
Operations

Verifying Signatures

Validate webhook authenticity using HMAC signatures.

Updated March 29, 2026

On this page
  • Why Verify?
  • How Signatures Work
  • Verification in Node.js
  • Next.js API Route Example
  • Verification in Python
  • Getting Your Webhook Secret
  • Next Steps

Why Verify?

Always verify webhook signatures to ensure the request genuinely came from DashForDevs and hasn't been tampered with. Without verification, anyone could send fake events to your endpoint.

How Signatures Work

Every webhook request includes an x-dash4devs-signature header containing an HMAC-SHA256 hash of the request body, signed with your webhook secret.

Verification in Node.js

typescript
import crypto from "crypto"

function verifyWebhookSignature(
  body: string,
  signature: string,
  secret: string
): boolean {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(body)
    .digest("hex")

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  )
}
Important: Always use timingSafeEqual instead of === to prevent timing attacks.

Next.js API Route Example

typescript
// app/api/webhooks/dash4devs/route.ts
import { NextRequest, NextResponse } from "next/server"
import crypto from "crypto"

const 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") || ""

  const expected = crypto
    .createHmac("sha256", SECRET)
    .update(body)
    .digest("hex")

  const valid = crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  )

  if (!valid) {
    return NextResponse.json({ error: "Invalid signature" }, { status: 401 })
  }

  const event = JSON.parse(body)
  // Process the verified event...

  return NextResponse.json({ received: true })
}

Verification in Python

python
import hmac
import hashlib

def verify_signature(body: bytes, signature: str, secret: str) -> bool:
    expected = hmac.new(
        secret.encode(),
        body,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(signature, expected)

Getting Your Webhook Secret

  1. Go to Settings → Webhooks in the dashboard
  2. Click on your webhook endpoint
  3. Copy the signing secret
  4. Store it as an environment variable (never hardcode it)
shell
# .env
DASH4DEVS_WEBHOOK_SECRET=whsec_your_signing_secret_here

Next Steps

  • Webhook Overview — Setting up webhooks
  • Event Types — All available events
  • Security: Webhook Signatures — Advanced security considerations
PreviousEvent TypesNextGet Customer

On this page

  • Why Verify?
  • How Signatures Work
  • Verification in Node.js
  • Next.js API Route Example
  • Verification in Python
  • Getting Your Webhook Secret
  • Next Steps