Skip to main content
A runnable Python script implementing the recommended workflow: upload the customer photo once, reference products by externalId, fall back to a full inline upsert if the product expired. No catalog sync loop, no health checks, no surprises.

Prerequisites

The script

Run it

Expected output (cold start, 1st run):
Subsequent runs against the same externalId skip the upsert: the reference call succeeds on the first try, the payload is ~50 bytes, and no images are re-processed server-side.

Key points

  • Upload the customer photo once, reuse the imageId. Cheapest path. Auto-deleted after your account’s retention window (default 7 days).
  • Reference by externalId for repeat calls. Skips re-shipping the product payload and keeps the server’s image analysis warm.
  • Upsert again only when the product changes or when PRODUCT_NOT_FOUND tells you the product has expired. No proactive sync needed.
  • URLs vs byte uploads: the same URL is served from cache with no re-download. Byte uploads re-upload every call, so pin them to the first upsert and reference by externalId afterwards.
  • One-shot generations: drop the externalId entirely. The server returns a productExternalId you can stash and re-use if you want, or ignore; one-shot products clean themselves up after 7 days of inactivity.

Where to go next