Skip to content

Local development and webhooks

Your server runs on localhost, but Vendrix delivers webhooks to a public HTTPS URL. A tunnel connects them.

These examples use a placeholder address. Your console shows the exact address of the API for your workspace.

Three addresses to distinguish#

Address roles
URLPurpose
Vendrix /api/public/v1Hosted API called by your server with your key. Not a localhost API.
http://localhost:3000/webhooks/vendrixLocal HTTP POST receiver.
https://your-tunnel.example/webhooks/vendrixPublic HTTPS URL to register in the Vendrix console.

1. Start the local receiver#

Start a Node server on port 3000 with a POST /webhooks/vendrix route. Use the Node receiver and signature verification from the webhook guide. Read the raw body before JSON.parse.

import express from "express";
import { verifyVendrixWebhook } from "./verify-vendrix-webhook";

const app = express();

// Read the body as raw bytes: the signature covers the exact bytes Vendrix sent.
app.post("/vendrix/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const verified = verifyVendrixWebhook({
    secret: process.env.VENDRIX_WEBHOOK_SECRET,
    rawBody: req.body,
    headers: req.headers,
  });
  if (!verified) return res.sendStatus(400);

  const event = JSON.parse(req.body.toString("utf8"));
  // Delivery is at least once: skip an event.id you have already handled.
  // Answer 2xx quickly, then do the work.
  res.sendStatus(200);
});

2. Expose the server over HTTPS#

With cloudflared installed, run the command below in a second terminal. Copy the HTTPS URL it prints and append /webhooks/vendrix.

Terminal
cloudflared tunnel --url http://localhost:3000

3. Configure the webhook#

  1. Developer console → sandbox application → Webhooks → Add.
  2. Paste the full public HTTPS URL, never localhost.
  3. Subscribe to webhook.test and save.
  4. Copy the signing secret shown once and keep it in server environment variables.

4. Send a test event#

Use Send test event in the console, or POST /sandbox/events with an authorized sandbox key.

curl -X POST "https://vendrix-api-7897083941.europe-west4.run.app/api/public/v1/sandbox/events" \
  -H "Authorization: Bearer $VENDRIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "message.received"
  }'

5. Verify and troubleshoot#

  1. Check the POST in the local terminal and verify Vendrix-Signature.
  2. Return 2xx promptly after reliably accepting the event.
  3. Inspect Deliveries in the console and check the HTTP status.
  4. On failure: check the tunnel, route, secret, clock and subscription.