Pour les développeurs

Guide des webhooks

Recevez les événements PODFY sur votre propre serveur et vérifiez que chaque requête est authentique : signature, nouvelles tentatives et exemples de code.

Ce qu'est un webhook ici

Un webhook est une requête que PODFY envoie à votre serveur dès qu'il se passe quelque chose : une preuve de livraison ou un signalement arrive, un statut de traitement change ou un remboursement est approuvé. Vous n'avez pas à interroger l'API en continu. Chaque requête est signée : votre serveur peut ainsi vérifier qu'elle vient bien de PODFY et n'a pas été modifiée en chemin.

Cette page explique comment recevoir les webhooks. Les événements et le format du corps de la requête figurent dans la référence ci-dessous, en anglais, comme la référence de l'API. L'API REST est décrite dans la référence de l'API.

Configurer et tester un webhook

Un administrateur de votre marque ajoute un webhook dans le portail (en anglais), sous Settings → Integrations → Webhooks, avec Add webhook. Saisissez l'adresse HTTPS de votre récepteur et choisissez les événements. Le secret avec lequel PODFY signe n'est affiché qu'une fois : conservez-le dans votre gestionnaire de secrets. Avec New secret, vous créez un nouveau secret : l'ancien reste valable 24 heures, ce qui vous laisse le temps de basculer votre récepteur sans manquer une requête.

Avec Send test, PODFY envoie un événement webhook.test avec les vrais en-têtes et la vraie signature à votre adresse, pour que vous puissiez tester votre vérification avant l'arrivée d'événements réels. Le journal des envois du portail affiche le code de réponse de chaque tentative, et Resend renvoie un envoi.

Si vous n'avez pas encore de récepteur, demandez au support PODFY une boîte de test. Elle accepte les requêtes signées et montre ce qui est arrivé. Selon son réglage QA, un webhook reçoit soit les enregistrements de production, soit uniquement les enregistrements de test de qa.podfy.app.

Où PODFY envoie

PODFY n'envoie qu'à des adresses HTTPS dont le nom d'hôte est public, sur le port 443. Les adresses IP, les adresses avec identifiant ou mot de passe, les hôtes de PODFY lui-même et les hôtes sous workers.dev ou pages.dev sont refusés à l'enregistrement. PODFY ne suit pas les redirections : indiquez donc l'adresse finale.

Un webhook peut aussi utiliser GET avec sa propre chaîne de requête (charge utile personnalisée). La signature couvre alors l'URL complète, voir la référence.

Référence

Recevoir les webhooks

La référence ci-dessous reste en anglais dans toutes les langues, comme la référence de l'API.

Events

A webhook subscribes to the events it lists, or to all standard events with *. * never matches the refund events: list refund.approved and refund.updated by name.

EventSent whenNotes
pod.createdA new record of a brand in delivery mode (a proof of delivery was uploaded).
report.createdA new record of a brand in report mode (a QR report was submitted).
record.status_changedThe work status of a record changed (portal, bulk change or API).Adds change.
record.updatedAnother field of a record changed: assignee, priority or duplicate_of. One event per changed field. A comment alone sends nothing.Adds change.
webhook.testA brand admin pressed Send test in the portal.A sample or the latest record, with the real headers and signature.
refund.approvedA refund request was approved. PODFY records and forwards the request; it never pays out.Only when the webhook lists it by name. Adds record.refund.
refund.updatedA refund was rejected, or its payout result (paid or failed) was recorded through the API.Only when the webhook lists it by name. Adds record.refund.

The request

PODFY sends a signed request to your URL for every event (POST with a JSON body, or GET for a custom webhook).

HeaderValue
Podfy-Signaturet=<unix seconds>,v1=<hex>,v2=<hex>. See Verify the signature.
Podfy-DeliveryUnique delivery id (dlv_…). Identical on every retry of the same delivery.
Podfy-EventThe event name, as in the body.
Content-Typeapplication/json for the standard payload. A custom webhook sends the content type you chose.
User-AgentPODFY-Webhooks/1.0

The payload

This is the standard body. A custom webhook sends the body you built from the template.

FieldTypeDescription
idstringEvent id (evt_…). Use it as an idempotency key.
versionintegerPayload format version, 1. Bumped only for a breaking change; new fields do not bump it.
eventstringOne of the events above.
created_atstringISO 8601 time of the event.
brandstringThe brand slug.
recordobjectThe record: podfy_id, mode, reference, asset, category, priority, work_status, note, fields, group_id, files, location, duplicate_of, url and updated_at (time of the last change of the record).
changeobjectOnly on record.status_changed and record.updated: {field, from, to}.
record.refundobjectOnly on refund.approved and refund.updated: {id, amount, currency, pay_ref, status, decided_at, result}. Use refund.id as your idempotency key. The approver's e-mail is never included.

Example: report.created

