Skip to content

Instantly share code, notes, and snippets.

@ajbonner
Created September 22, 2025 09:17
Show Gist options
  • Save ajbonner/f3304d6749d1396496fcec2aa9c47bb2 to your computer and use it in GitHub Desktop.
Save ajbonner/f3304d6749d1396496fcec2aa9c47bb2 to your computer and use it in GitHub Desktop.
Postman Pre-Request HMAC256 Signature Generation
const CryptoJS = require("crypto-js");
const requestBody = pm.request.body.raw;
const secretKey = pm.environment.get("WEBHOOK_SIGNATURE_KEY");
if (requestBody && secretKey) {
const hmac = CryptoJS.HmacSHA256(requestBody, secretKey).toString();
pm.environment.set("WEBHOOK_REQ_SIGNATURE", hmac);
console.log("Generated HMAC Signature:", hmac);
} else {
console.error("Error: Request body or 'secretKey' environment variable is missing.");
pm.execution.setNextRequest(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment