cURL · Virtual Try-On API

Virtual Try-On API with cURL

The fastest way to understand any API is to call it from the shell. Photta's docs are cURL-first by design — everything on this page runs in a single terminal, no Node or Python required.

In one sentence

Export `PHOTTA_API_KEY`, POST to `https://ai.photta.app/api/v1/tryon/apparel` with the right JSON body, capture the generation ID, then loop `curl … /tryon/apparel/:id` every 3 seconds until `data.status` flips to `completed` — typically within 1.5 to 4 minutes. Pair with `jq` to extract the output URL from the final response.

Updated · 2026-04-19

Your first request

cURLNode.jsPythoncURL
# Submit a try-on job. The API returns 202 Accepted + a generation ID.
JOB=$(curl -s -X POST "$PHOTTA_BASE_URL/tryon/apparel" \
  -H "$AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{
    "product_type": "dress",
    "product_images": ["https://example.com/dress.jpg"],
    "mannequin_id": "mnq_athena_ts",
    "pose_id": "pose_standing_front",
    "resolution": "2K",
    "aspect_ratio": "3:4"
  }')

ID=$(echo "$JOB" | jq -r '.data.id')
echo "Generation $ID queued"

# Poll every 3 seconds until the job completes (max 6 minutes).
for i in $(seq 1 120); do
  RESULT=$(curl -s "$PHOTTA_BASE_URL/tryon/apparel/$ID" -H "$AUTH_HEADER")
  STATUS=$(echo "$RESULT" | jq -r '.data.status')
  if [ "$STATUS" = "completed" ]; then
    echo "$RESULT" | jq -r '.data.output_url'
    break
  fi
  if [ "$STATUS" = "failed" ]; then
    echo "$RESULT" | jq -r '.data.error_message' >&2
    exit 1
  fi
  sleep 3
done

What to expect

Typical completion

1.5–4min

2K / 4K credits

5 / 7

Jewelry types

4

Close-up mannequins

built-in

How it works

Virtual Try-On API with cURL

Five shell steps, zero dependencies beyond curl and jq.

  1. 01

    Step 1

    Sign up and generate a key

    Head to ai.photta.app, open the Developers tab, click Generate API key. Live keys start with `photta_live_`.

  2. 02

    Step 2

    Export the key

    Put `export PHOTTA_API_KEY="photta_live_xxx"` in your shell profile or a `.envrc` file so every subsequent curl call picks it up automatically.

  3. 03

    Step 3

    Pin the base URL

    `export PHOTTA_BASE_URL="https://ai.photta.app/api/v1"` keeps the curl commands short and makes it easy to swap in a sandbox URL once one ships.

  4. 04

    Step 4

    Submit and poll

    POST to `$PHOTTA_BASE_URL/tryon/apparel` to get an ID, then loop `curl $PHOTTA_BASE_URL/tryon/apparel/$ID` every 3 seconds. Pipe the response to jq to extract `.data.status` cleanly.

  5. 05

    Step 5

    Persist the result

    When the job completes, pull `.data.output_url` out with jq and `curl -o` the bytes into local storage — ready for your next pipeline step.

Code, end to end

Copy, paste, done.

Four snippets — install prerequisites, wrap the REST call, submit + poll, then handle the errors that actually happen in production.

01cURL is already installed on macOS, Linux, WSL and modern Windows
bash
# Verify curl is available
curl --version

# Export your API key so the rest of the calls can reference it
export PHOTTA_API_KEY="photta_live_xxxxx"
02Set the base URL + auth header once
bash
# Pin the base URL in a shell variable so every call is a one-liner.
export PHOTTA_BASE_URL="https://ai.photta.app/api/v1"

# Reusable auth header — every request needs it.
AUTH_HEADER="Authorization: Bearer $PHOTTA_API_KEY"
03Submit and poll in one script
bash
# Submit a try-on job. The API returns 202 Accepted + a generation ID.
JOB=$(curl -s -X POST "$PHOTTA_BASE_URL/tryon/apparel" \
  -H "$AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{
    "product_type": "dress",
    "product_images": ["https://example.com/dress.jpg"],
    "mannequin_id": "mnq_athena_ts",
    "pose_id": "pose_standing_front",
    "resolution": "2K",
    "aspect_ratio": "3:4"
  }')

