Quickstart: Webhooks
Quickstart: Webhooks
Quickstart: Webhooks
This guide demonstrates how to set up and test Persona webhooks.
You’ll create a simple local webhook server with one endpoint that receives webhook events. You’ll configure Persona to send events to this endpoint.
The server implementation below is meant for learning purposes only—not production usage.
For demonstration purposes, we will keep the server simple:
When you test webhooks that contain real production data, your server should run in a secure environment you control with appropriate authentication, validation, and logging.
You’ll need access to:
Before you start, you should:
Create a new directory called webhook-demo/.
Add the sample code below to create a local server:
webhook-demo/webhook-server.js:webhook-demo/package.json:Now, test the server:
You should receive “Webhook received successfully” from the server. In the server logs, you should see the request headers and body.
Follow ngrok’s documentation to install ngrok locally and configure it with your ngrok authtoken.
Then expose your webhook server to the internet:
Note your ngrok domain (e.g. http://abs123.ngrok-free.dev). You’ll need this in the next step.
In the Persona dashboard:
URL: <your ngrok domain>/webhookEnabled events: inquiry.created, inquiry.started, inquiry.completed, inquiry.approvedAt the top of the resulting page:
You selected inquiry-related events in your webhook. Now, create an inquiry and interact with it to trigger events.
In the Persona dashboard (still in your Sandbox environment):
Look at your server logs. You should see events for: inquiry.created, inquiry.started, and inquiry.completed.
You may also see an event for inquiry.approved if your inquiry template has an associated Workflow that takes action on completed inquiries.
In the previous step, you saw the webhook request headers printed in your server logs:
Look at the persona- prefixed headers. These headers provide information about:
You need to implement logic in your server to check the Persona signature. Let’s do that next.
The value of the persona-signature header consists of a timestamp (t=<unix_timestamp>) plus a signature (v1=<signature>).
The signature is computed from your webhook secret (which you found in Step 3) and a dot-separated string composed of the unix timestamp joined with the request body.
Update your server code to verify the signature:
webhook-demo/webhook-server.js:Or paste it directly into the code for testing only.
Repeat Steps 4 and 5: Create another inquiry in Sandbox and complete it, then check your server logs for events.
This time, you should see the server log ”✅ Signature verified” for each event.
You can also send a fake webhook request, and check that the server logs ”❌ Invalid signature”:
In this tutorial, you:
To learn more, check out the following resources: