Verify Salesloft webhooks

Each delivery carries an x-salesloft-signature header: the hex HMAC-SHA1 of the request body, keyed with the callback_token you chose for the subscription. It shows the request came from someone holding that token and that the body hasn't changed. Salesloft documents no timestamp, so the signature doesn't limit how long a captured request stays valid.

The facts

Signature header
x-salesloft-signature

Format: <hex digest>

Scheme
HMAC-SHA1
Signed material
{raw body}

The request body as sent. Salesloft's page calls it the "response body", which in context means the body it delivers to you.

What to build
Recompute a digest over the raw body and compare
Key
shared secret

Salesloft webhook secret

The subscription's callback_token, a string you choose when you create the subscription. Salesloft doesn't generate a secret for you. Keep it in an environment variable, not in source code.

  • callback_token is required when you create a subscription, and can be any string. Generate a long random one.
  • Each subscription covers one event_type and has its own token. Reuse one token across subscriptions that share a URL, or map x-salesloft-event to the right token.
  • The Webhook Subscriptions API returns callback_token in its responses, so you can check which token a subscription uses.
  • Rotation isn't documented. The update endpoint's schema accepts only enabled, so changing a token means creating a new subscription and deleting the old one.

Source: Salesloft docs ↗

Code

Docs discrepancy · read before the code

The subscription schema says callback_token is sent in the payload of each event, but the only published body, for link_swap, has no callback_token field.

Salesloft docs ↗
express/src/index.js
javascript
require('dotenv').config({ quiet: true });
const express = require('express');
const crypto = require('crypto');

const app = express();

/**
 * Verify a Salesloft webhook signature.
 *
 * Salesloft sends x-salesloft-signature = hex(HMAC-SHA1(callback_token, rawBody)).
 * There is no timestamp and no prefix.
 *
 * @param {Buffer|string} rawBody - Raw request body
 * @param {string|undefined} signature - x-salesloft-signature header value
 * @param {string|undefined} callbackToken - callback_token of the subscription
 * @returns {boolean} - Whether the signature is valid
 */
function verifySalesloftSignature(rawBody, signature, callbackToken) {
  if (!signature || !callbackToken) {
    return false;
  }

  const expected = crypto
    .createHmac('sha1', callbackToken)
    .update(rawBody)
    .digest('hex');

  // Timing-safe comparison; throws on length mismatch
  try {
    return crypto.timingSafeEqual(
      Buffer.from(signature.trim().toLowerCase()),
      Buffer.from(expected)
    );
  } catch {
    return false;
  }
}

/**
 * Handle a verified event. The event name is in the x-salesloft-event header.
 */
