Receive webhooks reliably
Trainingym delivers events at-least-once and without ordering guarantees. Three habits make your integration robust: respond fast, deduplicate, and tolerate unknown fields.
Respond with 2xx, quickly
A delivery is considered successful when your endpoint returns any 2xx within 10 seconds. Enqueue heavy work and acknowledge immediately — a timeout counts as a failure and triggers retries.
app.MapPost("/webhooks", async (WebhookEnvelope evt, IQueue queue) =>
{
if (await queue.isDuplicate(evt.idEvent))
return Results.Ok(); // already processed → still 2xx
await queue.enqueue(evt); // process in the background
return Results.Ok();
});
Deduplicate with idEvent
Retries mean the same event can arrive more than once. Treat idEvent as the idempotency
key: if you have seen it, skip processing and still return 2xx.
Know the retry schedule
Any non-2xx response or timeout re-schedules the delivery on this backoff, up to 14 retries:
| Attempt | Delay |
|---|---|
| 1–2 | 1m · 2m |
| 3–4 | 10m · 30m |
| 5–9 | 1h → 2h → 4h → 8h → 12h |
| 10–14 | every 1 day |
Be forward-compatible
New fields may be added to payloads over time. Parse leniently and ignore what you don't recognize — do not fail a delivery because of an unexpected field.
Checklist
- Endpoint returns 2xx within 10 seconds
- Long work is queued, not done inline
-
idEventis stored and checked before processing - Unknown fields are ignored, not rejected