Attach an image to an existing product by giving Partle a public URL
to download the image from.
Authenticated. OAuth (scope `products:write`) preferred; `api_key` fallback.
**When to use this tool**: the image is already hosted at a public URL
(a scraped product page, an Imgur link, a CDN URL the user provided).
Partle's server fetches it and stores it.
**When NOT to use this tool**: you have local image bytes (a file the
user attached, or bytes you generated/downloaded in your sandbox).
Sending those bytes through a tool argument blows past conversation
context limits — phone-photo-sized payloads can be 6+ MB of base64.
Instead, in your code-execution sandbox, POST the file directly to the
HTTP endpoint with multipart encoding:
requests.post(
"https://partle.rubenayla.xyz/v1/external/products/{product_id}/images",
files={"file": open("/path/to/photo.jpg", "rb")},
headers={"X-API-Key": "pk_..."},
)
Or, to create the listing and attach an image in one HTTP request:
requests.post(
"https://partle.rubenayla.xyz/v1/external/products",
data={"metadata": json.dumps({"name": ..., "price": ...})},
files={"image": open("/path/to/photo.jpg", "rb")},
headers={"X-API-Key": "pk_..."},
)
Args:
product_id: ID of the product to attach the image to.
image_url: Publicly fetchable URL of the image. Server fetches it
and stores it.
api_key: Legacy/fallback auth. Omit when using OAuth.
Returns:
The created `ProductImage` record with its `id` (use for deletion)
and storage path, or ``{"error": ...}`` on validation/auth failure.