Webhooks: Get Try-On Results Pushed
Get a signed POST when a virtual try-on job completes or fails. Set up the endpoint, verify the signature, handle retries and rotate the secret.
Instead of polling, you can have us POST an event to your server when a photo try-on job finishes. Every event is signed, so your server can check that it came from TryItOn and wasn't changed on the way.
- Events are sent for photo try-ons made with an API key:
tryon.completedandtryon.failed. Each job sends exactly one of them. - Storefront widget jobs and live sessions don't send events.
- Polling keeps working. A webhook only saves you the loop. See Jobs & Polling.
Set up an endpoint
Add a route to your server that accepts POST requests with a JSON body. It must use HTTPS on a public host.
The code is under Verify the signature.
Add the URL in the dashboard. Open Developer API → API Keys, enter the URL
under Webhook and press Add endpoint. Copy the signing secret it shows (it starts with whsec_) into your
server's environment, for example as TRYITON_WEBHOOK_SECRET. You can reveal it again later.
Send a test event. Press Send test event. The deliveries table shows how your endpoint answered. Every attempt we make is listed there for 30 days.
One endpoint per account. Send events pauses delivery without losing your settings.
Events
type | Sent when |
|---|---|
tryon.completed | A job completed. data.output has the result image URLs. |
tryon.failed | A job failed, including one that timed out after 3 minutes. It isn't charged. |
webhook.test | You pressed Send test event. data holds only a message. |
data is what GET /status/{id} returns for the job, plus its jobId:
{
"id": "evt_5f0c8a1e2b3d4c5e6f708192",
"type": "tryon.completed",
"created_at": "2026-12-04T10:15:30.120Z",
"data": {
"jobId": "64b7f1a9d9a3b8e5c7f9a123",
"status": "completed",
"output": ["https://cdn.tryiton.now/USER_ID/tryons/3f2c9a.png"],
"error": null
}
}Every field is on Webhook Events. Handle unknown type values by answering
200 and ignoring them: we may add events later.
Verify the signature
We sign with the open Standard Webhooks scheme, so its libraries work too. Each request carries three headers:
| Header | Value |
|---|---|
webhook-id | The event id. The same on every retry. |
webhook-timestamp | When this attempt was sent, in Unix seconds. |
webhook-signature | One or more v1,<signature> entries, separated by spaces. |
Using an SDK?
From 2.5, each SDK has a helper that does all of this and returns the event: verifyWebhook in Node.js,
verify_webhook in Python and Ruby, VerifyWebhook in Go and Webhook::verify in PHP. See
Verify webhooks. The code below is for servers without an SDK.
To check a request:
- Read the raw body as it arrived. Parsing the JSON and serializing it again changes the bytes.
- Reject the request when
webhook-timestampis more than 5 minutes from your clock. This stops replays. - Compute HMAC-SHA256 over
{webhook-id}.{webhook-timestamp}.{raw body}. The key is your secret without thewhsec_prefix, base64-decoded. - Base64-encode the result. Accept the request when it matches any
v1,entry. Compare in constant time.
import crypto from "node:crypto";
import express from "express";
const secret = Buffer.from(process.env.TRYITON_WEBHOOK_SECRET.replace(/^whsec_/, ""), "base64");
function isValidSignature(headers, rawBody) {
const id = headers["webhook-id"];
const timestamp = Number(headers["webhook-timestamp"]);
if (!id || !Number.isInteger(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > 300) return false;
const expected = crypto.createHmac("sha256", secret).update(`${id}.${timestamp}.${rawBody}`).digest();
return String(headers["webhook-signature"] || "")
.split(" ")
.some((entry) => {
const [version, signature = ""] = entry.split(",");
const given = Buffer.from(signature, "base64");
return version === "v1" && given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
}
const app = express();
// express.raw keeps the exact bytes that were signed.
app.post("/webhooks/tryiton", express.raw({ type: "application/json" }), (req, res) => {
const rawBody = req.body.toString("utf8");
if (!isValidSignature(req.headers, rawBody)) return res.sendStatus(400);
const event = JSON.parse(rawBody);
res.sendStatus(200);
// Handle event.type and event.data here, or queue them.
});
app.listen(3000);Answer fast, handle duplicates
- Answer with any
2xxwithin 10 seconds. Do slow work, like downloading the images, after you answer or in a queue. Any other status, a redirect, or no answer in time counts as a failed attempt. We don't follow redirects. - The same event can arrive more than once, for example when your server answered after our timeout. Store the
webhook-idof events you handled and skip repeats. - Events from different jobs can arrive in any order. Each job sends one final event, so there is nothing to reorder within a job.
Retries
A failed attempt is retried on this schedule:
| Attempt | After the previous attempt failed |
|---|---|
| 1 | Sent when the job finishes |
| 2 | 10 seconds |
| 3 | 1 minute |
| 4 | 10 minutes |
| 5 | 1 hour |
| 6 | 6 hours |
After the sixth failure the event is marked failed. Retries stop early when you turn events off or delete the
endpoint. Each attempt has a fresh webhook-timestamp and signature. You can resend any event from the deliveries
table, as long as it's there (30 days).
The last retry comes about 7 hours after the job, and result images last 72 hours, so a delayed event still has
working URLs. If your endpoint was down longer, fetch missed results with GET /status/{id}. Status works for 3
days after a job.
Rotate the secret
Rotate when a secret may have leaked, or on your own schedule:
- Press Rotate next to the signing secret. The new secret signs every event from then on.
- The old secret keeps signing too for 24 hours. During that time
webhook-signaturehas one entry per secret, so the code above keeps working with either. Rotate again within those 24 hours and up to three secrets sign at once. Each old one stops 24 hours after its own rotation. - Put the new secret in your server's environment and deploy within 24 hours.
Related
- Webhook Events: every field of each event
- Jobs & Polling
- Get Job Status
- Go-Live Checklist
Image Guidelines
How to get the best virtual try-on results: accepted image formats and limits, photo tips for clothing, hairstyle, tattoo and live try-on, and common failures.
Live Try-On Quickstart
Add real-time virtual try-on to your site: prepare garments and start live sessions on your server, then stream the shopper's webcam with tryiton-live.