Verify Make webhooks

Make doesn't sign these requests, so there's no signature to check and no SDK to verify one. An API key keychain on the module sends a key you generate in a header you name, and your endpoint compares it in constant time. That authenticates the sender, but it doesn't protect the body or stop a replay.

These pages cover requests a Make scenario sends to your endpoint. To send data into Make and trigger a scenario, see Make's Webhooks docs and how to solve Make webhook rate limit errors.

The facts

Signature header
None (unsigned)
What to build
Compare the key header you chose with your stored value
Key
shared secret

Make webhook secret

Make issues no secret. You generate a value and store it in an API key keychain on the module. Keep it in an environment variable, not in source code.

  • Create it from Credentials on the module, with Authentication type set to API key
  • Make sends the Key exactly as entered, so a prefix such as Bearer is part of the value you compare
  • API key placement chooses header or query parameters, and API key parameter name sets the name, such as x-api-key
  • Restrict requests to service URLs sends the key only to the HTTPS origins in Allowed service origins, so list your endpoint there
  • Rotate it under Keys, where a change applies to every module that uses the keychain

Source: Make docs ↗

Code

express/src/index.js
javascript
// Generated with: make-webhooks skill
// https://github.com/hookdeck/webhook-skills
require('dotenv').config({ quiet: true });
const crypto = require('crypto');
const express = require('express');

const app = express();

// The HTTP module's method is user-chosen, so accept all the usual ones.
const METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];

/**
 * Constant-time string comparison. Hashing both sides first gives equal-length
 * buffers, so timingSafeEqual never throws and the secret's length isn't leaked.
 */
function safeEqual(a, b) {
  const ha = crypto.createHash('sha256').update(String(a)).digest();
  const hb = crypto.createHash('sha256').update(String(b)).digest();
  return crypto.timingSafeEqual(ha, hb);
}

/**
 * Make's HTTP module does not sign requests. With an API key keychain (placement
 * "In the header") it sends <parameter name>: <Key>, exactly as entered. Compare
 * the WHOLE header value: don't strip a "Bearer " prefix, it is part of the Key.
 *
 * A static credential authenticates the sender, not the body, and gives no replay
 * protection (no signature, no timestamp).
 */
function verifyMakeRequest(headers, config = process.env) {
  const expected = config.MAKE_WEBHOOK_SECRET;
  if (!expected) return false; // never accept when unconfigured

  const headerName = (config.MAKE_WEBHOOK_HEADER || 'Authorization').toLowerCase();
  const received = headers[headerName];
  return typeof received === 'string' && safeEqual(received, expected);
}

/**
 * Make has no built-in event types: the payload is whatever your scenario maps.
 * These examples assume { "event": "...", "id": "...", "data": {...} }.
 */
function handleEvent(payload) {
  const { event, id, data = {} } = payload;

  switch (event) {
    case 'order.created':
      console.log(`Order created: ${data.order_id}`);
      // Your code: fulfil the order
      break;

    case 'lead.created':
      console.log(`Lead created: ${data.email}`);
      // Your code: add the lead to your CRM
      break;

    case 'scenario.completed':
      console.log(`Scenario completed: ${data.scenario_name}`);
      // Your code: mark the job as done
      break;

    case 'scenario.failed':
      console.log(`Scenario failed: ${data.scenario_name} (${data.error})`);
      // Your code: alert the owning team
      break;

    default:
      console.log(`Unhandled event: ${event} (id: ${id})`);
  }
}

