QA
Beginner LevelREST APIs & Web Services

How do Webhook HTTP Callbacks deliver real-time event notifications?

❓ Interview Prompt: Explain Webhooks, event-driven HTTP callbacks, provider POST notifications, HMAC signature verification (`X-Signature`), and idempotency.

Webhooks are automated HTTP 'POST' callbacks sent by a service provider to a client's server when an event occurs (e.g. Stripe payment succeeded):

Webhook Architecture:

1
Registration: Client registers a callback URL (e.g. 'https://my-app.com/api/webhooks/stripe').
2
Event Trigger: When an event occurs, provider sends an HTTP 'POST' request with JSON event payload.
3
HMAC Signature Verification: Receiver verifies 'X-Signature' header using a shared secret to ensure payload authenticity!

Code Implementation Example

typescript
import crypto from 'crypto';

export function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature));
}
💡Verifying HMAC webhook payload signatures in TypeScript.
🎯 Interview Key Takeaway

Webhooks deliver real-time event notifications via HTTP POST callbacks; receivers must verify HMAC signatures for security.

#Webhooks#HMAC#Event-Driven#Beginner
Back to all REST APIs & Web Services Questions→

More REST APIs & Web Services Interview Questions

Beginner LevelREST APIs & Web Services

What is HTTP Method Idempotency and how do you implement Idempotency Keys for REST APIs?

Beginner LevelREST APIs & Web Services

What are standard HTTP Status Codes (200, 201, 204, 400, 401, 403, 404, 409, 429, 500, 503)?

Beginner LevelREST APIs & Web Services

What are HTTP Verbs (GET, POST, PUT, PATCH, DELETE) and when to use PUT vs PATCH?