Verify Recruitee webhooks

Recruitee includes an X-Recruitee-Signature header in its webhook requests, the hex HMAC-SHA256 of the raw body keyed with your webhook secret, so you can confirm a request came from Recruitee and that its body is intact. No timestamp is signed, so the signature doesn't protect against replays. Recruitee's docs include a worked example with openssl that you can test your code against.

The facts

Signature header
X-Recruitee-Signature

Format: <lowercase hex digest>

Scheme
HMAC-SHA256, hex
Signed material
{raw body}

The request body exactly as sent. No timestamp is signed or sent; created_at in the body is the event time and stays the same across retries.

What to build
Recompute an HMAC-SHA256 of the raw body with the secret as written, hex-encode it and compare it with the header
Key
shared secret

Recruitee webhook secret

Recruitee shows the webhook secret under Settings > Apps and Plugins > Webhooks. Its worked example uses the string as written. Keep it in an environment variable, not in source code.

  • Find it under **Settings > Apps and Plugins > Webhooks**. Managing webhooks needs the "Manage webhooks" ability in your hiring role.
  • Use it as written. Recruitee's worked example passes its secret straight to openssl dgst -hmac, so don't decode it.
  • The docs name one webhook secret. They don't say whether it's per company or per webhook, and they document no way to rotate it.

Source: Recruitee docs ↗

Code

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

const app = express();

/**
 * Verify a Recruitee webhook signature.
 *
 * Recruitee sends the hex HMAC-SHA256 of the RAW request body, keyed with the
 * webhook secret, in the X-Recruitee-Signature header (no prefix, no timestamp).
 *
 * @param {Buffer} rawBody - Raw request body (unparsed bytes)
 * @param {string} signatureHeader - X-Recruitee-Signature header value
 * @param {string} secret - Recruitee webhook secret
 * @returns {boolean} - Whether the signature is valid
 */
function verifyRecruiteeWebhook(rawBody, signatureHeader, secret) {
  if (!signatureHeader || !secret) {
    return false;
  }

  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');

  // Compare the hex strings as UTF-8 bytes. Decoding with Buffer.from(x, 'hex')
  // would stop at the first non-hex character and accept a digest with trailing junk.
  const received = Buffer.from(signatureHeader.trim().toLowerCase(), 'utf8');
  const expected = Buffer.from(expectedSignature, 'utf8');
  return received.length === expected.length && crypto.timingSafeEqual(received, expected);
}

// Recruitee sends {"test":true} on "Verify and create" / "Test"; it only needs a 200.
function isTestRequest(rawBody) {
  try {
    const parsed = JSON.parse(rawBody.toString());
    return parsed && parsed.test === true && parsed.event_type === undefined;
  } catch {
    return false;
  }
}

// Recruitee webhook endpoint. express.raw with '*/*' keeps the raw bytes for any
// content type, which signature verification needs.
app.post('/webhooks/recruitee',
  express.raw({ type: '*/*' }),
  (req, res) => {
    const signature = req.headers['x-recruitee-signature'];
    const rawBody = Buffer.isBuffer(req.body) ? req.body : Buffer.from('');

    // Verify the signature first, before parsing
    if (!verifyRecruiteeWebhook(rawBody, signature, process.env.RECRUITEE_WEBHOOK_SECRET)) {
      // The bare test request may arrive unsigned; it carries no event data.
      if (!signature && isTestRequest(rawBody)) {
        return res.status(200).send('OK');
      }
      console.error('Webhook signature verification failed');
      return res.status(400).send('Invalid signature');
    }

    let event;
    try {
      event = JSON.parse(rawBody.toString());
    } catch {
      return res.status(400).send('Invalid JSON');
    }

    // Test and Test payload requests (signed): acknowledge without processing. A Test
    // payload body is an example event plus `test`, so check this before dispatch.
    if (event.test === true) {
      return res.status(200).send('OK');
    }

    // The event name is in the body: event_type (+ event_subtype), NOT a header.
    const { id, attempt_count, event_type, event_subtype, payload } = event;
    console.log(`Received Recruitee event: ${event_type}/${event_subtype} (id ${id}, attempt ${attempt_count})`);

    // Retries reuse the same id: dedupe on it in real handlers.
    switch (event_type) {
      case 'new_candidate':
        console.log('New candidate:', payload?.candidate?.id, `(${event_subtype})`);
        // Your code: Notify recruiters, sync to CRM, etc.
        break;

      case 'candidate_assigned':
        console.log('Candidate assigned to offer:', payload?.candidate?.id, payload?.offer?.id);
        // Your code: Track applications per job.
        break;

      case 'candidate_moved':
        // Disqualification arrives here, not as its own event_type.
        if (event_subtype === 'disqualified') {
          console.log('Candidate disqualified:', payload?.candidate?.id, payload?.details?.disqualify_reason?.name);
        } else if (event_subtype === 'requalified') {
          console.log('Candidate requalified:', payload?.candidate?.id);
        } else {
          console.log('Candidate moved:', payload?.candidate?.id, payload?.details?.from_stage?.name, '->', payload?.details?.to_stage?.name);
        }
        // Your code: Pipeline analytics, Slack alerts, onboarding on the hire stage, etc.
        break;

      case 'candidate_deleted':
        console.log('Candidate deleted:', payload?.candidate?.id);
        // Your code: Erase the candidate in downstream systems.
        break;

      case 'offer_published':
        console.log('Job published:', payload?.offer?.id);
        break;

      case 'offer_unpublished':
        console.log('Job unpublished:', payload?.offer?.id);
        break;

      case 'offer_updated':
        console.log('Job updated:', payload?.offer?.id, `(${event_subtype})`);
        break;

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

    // Recruitee treats any status other than 200 as a failure and retries.
    res.status(200).send('OK');
  }
);

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

// Export app for testing
module.exports = { app, verifyRecruiteeWebhook };

// Start server only when run directly (not when imported for testing)
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: POST http://localhost:${PORT}/webhooks/recruitee`);
  });
}
nextjs/app/webhooks/recruitee/route.ts
typescript
// Generated with: recruitee-webhooks skill
// https://github.com/hookdeck/webhook-skills
import { NextRequest, NextResponse } from 'next/server';
import crypto from 'crypto';

