Search Documentation
Search for a documentation page...
Media API
REST API endpoints for managing the store's media library.
The media library is the store's catalog of uploaded images, video, and documents. Add files by uploading them directly or by pointing at remote URLs (re-hosted on the store CDN), then attach them to products, variants, or collections.
List Media
Returns a paginated list of the store's media, newest first. Filter by kind and search filename or alt text with query.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 24 | Items per page (1-100) |
offset | number | 0 | Items to skip |
kind | "image" | "video" | "document" | – | Filter by media kind |
query | string | – | Search by filename or alt text |
Response
Create Media
Adds media to the library in one of two modes, chosen by the request Content-Type.
File upload (multipart/form-data) – upload file(s) under the file field; repeat the field for multiple files. Maximum 10 files, 25 MB each.
Remote URLs (application/json) – pass { "urls": [...] } (up to 10) to download public files and re-host them on the store CDN. Accepted: images (max 25 MB), videos such as MP4, WebM and MOV (max 100 MB) and PDFs (max 100 MB). Use this to move a file you can link to but not upload, for example one served from your storefront's own site.
The file type comes from the response Content-Type. When the server sends a generic one (application/octet-stream), the type is detected from the file itself. Other types (HTML, archives, audio) are refused. Only public http(s) addresses are fetched; private and internal hosts are blocked.
Both modes catalog the result and return the created rows under media.
JPEG, PNG, WebP and AVIF images whose longest side exceeds 2048 px are scaled down to fit 2048 px, in their own format. The stored file, its sizeBytes and its recorded width and height describe the scaled copy. Smaller images, animations and other file types are stored unchanged.
Request Body (JSON mode)
| Field | Type | Required | Description |
|---|---|---|---|
urls | string[] | Yes | Public URLs of images, videos or PDFs to fetch and add (1–10) |
Response (201)
URL Import Errors (400)
URLs are processed in order and the request stops at the first one that fails. The response names the reason and lists the files already added, so you can retry from the failed URL:
Get Media
Returns a single media item by ID. Returns 404 if it does not exist in this store.
Update Media
Updates editable metadata. Send at least one field – an empty body returns 400.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
filename | string | No | Display filename (min 1 char) |
alt | string | null | No | Alt text for accessibility (null to clear) |
Response (200)
Returns the updated media item.
Delete Media
Removes the media row and best-effort deletes the underlying blob. If the asset is still attached to one or more products, variants, or collections, the request returns 409 with the list of usedBy entities. Pass ?force=true to delete anyway – the URL is stripped from every entity that references it.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
force | boolean | false | Delete even if the asset is still attached |
Response (204)
Empty body on success.