{
  "id": "evt_5d1e8a07b3c94f2a61d0e7f8",
  "version": 1,
  "event": "report.created",
  "created_at": "2026-11-16T09:24:00Z",
  "brand": "acme",
  "record": {
    "podfy_id": "PFY-7Q4K2-1",
    "mode": "report",
    "reference": "COFFEE-1",
    "asset": {
      "name": "Coffee machine",
      "location": "Floor 2",
      "group": "B"
    },
    "category": "NOT_WORKING",
    "priority": "high",
    "work_status": "new",
    "note": "Makes a grinding noise",
    "fields": {
      "floor": "2"
    },
    "group_id": "PFY-7Q4K2",
    "files": [
      {
        "name": "photo.jpg",
        "url": "https://portal.podfy.net/api/public/pod/3f9a0c1d2e4b5a69/file"
      }
    ],
    "location": null,
    "duplicate_of": null,
    "url": "https://portal.podfy.net/pod/3f9a0c1d2e4b5a69",
    "updated_at": "2026-11-16T09:24:00Z"
  }
}

Verify the signature

Check every request before you trust it. You need the secret of the webhook, the Podfy-Signature and Podfy-Delivery headers and the raw request body.

  1. Split Podfy-Signature at the commas. Take t and every v1 and v2 value.
  2. Reject the request when t is more than 5 minutes (300 seconds) away from your clock.
  3. Compute v2 = HMAC-SHA256 (hex) with your secret of t + "." + delivery id + "." + raw body, where the delivery id is the Podfy-Delivery header. This is recommended: it also binds the delivery id, so a captured request cannot be replayed under another one.
  4. v1 = HMAC-SHA256 (hex) of t + "." + raw body. It stays valid and is what you check when you do not use the delivery id.
  5. Compare your value with the received one in constant time. Accept the request when any received pair matches (during a rotation there are two pairs).
  6. Answer with a 2xx status. A request that fails verification should get a 4xx and no further processing.

Sign the raw bytes. Parsing the JSON and serialising it again changes spacing and key order, and the signature will not match. A GET webhook has no body: the signed content is the full request URL as sent, including the query string.

Worked example

Secret, delivery id and body below are an example you can run your code against. The body is the exact string that was signed. Every character counts, so use the raw bytes you receive.

PartValue
Secretwhsec_0123456789abcdef0123456789abcdef0123456789abcdef
t1795000000
Podfy-Deliverydlv_3f9a0c1d2e4b5a69c0de

Body

{"id":"evt_5d1e8a07b3c94f2a61d0e7f8","version":1,"event":"report.created","created_at":"2026-11-16T09:24:00Z","brand":"acme","record":{"podfy_id":"PFY-7Q4K2-1","mode":"report","reference":"COFFEE-1","asset":{"name":"Coffee machine","location":"Floor 2","group":"B"},"category":"NOT_WORKING","priority":"high","work_status":"new","note":"Makes a grinding noise","fields":{"floor":"2"},"group_id":"PFY-7Q4K2","files":[{"name":"photo.jpg","url":"https://portal.podfy.net/api/public/pod/3f9a0c1d2e4b5a69/file"}],"location":null,"duplicate_of":null,"url":"https://portal.podfy.net/pod/3f9a0c1d2e4b5a69","updated_at":"2026-11-16T09:24:00Z"}}

Podfy-Signature

t=1795000000,v1=7a4613e656dc09602ed02650fc2439d25640c0e0af5e7964446ac850feb81a0d,v2=32cb0d5cef76e5d988b540c71b54aea8047766be7cc9eb761a950c0deab398a9

With a rotation in progress the header holds a second v1/v2 pair made with the previous secret, for example t=…,v1=A,v2=A,v1=B,v2=B.

Code samples

Both samples use only the standard library of the language. They check the timestamp, compare in constant time, prefer v2 when the delivery id is available and accept any matching pair.

Node.js: verify.js

const crypto = require("node:crypto");

// rawBody: the request body exactly as received (Buffer), never re-serialised JSON.
// For a GET webhook pass the full request URL instead of a body.
function verifyPodfyWebhook(secret, signatureHeader, deliveryId, rawBody, nowSeconds = Math.floor(Date.now() / 1000)) {
  let t = null;
  const v1 = [];
  const v2 = [];
  for (const part of String(signatureHeader || "").split(",")) {
    const i = part.indexOf("=");
    if (i < 1) continue;
    const key = part.slice(0, i).trim();
    const value = part.slice(i + 1).trim();
    if (key === "t") t = value;
    else if (key === "v1") v1.push(value);
    else if (key === "v2") v2.push(value);
  }
  const timestamp = Number(t);
  if (!t || !Number.isFinite(timestamp)) return false;
  if (Math.abs(nowSeconds - timestamp) > 300) return false; // older (or newer) than 5 minutes

  const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(String(rawBody), "utf8");
  const sign = (prefix) =>
    crypto.createHmac("sha256", secret).update(prefix).update(body).digest("hex");
  const equal = (a, b) =>
    a.length === b.length && crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b));

  // v2 also binds the delivery id (recommended). During a secret rotation the header holds two pairs:
  // accept the request when any of them matches.
  if (deliveryId && v2.length) {
    const expected = sign(`${t}.${deliveryId}.`);
    return v2.some((candidate) => equal(expected, candidate));
  }
  const expected = sign(`${t}.`);
  return v1.some((candidate) => equal(expected, candidate));
}