// Read the body raw (any content type) so the request is authenticated before
// anything is parsed. GET requests arrive with no body.
app.all('/webhooks/make', express.raw({ type: '*/*' }), (req, res) => {
  if (!METHODS.includes(req.method)) {
    res.set('Allow', METHODS.join(', '));
    return res.status(405).json({ error: 'Method not allowed' });
  }

  if (!verifyMakeRequest(req.headers)) {
    return res.status(401).json({ error: 'Invalid or missing credentials' });
  }

  const raw = Buffer.isBuffer(req.body) ? req.body.toString('utf8') : '';

  // An empty body (e.g. GET) is valid: there is simply no event to dispatch.
  if (raw.trim() === '') {
    return res.status(200).json({ received: true });
  }

  let payload;
  try {
    payload = JSON.parse(raw);
  } catch {
    return res.status(400).json({ error: 'Invalid JSON body' });
  }

  if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
    return res.status(400).json({ error: 'Expected a JSON object' });
  }

  try {
    handleEvent(payload);
  } catch (err) {
    console.error('Error handling Make event:', err);
    // A non-2xx makes the HTTP module error, which stops the scenario run
    // unless an error handler route is attached.
    return res.status(500).json({ error: 'Handler error' });
  }

  res.status(200).json({ received: true });
});

app.get('/health', (req, res) => {
  res.json({ status: 'ok' });
});

module.exports = app;
module.exports.verifyMakeRequest = verifyMakeRequest;

if (require.main === module) {
  const PORT = process.env.PORT || 3000;
  app.listen(PORT, () => {
    console.log(`Server running on http://localhost:${PORT}`);
    console.log(`Webhook endpoint: http://localhost:${PORT}/webhooks/make`);
  });
}
nextjs/app/webhooks/make/route.ts
typescript
// Generated with: make-webhooks skill
// https://github.com/hookdeck/webhook-skills
import { NextRequest, NextResponse } from 'next/server';
import { verifyMakeRequest } from '../../../lib/verify-make';

/**
 * Make has no built-in event types: the payload is whatever your scenario maps.
 * These examples assume { "event": "...", "id": "...", "data": {...} }.
 */
interface MakePayload {
  event?: string;
  id?: string;
  data?: Record<string, unknown>;
}

function handleEvent(payload: MakePayload): void {
  const { event, id, data = {} } = payload;

  switch (event) {
    case 'order.created':
      console.log(`Order created: ${data.order_id}`);
      // Your code: fulfil the order
      break;

    case 'lead.created':
      console.log(`Lead created: ${data.email}`);
      // Your code: add the lead to your CRM
      break;

    case 'scenario.completed':
      console.log(`Scenario completed: ${data.scenario_name}`);
      // Your code: mark the job as done
      break;

    case 'scenario.failed':
      console.log(`Scenario failed: ${data.scenario_name} (${data.error})`);
      // Your code: alert the owning team
      break;

    default:
      console.log(`Unhandled event: ${event} (id: ${id})`);
  }
}

async function handle(request: NextRequest) {
  // Authenticate before reading or parsing the body.
  if (!verifyMakeRequest(request.headers)) {
    return NextResponse.json({ error: 'Invalid or missing credentials' }, { status: 401 });
  }

  // Read the raw text (any content type). GET requests arrive with no body.
  const raw = await request.text();

  // An empty body (e.g. GET) is valid: there is simply no event to dispatch.
  if (raw.trim() === '') {
    return NextResponse.json({ received: true });
  }

  let payload: unknown;
  try {
    payload = JSON.parse(raw);
  } catch {
    return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });
  }

  if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
    return NextResponse.json({ error: 'Expected a JSON object' }, { status: 400 });
  }

  try {
    handleEvent(payload as MakePayload);
  } catch (err) {
    console.error('Error handling Make event:', err);
    // A non-2xx makes the HTTP module error, which stops the scenario run
    // unless an error handler route is attached.
    return NextResponse.json({ error: 'Handler error' }, { status: 500 });
  }

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

// The HTTP module's method is user-chosen, so serve all the usual ones.
export const GET = handle;
export const POST = handle;
export const PUT = handle;
export const PATCH = handle;
export const DELETE = handle;
fastapi/main.py
python
# Generated with: make-webhooks skill
# https://github.com/hookdeck/webhook-skills
import hmac
import json
import os

from dotenv import load_dotenv
from fastapi import Depends, FastAPI, HTTPException, Request

load_dotenv()

app = FastAPI()

# The HTTP module's method is user-chosen, so accept all the usual ones.
METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"]


def safe_equal(a: str, b: str) -> bool:
    """Constant-time comparison. Encode both sides: compare_digest raises
    TypeError on a non-ASCII str, but accepts bytes."""
    return hmac.compare_digest(a.encode("utf-8"), b.encode("utf-8"))


