Skip to main content
The Webhook event system is continuously evolving. The event types and signature formats shown in this document represent the recommended implementation patterns — refer to the latest platform documentation for specifics.

What You’ll Build

This tutorial walks you through building a Webhook receiver service that securely receives and processes real-time events pushed by the Profy platform. You’ll implement signature verification, event dispatching, idempotent processing, and asynchronous consumption.

Webhook Event Types

JSON structure of each Webhook request:

Prerequisites

Profy App

Created an App in Profy Studio and obtained the Client ID

Webhook URL

Configured a publicly accessible Webhook receiver URL in Studio

Webhook Secret

Obtained the Webhook signing secret from Studio (used to verify request origin)

Step 1: Register the Webhook URL

Complete the Webhook configuration in Profy Studio:
  1. Go to App Management → Select your App → Webhook Settings
  2. Enter your Webhook receiver URL (e.g., https://your-app.com/api/webhook)
  3. Select the event types you want to subscribe to
  4. Save and copy the auto-generated Webhook Secret
.env
The Webhook Secret is the sole credential for verifying request origin. Keep it safe — never commit it to version control or expose it to clients.

Step 2: Create the Webhook Receiver Endpoint

Return 200 first, then process asynchronously. The Profy platform triggers retries when it doesn’t receive a response in time — responding quickly prevents duplicate deliveries.

Step 3: Verify Signatures

Profy signs the request body using HMAC-SHA256, with the signature passed via the X-Profy-Signature header. The format is sha256=<hex_digest>.
You must use timingSafeEqual (Node) or hmac.compare_digest (Python) for comparison. Regular string comparison is vulnerable to timing attacks.

Step 4: Handle Events

Dispatch to the appropriate handler based on event_type.

Step 5: Idempotent Processing

Network issues or timeout retries can cause the same event to be delivered multiple times. Use event_id for idempotent deduplication.
Add idempotency checks to the main processing flow:
If you don’t have Redis, you can also achieve idempotency using a database UNIQUE(event_id) constraint. A failed insert indicates the event was already processed.

Step 6: Response and Retry Behavior

Response Guidelines

Best Practices

Do not perform time-consuming operations (such as database writes or external API calls) before returning 200. The Profy platform’s delivery timeout is 10 seconds.

Local Development and Debugging

During local development, the Webhook URL needs to be publicly accessible. Use a tunnel tool to expose your local port to the internet.
After obtaining the temporary public URL, enter it in the Profy Studio Webhook URL configuration (e.g., https://abc123.ngrok-free.app/api/webhook).
During debugging, you can view the request/response details and retry history of each delivery in the Profy Studio Webhook logs.

Complete Example

Here’s a complete, ready-to-run example:

Security Best Practices

Always Verify Signatures

Every request must pass HMAC-SHA256 signature verification — reject all unsigned or incorrectly signed requests

Use HTTPS

The Webhook URL must use HTTPS to prevent request content from being intercepted or tampered with in transit

Idempotent Processing

Use event_id for deduplication to ensure the same event is only processed once even if delivered multiple times

Timeout Protection

Return 200 within 10 seconds. Move time-consuming logic to a background queue to avoid blocking responses and triggering retries
Additional recommendations:
  • IP Allowlisting: If your firewall supports it, only allow traffic from Profy platform egress IP ranges
  • Secret Rotation: Periodically regenerate the Webhook Secret in Studio and smoothly transition on the application side (support verifying both old and new Secrets during the transition period)
  • Logging and Monitoring: Log the event_id, processing result, and latency for each Webhook to help troubleshoot missed or delayed events

Next Steps

Next.js Full-Stack Integration

OAuth login + Token management + billing event reporting

Per-Use Billing SaaS

PER_USE mode: fixed-price per-use billing

Events API Reference

View the complete Events API documentation

Token Management Best Practices

Concurrent refresh, secure storage, degradation strategies