Search Documentation

Search for a documentation page...

Images API

REST API endpoints for uploading and generating product images.

Uploading images

Image upload moved to the Media API. Use POST /api/v1/media to upload files (multipart/form-data, up to 10 files of 25 MB each under the file field) or to ingest remote image URLs as JSON. It returns catalogued media records with CDN URLs you can use anywhere a product, collection, or post expects an image.


Generate Image

POST /api/v1/images/generate

Generates an image using AI from a text prompt. The image is uploaded to the store's CDN and returns the URL. Timeout: 30 seconds.

Request Body

FieldTypeRequiredDescription
promptstringYesText prompt (1-1000 characters)
typestringNoImage type: product, collection, or hero (default: product)
namestringNoFilename prefix (default: generated)

The type parameter affects the generated image's aspect ratio and style:

TypeUse Case
productSquare product photos, clean backgrounds
collectionWide banner images for collection headers
heroFull-width hero images for landing pages
curl -X POST \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A minimalist ceramic coffee mug on a marble surface, soft natural lighting",
"type": "product",
"name": "coffee-mug"
}' \
https://your-store.yns.store/api/v1/images/generate

Response

{
"url": "https://your-store.blob.vercel-storage.com/images/coffee-mug-abc123.png",
"pathname": "images/coffee-mug-abc123.png"
}

List Generations

GET /api/v1/images/generations

Lists the store's image and video generations, newest first, across all products.

Query Parameters

ParameterTypeDefaultDescription
limitnumber40Generations per page (1-100)
offsetnumber0Generations to skip
sourcestringFilter by origin: studio (the in-app Image Studio) or api (this endpoint)
typestringFilter by media type: image or video
curl \
-H "Authorization: Bearer your_api_key" \
"https://your-store.yns.store/api/v1/images/generations?source=api&type=image&limit=20"

Response

{
"data": [
{
"id": "0191abc0-1234-7def-8000-00000000000b",
"status": "completed",
"type": "image",
"generatedImageUrl": "https://your-store.blob.vercel-storage.com/images/coffee-mug-abc123.png",
"aspectRatio": "1:1",
"source": "api",
"productId": null,
"createdAt": "2024-05-03T12:00:00.000Z"
}
],
"meta": {
"count": 1,
"limit": 20,
"offset": 0
}
}

Get Generation

GET /api/v1/images/generations/:id

Poll the status and result of a generation started with POST /api/v1/images/generate. Store-scoped — a store can only read its own generations.

curl \
-H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/images/generations/0191abc0-1234-7def-8000-00000000000b

Response

{
"id": "0191abc0-1234-7def-8000-00000000000b",
"status": "completed",
"type": "image",
"url": "https://your-store.blob.vercel-storage.com/images/coffee-mug-abc123.png",
"error": null,
"aspectRatio": "1:1",
"source": "api",
"productId": null,
"createdAt": "2024-05-03T12:00:00.000Z"
}

Status Values

StatusMeaning
pendingQueued, not started yet
processingGeneration in progress
completedFinished — url holds the result
failedFailed — error explains why

A 404 is returned when no generation with that id belongs to the store.