Jobs, Polling & Retries
How virtual try-on API jobs work: submit, poll GET /status every 2 seconds, handle completed and failed jobs, set SDK wait timeouts, retry without duplicates.
Every photo try-on in the virtual try-on API is an asynchronous job. You submit it, get a jobId back right away,
then poll GET /status/{id} until the job is completed or failed. There are no
webhooks: polling is the only way to get the result.
Job lifecycle
Submit. POST /tryon/fashion, /tryon/hairstyle or /tryon/tattoo returns 201 with the job id. The job's
credits are held from this moment.
{ "ok": true, "jobId": "64b7f1a9d9a3b8e5c7f9a123" }Processing. GET /status/{id} returns status: "processing" and an empty output while the model runs. Most
jobs finish well within a minute.
{ "ok": true, "status": "processing", "output": [], "error": null }Completed or failed. A finished job has status: "completed" and one URL per image in output:
{
"ok": true,
"status": "completed",
"output": ["https://cdn.tryiton.now/USER_ID/tryons/3f2c9a.png"],
"error": null
}A failed job has status: "failed", an empty output and the reason as a plain string in error. This is still
HTTP 200: the status request worked, the job didn't.
{ "ok": true, "status": "failed", "output": [], "error": "Timed out." }output is always an array and error is always a string or null, so you can read both without checking for
missing fields. Result files are .png or .jpg, matching the output_format you sent. Result images carry an
EXIF tag that marks them as AI-generated.
Polling
- Poll every 2 seconds. That's the SDK default. Polling faster doesn't make the job finish sooner and spends the 300 requests/minute per-IP rate limit that all your requests share.
- Stop at
completedorfailed. Both are final. A job never goes back toprocessing. - Jobs time out after 5 minutes. A job still processing 5 minutes after submission is marked
failedwith"Timed out."and isn't charged. The check runs every 2 minutes, so the status can flip up to about 7 minutes after submission.
Result lifetime
- Download results you want to keep. Result images are deleted about 72 hours after the job was submitted (an hourly cleanup), and their URLs stop working.
- Job records expire for polling after 3 days. After that,
GET /status/{id}returns404 NotFound. Your request history stays visible in the dashboard under Developer API → Requests.
SDK wait helpers and timeouts
Each SDK has a waitForResult helper that polls every 2 seconds and returns the output URLs. It raises an error
named ProcessingError if the job fails, and Timeout if it gives up first. A Timeout doesn't mean the job
failed: keep polling the same jobId rather than resubmitting.
The default wait is 120 seconds. Clothing jobs can take longer under load, so raise it. A wait just over 5 minutes covers a job's full lifetime, since the server fails any job that runs longer.
const output = await client.waitForResult(jobId, {
pollIntervalMs: 2_000,
timeoutMs: 6 * 60_000,
});output = client.wait_for_result(job_id, poll_interval=2.0, timeout=360)// WaitForResult has no timeout of its own: bound it with the context.
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Minute)
defer cancel()
output, err := client.WaitForResult(ctx, jobID, 2*time.Second)// Arguments: job id, poll interval (seconds), timeout (seconds).
$output = $client->waitForResult($jobId, 2.0, 360.0);output = client.wait_for_result(job_id, poll_interval: 2.0, timeout: 360)In Go, a context that expires while WaitForResult is sleeping returns an *tryiton.Error named Timeout. If it
expires during an HTTP request, the error is named NetworkError. Check ctx.Err() to tell a deadline from a real
network problem.
Polling yourself
Use getStatus when you want control over the loop, for example to poll many jobs from one worker or to persist
progress between runs.
import { TryItOn } from "tryiton";
const client = new TryItOn({ apiKey: process.env.TRYITON_API_KEY });
const jobId = process.argv[2];
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
for (;;) {
const { status, output, error } = await client.getStatus(jobId);
if (status === "completed") {
console.log(output);
break;
}
if (status === "failed") {
console.error("Job failed:", error);
break;
}
await sleep(2_000);
}import os
import sys
import time
from tryiton import TryItOn
client = TryItOn(api_key=os.environ["TRYITON_API_KEY"])
job_id = sys.argv[1]
while True:
status = client.get_status(job_id)
if status.status == "completed":
print(status.output)
break
if status.status == "failed":
print("Job failed:", status.error)
break
time.sleep(2)package main
import (
"context"
"fmt"
"log"
"os"
"time"
tryiton "github.com/tryiton-now/tryiton-go/v2"
)
func main() {
client, err := tryiton.New(os.Getenv("TRYITON_API_KEY"))
if err != nil {
log.Fatal(err)
}
jobID := os.Args[1]
ctx := context.Background()
for {
s, err := client.GetStatus(ctx, jobID)
if err != nil {
log.Fatal(err)
}
switch s.Status {
case "completed":
fmt.Println(s.Output)
return
case "failed":
// The SDK decodes the API's error string into a JobError.
reason := "unknown"
if s.Error != nil {
reason = s.Error.Message
}
log.Fatalf("job failed: %s", reason)
}
time.Sleep(2 * time.Second)
}
}Retries and duplicate jobs
The API has no idempotency keys, so a retried submit is a new job. What to do depends on how the first attempt ended:
| First attempt | Was a job created? | What to do |
|---|---|---|
Returned 201 with a jobId | Yes | Don't resubmit. Poll that jobId. |
Returned an error response (4xx/5xx) | No, nothing billable | Retrying is safe once the cause is fixed. See when to retry. |
| Timed out or the connection dropped, no response | Maybe | If duplicates matter, check Developer API → Requests in the dashboard before resubmitting. A duplicate is billed only if it completes. |
Job ended failed | Yes, not billed | Resubmit as a new job. Fix the input first if the reason points at it. |
SDK wait raised Timeout | Yes, may still complete | Keep polling the same jobId. |
To avoid paying twice for the same work, store the jobId with your own record (an order, a product, a user) as
soon as the submit returns, and check it before submitting again.
Related
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.
Data Retention & Privacy
What the TryItOn virtual try-on API stores and for how long: job records, input images, 72-hour result deletion, live garments and live video streams.