Webhooks
Recevez un evenement HTTP sur votre propre URL plutot que de sonder l'API.
Creer un webhook
http
POST /v1/webhooksjson
{
"url": "https://votre-app.exemple.com/webhooks/emini",
"events": ["job.completed", "job.failed"]
}json
{
"webhook": { "id": "...", "url": "https://votre-app.exemple.com/webhooks/emini", "events": ["job.completed", "job.failed"], "status": "active" },
"secret": "whsec_..."
}secret n'est renvoye qu'une seule fois, a la creation. Conservez-le pour verifier la signature des livraisons.Evenements disponibles
job.completed— un job asynchrone (video) s'est termine avec succesjob.failed— un job asynchrone a echouebudget.alert— un seuil d'alerte de budget projet a ete franchi
Verifier la signature
Chaque livraison inclut un en-tete X-Emini-Signature : un HMAC-SHA256 du corps brut de la requete, calcule avec votre secret.
Node.jstypescript
import crypto from "node:crypto";
function isValid(rawBody: string, signature: string, secret: string): boolean {
const expected = crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}Gerer les webhooks
bash
GET /v1/webhooks # lister
DELETE /v1/webhooks/{webhook_id} # desactiver
GET /v1/webhooks/{webhook_id}/deliveries # historique des livraisonsAlternative : sondage
Les webhooks sont optionnels — GET /v1/jobs/{job_id} reste toujours disponible pour sonder activement l'etat d'un job (voir le guide Video).