def verify_make_request(headers, config=os.environ) -> bool:
    """Make's HTTP module does not sign requests. With an API key keychain
    (placement "In the header") it sends <parameter name>: <Key>, exactly as
    entered. Compare the WHOLE header value: don't strip a "Bearer " prefix, it
    is part of the Key.

    A static credential authenticates the sender, not the body, and gives no
    replay protection (no signature, no timestamp).
    """
    expected = config.get("MAKE_WEBHOOK_SECRET")
    if not expected:
        return False  # never accept when unconfigured

    header_name = config.get("MAKE_WEBHOOK_HEADER") or "Authorization"
    # Header names are case-insensitive, whatever mapping type was passed in.
    wanted = header_name.lower()
    received = next((v for k, v in headers.items() if k.lower() == wanted), None)
    return received is not None and safe_equal(received, expected)


async def require_make_auth(request: Request) -> None:
    """FastAPI dependency: reject the request before the body is parsed."""
    if not verify_make_request(request.headers):
        raise HTTPException(status_code=401, detail="Invalid or missing credentials")


def handle_event(payload: dict) -> None:
    """Make has no built-in event types: the payload is whatever your scenario
    maps. These examples assume {"event": "...", "id": "...", "data": {...}}."""
    event = payload.get("event")
    data = payload.get("data") or {}

    if event == "order.created":
        print(f"Order created: {data.get('order_id')}")
        # Your code: fulfil the order

    elif event == "lead.created":
        print(f"Lead created: {data.get('email')}")
        # Your code: add the lead to your CRM

    elif event == "scenario.completed":
        print(f"Scenario completed: {data.get('scenario_name')}")
        # Your code: mark the job as done

    elif event == "scenario.failed":
        print(f"Scenario failed: {data.get('scenario_name')} ({data.get('error')})")
        # Your code: alert the owning team

    else:
        print(f"Unhandled event: {event} (id: {payload.get('id')})")


@app.api_route("/webhooks/make", methods=METHODS, dependencies=[Depends(require_make_auth)])
async def make_webhook(request: Request):
    # Raw body, any content type. GET requests arrive with no body.
    raw_body = await request.body()

    # An empty body (e.g. GET) is valid: there is simply no event to dispatch.
    if not raw_body.strip():
        return {"received": True}

    try:
        payload = json.loads(raw_body)
    except (json.JSONDecodeError, UnicodeDecodeError):
        raise HTTPException(status_code=400, detail="Invalid JSON body")

    if not isinstance(payload, dict):
        raise HTTPException(status_code=400, detail="Expected a JSON object")

    try:
        handle_event(payload)
    except Exception as err:  # noqa: BLE001
        print(f"Error handling Make event: {err}")
        # A non-2xx makes the HTTP module error, which stops the scenario run
        # unless an error handler route is attached.
        raise HTTPException(status_code=500, detail="Handler error")

    return {"received": True}


@app.get("/health")
async def health():
    return {"status": "ok"}


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app, host="0.0.0.0", port=8000)

From hookdeck/webhook-skills ↗

Or install the Make webhooks skill:

npx skills add hookdeck/webhook-skills --skill make-webhooks

Common failures

Prefix left out of the comparison

Make sends the Key exactly as entered. If you typed Bearer abc, the value to compare is Bearer abc, not abc.

Header name mismatch

API key parameter name sets the header. Your endpoint has to read the same name, and header names are case-insensitive.

Key placed in the query string

With API key placement set to query parameters, the key isn't in a header at all. Use In the header.

Origin missing from the keychain

With Restrict requests to service URLs on, Make sends credentials only to the origins in Allowed service origins. Add your endpoint's origin, including its port if it isn't 443.

From Hookdeck's Make guide

Let Event Gateway check your Make key.

Set the key on a Make source and Event Gateway checks the header your module sends. A request with the wrong key still gets a 200, but it's recorded as failed verification and creates no event.

Not affiliated with Make. Facts are compiled from public sources and linked inline.