Guide

Webhooks

Get a signed HTTP request on your server whenever a record is created, changed or deleted.

How it works

Open your project and go to Webhooks (Pro plan, up to 10 per project). Add the URL of your server, pick one entity or all of them, and the events you want. From then on, every change to a matching record, from the API, the dashboard, an import or a custom endpoint, is sent to that URL as a POST with a JSON body.

Changes are queued and sent within a few seconds, so your API answers just as fast with or without webhooks. Use Send test to check your receiver, and Recent deliveries to see what was sent and what your server answered.

What you receive

http
POST https://myapp.com/api/codefreeapi-webhook
Content-Type: application/json
X-CodeFreeAPI-Event: record.created
X-CodeFreeAPI-Delivery: 5f0c…
X-CodeFreeAPI-Signature: t=1761480000,v1=6d2f…

{
  "id": "5f0c…",                 // delivery id: the same on retries
  "event": "record.created",     // record.created | record.updated | record.deleted
  "entity": "orders",
  "occurredAt": "2026-10-26T12:00:00.000Z",
  "data": {
    "id": "a1b2…",
    "total": 42,
    "status": "paid",
    "ownerId": "c3d4…",
    "createdAt": "…",
    "updatedAt": "…"
  }
}
FieldMeaning
idThe delivery. Retries send the same id, so you can ignore one you already handled.
eventrecord.created, record.updated or record.deleted
entityName of the entity the record belongs to
dataThe record as the API returns it (for deletes: as it was). Password fields are never included.

Checking the signature

Anyone can send a request to your URL, so check that it came from CodeFreeAPI. Each webhook has a signing secret (shown when you add it, and under Secret). The X-CodeFreeAPI-Signature header holds a timestamp t and v1, the hex HMAC-SHA256 of "<t>.<raw body>" with that secret.

Node.js / Express
import crypto from 'crypto';
import express from 'express';

const app = express();

// Use the raw body: the signature is over the exact bytes that were sent
app.post('/api/codefreeapi-webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const header = req.get('X-CodeFreeAPI-Signature') || '';
  const { t, v1 } = Object.fromEntries(header.split(',').map((part) => part.split('=')));
  const expected = crypto
    .createHmac('sha256', process.env.CODEFREEAPI_WEBHOOK_SECRET)
    .update(`${t}.${req.body}`)
    .digest('hex');

  const valid =
    v1 && v1.length === expected.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300; // reject replays older than 5 minutes
  if (!valid || !fresh) return res.status(400).send('Bad signature');

  const event = JSON.parse(req.body);
  // ... handle event.event / event.data; skip event.id values you already handled
  res.sendStatus(200);
});

Keep the secret on the server

Store it like a password (an environment variable), never in frontend code. If it leaks, make a new one with the rotate button; the old one stops working at once.

Retries

Answer with any 2xx status within 10 seconds to confirm. Anything else (an error status, a timeout, no connection) is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours. After that the delivery is marked failed; you can send it again from the delivery list.

A webhook that fails 50 times in a row is switched off so it doesn't pile up. Fix your receiver, then switch it back on in the dashboard.

Tips

  • Answer quickly and do slow work (emails, other APIs) afterwards, so the 10-second limit is never a problem.
  • Deliveries can arrive more than once and, after retries, out of order. Use the delivery id and the record's updatedAt.
  • The URL must be public (http or https on the normal ports). To try it locally, use a tunnel such as ngrok or cloudflared.
  • Want to call another service from inside your API instead? Use an HTTP request step in a custom endpoint.