ID=$(echo "$JOB" | jq -r '.data.id')
echo "Generation $ID queued"

# Poll every 3 seconds until the job completes (max 6 minutes).
for i in $(seq 1 120); do
  RESULT=$(curl -s "$PHOTTA_BASE_URL/tryon/apparel/$ID" -H "$AUTH_HEADER")
  STATUS=$(echo "$RESULT" | jq -r '.data.status')
  if [ "$STATUS" = "completed" ]; then
    echo "$RESULT" | jq -r '.data.output_url'
    break
  fi
  if [ "$STATUS" = "failed" ]; then
    echo "$RESULT" | jq -r '.data.error_message' >&2
    exit 1
  fi
  sleep 3
done
04Read the status code + error body instead of silently failing
bash
# -w pulls out the HTTP status without polluting the JSON body.
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$PHOTTA_BASE_URL/tryon/apparel" \
  -H "$AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{ "product_type": "dress" }')

BODY=$(echo "$RESPONSE" | sed '$d')
STATUS=$(echo "$RESPONSE" | tail -1)

case "$STATUS" in
  200|202)
    echo "$BODY" | jq '.data' ;;
  402)
    echo "Out of credits" ; echo "$BODY" | jq '.error' ;;
  429)
    RETRY=$(echo "$BODY" | jq -r '.error.retry_after')
    echo "Rate limited — retry in ${RETRY}s" ;;
  *)
    echo "Error $STATUS" ; echo "$BODY" | jq '.error' ;;
esac

Why this shape

Why cURL is still the fastest way to verify an API

  • Zero install — cURL ships with every major OS
  • Pairs with `jq` for scripted pipelines (CI, cron, bash hooks)
  • Ideal for smoke-testing endpoints before wiring them into code
  • All code in this page copy-pastes into any POSIX shell

What it doesn't do

Honest caveats

  • cURL's polling loop blocks your terminal — move to Node/Python for parallel workers
  • No streaming parser for the result; you fetch the final URL when the job is done
  • Windows Command Prompt users should run WSL or PowerShell's curl.exe wrapper

Questions other developers ask

Questions other developers ask

Is there a Photta CLI tool?+

Not yet — but cURL plus a fifteen-line bash wrapper gets you most of the way. The docs prioritise cURL-first examples because every language can run a subprocess, and the shell is the common denominator in CI pipelines.

Do I need jq to use the API?+

Not strictly — but scripted pipelines are much easier with it. jq lets you pull `.data.id`, `.data.status` and `.data.output_url` out of the JSON response without parsing it by hand. Install with `brew install jq` on macOS or `apt install jq` on Debian/Ubuntu.

How do I authenticate with curl?+

Add `-H "Authorization: Bearer $PHOTTA_API_KEY"` to every request. Keep the key in an env var, never inline it in a script you commit. `curl --oauth2-bearer` also works but the explicit header form is clearer in docs and logs.

Can I use curl-based scripts in production?+

For one-off batch backfills and cron jobs, yes — thousands of teams ship catalog backfills this way. For a long-lived application, a real language is usually better because you get proper error handling, retries, and observability. The curl examples on this page stay accurate even after you port to Node or Python; the request shape is the same.

How do I poll from a bash loop?+

Use `for i in $(seq 1 120); do … ; sleep 3; done` with the status check in the loop body. Break out when `.data.status` is `completed` or `failed`. The code sample on this page shows the exact pattern, including a hard upper bound so a stuck job can't hang the script forever.

How do I read error responses in curl?+

Use `curl -w "\n%{http_code}"` to capture the HTTP status code alongside the JSON body. Branch on the status: 402 for insufficient credits, 429 for rate limits (honour the Retry-After value), 5xx for transient server errors. The error body always has an `error.code` and `error.message` field.

cURL · Virtual Try-On API

Create an account and get an API key

Export `PHOTTA_API_KEY`, POST to `https://ai.photta.app/api/v1/tryon/apparel` with the right JSON body, capture the generation ID, then loop `curl … /tryon/apparel/:id` every 3 seconds until `data.status` flips to `completed` — typically within 1.5 to 4 minutes. Pair with `jq` to extract the output URL from the final response.

Virtual Try-On API with cURL — Photta | Photta