/**
 * Verify a Recruitee webhook signature.
 *
 * Recruitee sends the hex HMAC-SHA256 of the RAW request body, keyed with the
 * webhook secret, in the X-Recruitee-Signature header (no prefix, no timestamp).
 */
function verifyRecruiteeWebhook(rawBody: string, signatureHeader: string | null, secret: string | undefined): boolean {
  if (!signatureHeader || !secret) {
    return false;
  }

  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');

  // Compare the hex strings as UTF-8 bytes. Decoding with Buffer.from(x, 'hex')
  // would stop at the first non-hex character and accept a digest with trailing junk.
  const received = Buffer.from(signatureHeader.trim().toLowerCase(), 'utf8');
  const expected = Buffer.from(expectedSignature, 'utf8');
  return received.length === expected.length && crypto.timingSafeEqual(received, expected);
}

// Recruitee sends {"test":true} on "Verify and create" / "Test"; it only needs a 200.
function isTestRequest(parsed: any): boolean {
  return !!parsed && parsed.test === true && parsed.event_type === undefined;
}

export async function POST(request: NextRequest) {
  // Raw body for signature verification (do not parse first)
  const body = await request.text();
  const signature = request.headers.get('x-recruitee-signature');

  // Verify the signature before parsing
  if (!verifyRecruiteeWebhook(body, signature, process.env.RECRUITEE_WEBHOOK_SECRET)) {
    // The bare test request may arrive unsigned; it carries no event data.
    if (!signature) {
      try {
        if (isTestRequest(JSON.parse(body))) {
          return NextResponse.json({ received: true });
        }
      } catch {
        // fall through to 400
      }
    }
    console.error('Webhook signature verification failed');
    return NextResponse.json({ error: 'Invalid signature' }, { status: 400 });
  }

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

  // Test and Test payload requests (signed): acknowledge without processing. A Test
  // payload body is an example event plus `test`, so check this before dispatch.
  if (event?.test === true) {
    return NextResponse.json({ received: true });
  }

  // The event name is in the body: event_type (+ event_subtype), NOT a header.
  const { id, attempt_count, event_type, event_subtype, payload } = event;
  console.log(`Received Recruitee event: ${event_type}/${event_subtype} (id ${id}, attempt ${attempt_count})`);

  // Retries reuse the same id: dedupe on it in real handlers.
  switch (event_type) {
    case 'new_candidate':
      console.log('New candidate:', payload?.candidate?.id, `(${event_subtype})`);
      // Your code: Notify recruiters, sync to CRM, etc.
      break;

    case 'candidate_assigned':
      console.log('Candidate assigned to offer:', payload?.candidate?.id, payload?.offer?.id);
      // Your code: Track applications per job.
      break;

    case 'candidate_moved':
      // Disqualification arrives here, not as its own event_type.
      if (event_subtype === 'disqualified') {
        console.log('Candidate disqualified:', payload?.candidate?.id, payload?.details?.disqualify_reason?.name);
      } else if (event_subtype === 'requalified') {
        console.log('Candidate requalified:', payload?.candidate?.id);
      } else {
        console.log('Candidate moved:', payload?.candidate?.id, payload?.details?.from_stage?.name, '->', payload?.details?.to_stage?.name);
      }
      // Your code: Pipeline analytics, Slack alerts, onboarding on the hire stage, etc.
      break;

    case 'candidate_deleted':
      console.log('Candidate deleted:', payload?.candidate?.id);
      // Your code: Erase the candidate in downstream systems.
      break;

    case 'offer_published':
      console.log('Job published:', payload?.offer?.id);
      break;

    case 'offer_unpublished':
      console.log('Job unpublished:', payload?.offer?.id);
      break;

    case 'offer_updated':
      console.log('Job updated:', payload?.offer?.id, `(${event_subtype})`);
      break;

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

  // Recruitee treats any status other than 200 as a failure and retries.
  return NextResponse.json({ received: true });
}
fastapi/main.py
python
# Generated with: recruitee-webhooks skill
# https://github.com/hookdeck/webhook-skills
import os
import hmac
import hashlib
import json
from dotenv import load_dotenv
from fastapi import FastAPI, Request, HTTPException

load_dotenv()

app = FastAPI()


def verify_recruitee_webhook(raw_body: bytes, signature_header: str, secret: str) -> bool:
    """Verify a Recruitee webhook signature.

    Recruitee sends the hex HMAC-SHA256 of the RAW request body, keyed with the
    webhook secret, in the X-Recruitee-Signature header (no prefix, no timestamp).
    """
    if not signature_header or not secret:
        return False

    expected_signature = hmac.new(
        secret.encode("utf-8"),
        raw_body,
        hashlib.sha256,
    ).hexdigest()

    # Timing-safe comparison
    return hmac.compare_digest(signature_header.strip().lower().encode(), expected_signature.encode())


def is_test_request(parsed) -> bool:
    # Recruitee sends {"test":true} on "Verify and create" / "Test"; it only needs a 200.
    return isinstance(parsed, dict) and parsed.get("test") is True and "event_type" not in parsed


@app.post("/webhooks/recruitee")
async def recruitee_webhook(request: Request):
    # Raw body for signature verification (do not parse first)
    raw_body = await request.body()
    signature = request.headers.get("x-recruitee-signature")
    secret = os.environ.get("RECRUITEE_WEBHOOK_SECRET", "")

    # Verify the signature before parsing
    if not verify_recruitee_webhook(raw_body, signature, secret):
        # The bare test request may arrive unsigned; it carries no event data.
        if not signature:
            try:
                if is_test_request(json.loads(raw_body)):
                    return {"received": True}
            except ValueError:
                pass
        print("Webhook signature verification failed")
        raise HTTPException(status_code=400, detail="Invalid signature")

    try:
        event = json.loads(raw_body)
    except ValueError:
        raise HTTPException(status_code=400, detail="Invalid JSON")

    # Test and Test payload requests (signed): acknowledge without processing. A Test
    # payload body is an example event plus `test`, so check this before dispatch.
    if isinstance(event, dict) and event.get("test") is True:
        return {"received": True}

    # The event name is in the body: event_type (+ event_subtype), NOT a header.
    event_type = event.get("event_type")
    event_subtype = event.get("event_subtype")
    payload = event.get("payload") or {}
    candidate_id = (payload.get("candidate") or {}).get("id")
    offer_id = (payload.get("offer") or {}).get("id")
    print(f"Received Recruitee event: {event_type}/{event_subtype} (id {event.get('id')}, attempt {event.get('attempt_count')})")

    # Retries reuse the same id: dedupe on it in real handlers.
    if event_type == "new_candidate":
        print(f"New candidate: {candidate_id} ({event_subtype})")
        # Your code: Notify recruiters, sync to CRM, etc.
    elif event_type == "candidate_assigned":
        print(f"Candidate assigned to offer: {candidate_id} {offer_id}")
        # Your code: Track applications per job.
    elif event_type == "candidate_moved":
        details = payload.get("details") or {}
        # Disqualification arrives here, not as its own event_type.
        if event_subtype == "disqualified":
            print(f"Candidate disqualified: {candidate_id} {(details.get('disqualify_reason') or {}).get('name')}")
        elif event_subtype == "requalified":
            print(f"Candidate requalified: {candidate_id}")
        else:
            print(f"Candidate moved: {candidate_id} {(details.get('from_stage') or {}).get('name')} -> {(details.get('to_stage') or {}).get('name')}")
        # Your code: Pipeline analytics, Slack alerts, onboarding on the hire stage, etc.
    elif event_type == "candidate_deleted":
        print(f"Candidate deleted: {candidate_id}")
        # Your code: Erase the candidate in downstream systems.
    elif event_type == "offer_published":
        print(f"Job published: {offer_id}")
    elif event_type == "offer_unpublished":
        print(f"Job unpublished: {offer_id}")
    elif event_type == "offer_updated":
        print(f"Job updated: {offer_id} ({event_subtype})")
    else:
        print(f"Unhandled event: {event_type}")

    # Recruitee treats any status other than 200 as a failure and retries.
    return {"received": True}


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

From hookdeck/webhook-skills ↗

Or install the Recruitee webhooks skill:

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

Common failures

Body parsed before verification

The signature covers the body as sent. Verify against the raw bytes, before any JSON parsing.

Secret decoded

Use the secret as written. Recruitee's worked example passes it straight to openssl, so don't decode it, even if it looks like base64.

Wrong digest format

The header is a plain hex digest with no prefix such as sha256=. A base64 digest of the same HMAC never matches.

Unsigned test request rejected

The docs say all requests carry the header, but their example test request shows none. If **Verify and create** fails on a signature error, let the bare {"test":true} body through with a 200.

From Hookdeck's Recruitee guide

Let Event Gateway verify Recruitee signatures.

Event Gateway verifies the signature on each Recruitee delivery before it reaches your service, then queues it and retries failures on your schedule.

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