Webhooks
Lorsque l’app est en mode HIOBuy warehouse fulfillment, HIOBuy envoie des événements du cycle de vie fulfillment vers votre endpoint HTTPS. Configurez dans Developer Portal → Webhooks . La livraison est asynchrone ; les réponses Public API n’attendent pas votre serveur webhook.
Prérequis: Autorisation canal → mode fulfillment = HIOBuy warehouse. En mode self, intro visible seulement ; création/activation d’Endpoint impossibles.
Vue d’ensemble {#overview}
| Élément | Valeur |
|---|---|
| Transport | POST JSON vers votre endpoint |
| Délai | 10 secondes |
| Succès | HTTP 2xx |
| Secret de signature | whsec_… (affiché une seule fois à la création / rotation) |
| En-tête de signature | HioBuy-Signature |
| En-tête d’ID d’événement | HioBuy-Event-Id |
| User-Agent | HioBuy-Webhooks/1.0 |
| Nouvelles tentatives | jusqu’à 5 essais : immédiat, puis 1m / 5m / 30m / 2h |
| Événements de test | Portail Send test → livemode: false, préfixe id evt_test_ |
Inscription, rotation du secret, historique et retry manuel sont portail uniquement (auth session). Pas d’API Public /v1/webhooks/* en v1.
Catalogue d’événements {#events}
Abonnez-vous par endpoint. Au moins un événement requis.
| Catégorie | Type d’événement | Quand |
|---|---|---|
| Approvisionnement | procurement.failed | Échec d’approvisionnement entrepôt |
| Approvisionnement | procurement.out_of_stock | SKU indisponible à l’approvisionnement |
| Entrepôt | package.received | Colis domestique reçu en entrepôt |
| Entrepôt | package.exception | Exception entrante (data.exception_type) |
| Consolidation | consolidation.completed | Consolidation terminée |
| Expédition | shipment.created | Expédition internationale créée |
| Expédition | shipment.dispatched | Remis au transporteur |
| Expédition | shipment.delivered | Livré au destinataire |
| Expédition | shipment.exception | Exception sortante (data.exception_type) |
| Compte | balance.low | Portefeuille entrepôt sous le seuil |
Le push live warehouse→développeur est déployé progressivement ; validez votre récepteur via Send test dès maintenant.
Envelope public {#envelope}
Chaque corps de livraison est un JSON :
{
"id": "evt_01HXYZ…",
"type": "package.received",
"created_at": "2026-08-16T04:00:00.000Z",
"livemode": true,
"app_id": "app_…",
"data": {
"package_id": "pkg_…",
"order_id": "ord_…",
"status": "received"
}
}| Champ | Type | Description |
|---|---|---|
id | string | ID d’événement public (evt_… live, evt_test_… test) |
type | string | Type du catalogue |
created_at | string | Horodatage ISO-8601 |
livemode | boolean | false pour les tests portail |
app_id | string | ID de votre app |
data | object | Payload spécifique (sans champs internes entrepôt) |
Exemples de data {#data-shapes}
Conformes aux échantillons de test portail ; le live utilise les mêmes clés.
procurement.failed
{
"order_id": "ord_…",
"status": "failed",
"reason": "supplier_rejected"
}package.exception
{
"package_id": "pkg_…",
"order_id": "ord_…",
"status": "exception",
"exception_type": "DAMAGED"
}shipment.dispatched
{
"shipment_id": "shp_…",
"tracking_number": "…",
"status": "dispatched"
}balance.low
{
"available_amount": 12.5,
"currency": "USD",
"threshold": 50
}Livraison HTTP {#delivery}
POST /your/webhook-path HTTP/1.1
Host: your-server.example
Content-Type: application/json
User-Agent: HioBuy-Webhooks/1.0
HioBuy-Event-Id: evt_01HXYZ…
HioBuy-Signature: t=1723780800,v1=abcdef0123456789…- En production, l’URL doit être HTTPS. Hors production,
http://localhost/ tunnels peuvent être autorisés. - Répondez
2xxen 10 s. Sinon retry jusqu’à épuisement. - Livraison at-least-once. Dédupliquez sur
id(et optionnellementHioBuy-Event-Id).
Vérification de signature {#signature}
- Lire
HioBuy-Signature(t=<unix_seconds>,v1=<hex_hmac>). - Construire
"{t}.{raw_body}"oùraw_bodyest le corps brut reçu (JSON UTF-8). - Calculer
HMAC-SHA256(secret, signed_payload)en hex. - Comparer à
v1en temps constant. - Rejeter si
|now - t|trop grand (tolérance recommandée : 5 minutes).
Node.js exemple
import crypto from "node:crypto";
function verifyHioBuySignature(rawBody, signatureHeader, secret, toleranceSec = 300) {
const match = /^t=(\d+),v1=([0-9a-f]+)$/i.exec(signatureHeader || "");
if (!match) return false;
const t = Number(match[1]);
const expected = match[2].toLowerCase();
if (!Number.isFinite(t)) return false;
if (Math.abs(Math.floor(Date.now() / 1000) - t) > toleranceSec) return false;
const signed = `${t}.${rawBody}`;
const digest = crypto
.createHmac("sha256", secret)
.update(signed, "utf8")
.digest("hex");
const a = Buffer.from(digest, "utf8");
const b = Buffer.from(expected, "utf8");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}Stockez
whsec_…uniquement côté serveur. Le portail masque (6 derniers caractères). Après rotation, mettez à jour le serveur avant la prochaine livraison.
Retries et statuts {#retries}
| Tentative | Délai après l’échec précédent |
|---|---|
| 1 | Immédiat (file) |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 heures |
Après le dernier échec : failed. Retry now possible dans le détail portail.
Statuts : pending · success · retrying · failed.
Parcours portail {#portal}
- Passez l’app en warehouse fulfillment via Channel Auth / setup.
- Ouvrez Webhooks → Add endpoint.
- Saisissez l’URL HTTPS, une description optionnelle et les événements.
- Copiez le secret dès l’affichage (une seule fois).
- Utilisez Send test event et inspectez deliveries / attempts.
- Faites pivoter le secret, désactivez ou supprimez si besoin.
Limites et rétention {#limits}
| Limite | Valeur |
|---|---|
| Payload | ≤ 64 KB |
| corps de réponse stocké par attempt | ≤ 4 KB |
| rétention events / deliveries | ~30 jours |
| Attempt | ~14 jours |
Voir aussi
- Fulfillment setup — mode warehouse
- Fulfillment API — expédition internationale
- Authentication — clés API (distinctes du secret webhook)
- Sandbox — les commandes sandbox ne poussent pas automatiquement ; utiliser Send test
Get Support
Need integration help? Contact Developer Support at support@hiobuy.com · Response within 1–2 business days