module.exports = { verifyPodfyWebhook };

Node.js: a receiver

const http = require("node:http");
const { verifyPodfyWebhook } = require("./verify");

const secret = process.env.PODFY_WEBHOOK_SECRET;
const seen = new Set(); // use a database or cache with an expiry in production

http.createServer((req, res) => {
  const chunks = [];
  req.on("data", (chunk) => chunks.push(chunk));
  req.on("end", () => {
    const rawBody = Buffer.concat(chunks);
    const ok = verifyPodfyWebhook(secret, req.headers["podfy-signature"], req.headers["podfy-delivery"], rawBody);
    if (!ok) { res.writeHead(400).end(); return; }

    res.writeHead(200).end("ok"); // answer within 10 seconds, then process
    const event = JSON.parse(rawBody.toString("utf8"));
    if (seen.has(event.id)) return; // a retry of an event you already handled
    seen.add(event.id);
    console.log(event.event, event.record.podfy_id);
  });
}).listen(3000);

Python: verify.py

import hashlib
import hmac
import time


def verify_podfy_webhook(secret, signature_header, delivery_id, raw_body, now=None):
    """raw_body: the request body as bytes, exactly as received (for a GET webhook: the full URL as bytes)."""
    t, v1, v2 = None, [], []
    for part in (signature_header or "").split(","):
        key, _, value = part.strip().partition("=")
        if key == "t":
            t = value
        elif key == "v1":
            v1.append(value)
        elif key == "v2":
            v2.append(value)
    try:
        timestamp = int(t)
    except (TypeError, ValueError):
        return False
    if abs((time.time() if now is None else now) - timestamp) > 300:  # older (or newer) than 5 minutes
        return False

    def sign(prefix):
        return hmac.new(secret.encode(), prefix.encode() + raw_body, hashlib.sha256).hexdigest()

    # v2 also binds the delivery id (recommended). During a secret rotation the header holds two pairs:
    # accept the request when any of them matches.
    if delivery_id and v2:
        expected, candidates = sign(f"{t}.{delivery_id}."), v2
    else:
        expected, candidates = sign(f"{t}."), v1
    return any(hmac.compare_digest(expected, c) for c in candidates)

Python: a receiver

from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import os

SECRET = os.environ["PODFY_WEBHOOK_SECRET"]
seen = set()  # use a database or cache with an expiry in production


class Handler(BaseHTTPRequestHandler):
    def do_POST(self):
        raw_body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
        ok = verify_podfy_webhook(SECRET, self.headers.get("Podfy-Signature"), self.headers.get("Podfy-Delivery"), raw_body)
        self.send_response(200 if ok else 400)
        self.end_headers()
        if not ok:
            return
        event = json.loads(raw_body)  # answered first in real code: queue the work
        if event["id"] in seen:  # a retry of an event you already handled
            return
        seen.add(event["id"])
        print(event["event"], event["record"]["podfy_id"])


HTTPServer(("", 3000), Handler).serve_forever()

Secret rotation

When a brand admin creates a new secret (New secret in the portal), the previous secret stays valid for 24 hours. During that time every request carries a second v1/v2 pair signed with the previous secret. Accept the request when any pair matches: a receiver that still has the old secret and one that already has the new secret both verify. After 24 hours only the new secret signs.

Delivery, retries and idempotency

  • Answer with any 2xx status within 10 seconds. Anything else, a timeout or a network error counts as a failure. Redirects are not followed. Answer first and process afterwards.
  • A failed delivery is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours. After that it is marked failed. A delivery that stays pending is put back in the queue automatically. The delivery log in the portal shows every attempt, and Resend sends a delivery again by hand.
  • A delivery can arrive more than once (a retry after a timeout, or a resend). Treat the event id (and the Podfy-Delivery header) as the idempotency key: store the ids you handled and ignore a repeat. For refunds use record.refund.id.
  • Events of one record can arrive out of order. Use record.updated_at to ignore an older event.
  • Receivers must tolerate new fields. New fields are added without a new version; only a breaking change raises version.
  • A webhook with a custom payload sends your own body and content type. The headers and the signature are the same, and the signature covers the body as sent.

Allowed targets

  • HTTPS only, on port 443, with a public host name. No IP addresses, no user name or password in the URL, no podfy.app or podfy.net hosts (except a PODFY test inbox address), no workers.dev or pages.dev, no local or internal host names.
  • The address is checked when you save the webhook. Variables of a custom payload are allowed in the query string and the body only, never in the scheme, host or path.