function handleSalesloftEvent(eventType, payload) {
  switch (eventType) {
    case 'person_created':
      console.log('Person created');
      // Your code: Sync the new person to your CRM or data warehouse
      break;

    case 'person_updated':
      console.log('Person updated');
      // Your code: Update your copy of the person
      break;

    case 'call_created':
      console.log('Call created');
      // Your code: Log the call activity
      break;

    case 'email_updated':
      console.log('Email updated');
      // Your code: Track opens, clicks, and replies
      break;

    case 'meeting_booked':
      console.log('Meeting booked');
      // Your code: Notify the account owner or create a calendar event
      break;

    case 'cadence_membership_created':
      console.log('Cadence membership created');
      // Your code: Record that a person was added to a cadence
      break;

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

// Salesloft webhook endpoint - must use the raw body for signature verification.
// type: '*/*' reads the body as a Buffer whatever the Content-Type is.
app.post('/webhooks/salesloft',
  express.raw({ type: '*/*' }),
  (req, res) => {
    const callbackToken = process.env.SALESLOFT_CALLBACK_TOKEN;
    if (!callbackToken) {
      console.error('SALESLOFT_CALLBACK_TOKEN is not configured');
      return res.status(500).send('Webhook secret not configured');
    }

    const signature = req.headers['x-salesloft-signature'];
    if (!signature) {
      return res.status(400).send('Missing x-salesloft-signature header');
    }

    const rawBody = Buffer.isBuffer(req.body) ? req.body : Buffer.from('');
    if (!verifySalesloftSignature(rawBody, signature, callbackToken)) {
      console.error('Salesloft webhook signature verification failed');
      return res.status(400).send('Invalid signature');
    }

    // Parse only after verification
    let payload;
    try {
      payload = JSON.parse(rawBody.toString('utf8'));
    } catch {
      return res.status(400).send('Invalid JSON');
    }

    handleSalesloftEvent(req.headers['x-salesloft-event'], payload);

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

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

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

// 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/salesloft`);
  });
}
nextjs/app/webhooks/salesloft/route.ts
typescript
import { NextRequest, NextResponse } from 'next/server';
import { verifySalesloftSignature } from '../../../lib/verify-salesloft';

// The event name is in the x-salesloft-event header; the body is the resource object
function handleSalesloftEvent(eventType: string | null, payload: unknown) {
  switch (eventType) {
    case 'person_created':
      console.log('Person created');
      // Your code: Sync the new person to your CRM or data warehouse
      break;

    case 'person_updated':
      console.log('Person updated');
      // Your code: Update your copy of the person
      break;

    case 'call_created':
      console.log('Call created');
      // Your code: Log the call activity
      break;

    case 'email_updated':
      console.log('Email updated');
      // Your code: Track opens, clicks, and replies
      break;

    case 'meeting_booked':
      console.log('Meeting booked');
      // Your code: Notify the account owner or create a calendar event
      break;

    case 'cadence_membership_created':
      console.log('Cadence membership created');
      // Your code: Record that a person was added to a cadence
      break;

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

export async function POST(request: NextRequest) {
  const callbackToken = process.env.SALESLOFT_CALLBACK_TOKEN;
  if (!callbackToken) {
    console.error('SALESLOFT_CALLBACK_TOKEN is not configured');
    return NextResponse.json({ error: 'Webhook secret not configured' }, { status: 500 });
  }

  const signature = request.headers.get('x-salesloft-signature');
  if (!signature) {
    return NextResponse.json({ error: 'Missing x-salesloft-signature header' }, { status: 400 });
  }

  // Raw body for signature verification - don't use request.json() first
  const rawBody = await request.text();
  if (!verifySalesloftSignature(rawBody, signature, callbackToken)) {
    console.error('Salesloft webhook signature verification failed');
    return NextResponse.json({ error: 'Invalid signature' }, { status: 400 });
  }

  // Parse only after verification
  let payload: unknown;
  try {
    payload = JSON.parse(rawBody);
  } catch {
    return NextResponse.json({ error: 'Invalid JSON' }, { status: 400 });
  }

  handleSalesloftEvent(request.headers.get('x-salesloft-event'), payload);

  return NextResponse.json({ received: true });
}
fastapi/main.py
python
import hashlib
import hmac
import json
import os
from typing import Optional

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

load_dotenv()

app = FastAPI()


def verify_salesloft_signature(
    raw_body: bytes, signature: Optional[str], callback_token: Optional[str]
) -> bool:
    """Verify a Salesloft webhook signature.

    Salesloft sends x-salesloft-signature = hex(HMAC-SHA1(callback_token, rawBody)).
    There is no timestamp and no prefix.
    """
    if not signature or not callback_token:
        return False

    expected = hmac.new(callback_token.encode("utf-8"), raw_body, hashlib.sha1).hexdigest()
    # Timing-safe comparison (compare_digest needs ASCII-only str inputs)
    return hmac.compare_digest(signature.strip().lower().encode("utf-8"), expected.encode("utf-8"))


def handle_salesloft_event(event_type: Optional[str], payload: object) -> None:
    """Handle a verified event. The event name is in the x-salesloft-event header."""
    if event_type == "person_created":
        print("Person created")
        # Your code: Sync the new person to your CRM or data warehouse

    elif event_type == "person_updated":
        print("Person updated")
        # Your code: Update your copy of the person

    elif event_type == "call_created":
        print("Call created")
        # Your code: Log the call activity

    elif event_type == "email_updated":
        print("Email updated")
        # Your code: Track opens, clicks, and replies

    elif event_type == "meeting_booked":
        print("Meeting booked")
        # Your code: Notify the account owner or create a calendar event

    elif event_type == "cadence_membership_created":
        print("Cadence membership created")
        # Your code: Record that a person was added to a cadence

    else:
        print(f"Unhandled Salesloft event: {event_type}")


@app.post("/webhooks/salesloft")
async def salesloft_webhook(request: Request):
    callback_token = os.environ.get("SALESLOFT_CALLBACK_TOKEN")
    if not callback_token:
        raise HTTPException(status_code=500, detail="Webhook secret not configured")

    signature = request.headers.get("x-salesloft-signature")
    if not signature:
        raise HTTPException(status_code=400, detail="Missing x-salesloft-signature header")

    # Raw body for signature verification - don't parse JSON first
    raw_body = await request.body()
    if not verify_salesloft_signature(raw_body, signature, callback_token):
        raise HTTPException(status_code=400, detail="Invalid signature")

    # Parse only after verification
    try:
        payload = json.loads(raw_body)
    except ValueError:
        raise HTTPException(status_code=400, detail="Invalid JSON")

    handle_salesloft_event(request.headers.get("x-salesloft-event"), payload)

    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 Salesloft webhooks skill:

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

Common failures

SHA-256 instead of SHA-1

Salesloft uses SHA-1, so a verifier copied from a provider that uses SHA-256 never matches.

Wrong key

The key is the subscription's callback_token, not your OAuth token or API key. If subscriptions use different tokens, use the one for this event. The Webhook Subscriptions API returns it.

Body parsed before verification

Parsing and re-serializing JSON changes the bytes. Compute the digest over the raw request body.

From Hookdeck's Salesloft guide

Let Event Gateway verify Salesloft signatures.

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

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