Images
Upload images to your media library, attach them to products, and control the display order.
| Method | Path | Description |
|---|---|---|
POST | /v1/products/{id}/images/attach | Attach existing images to a product |
PATCH | /v1/images/reorder | Reorder images |
POST | /v1/images | Upload an image to the library |
GET | /v1/images | List images |
GET | /v1/images/{id} | Get an image |
PATCH | /v1/images/{id} | Update image metadata |
DELETE | /v1/images/{id} | Delete an image |
Upload an image to the library
POST /v1/imagesUploads an image file to the store-level media library without attaching it to a product. Accepted formats: JPEG, PNG, WebP, GIF, AVIF, HEIC. Max size 10 MB. An optional `lqip` field accepts a ThumbHash base64 string for low-quality image placeholder. Requires a secret key.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
file | string | No | |
lqip | string | No |
Request
curl -X POST https://api.hydrajs.dev/v1/images \
-H "Authorization: Bearer sk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"file": "string_value",
"lqip": "string_value"
}' \
-F "[email protected]"Response 201
{
"data": {}
}List images
GET /v1/imagesReturns a cursor-paginated list of images in the store media library. Filter by attachment status with `?unattached=true`, by category, or by search query. Publishable keys can read.
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | integer | 25 | |
cursor | string | - | |
fields | string | - | |
unattached | string | - | Values: true, false |
search | string | - | |
category | string | - | Values: product, collection, blog, logo, general, page, marketing, directory |
Request
curl https://api.hydrajs.dev/v1/images \
-H "Authorization: Bearer sk_YOUR_KEY"Response 200
{
"data": [],
"pagination": {}
}Get an image
GET /v1/images/{id}Retrieves a single image by ID. Publishable keys can read.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id | string |
Request
curl https://api.hydrajs.dev/v1/images/:id \
-H "Authorization: Bearer sk_YOUR_KEY"Response 200
{
"data": {}
}Update image metadata
PATCH /v1/images/{id}Updates image metadata including alt text, slug, and category. When the slug is changed, CDN routing mappings are updated automatically. Requires a secret key.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id | string |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
alt | string | No | |
position | integer | No | |
slug | string | No | |
category | string | No | Values: product, collection, blog, logo, general, page, marketing, directory |
Request
curl -X PATCH https://api.hydrajs.dev/v1/images/:id \
-H "Authorization: Bearer sk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"alt": "string_value",
"position": 1,
"slug": "string_value"
}'Response 200
{
"data": {}
}Delete an image
DELETE /v1/images/{id}Permanently deletes an image. Removes the file from cloud storage and cleans up CDN slug mappings. Requires a secret key.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id | string |
Request
curl -X DELETE https://api.hydrajs.dev/v1/images/:id \
-H "Authorization: Bearer sk_YOUR_KEY"Attach existing images to a product
POST /v1/products/{id}/images/attachAttaches one or more existing library images to the specified product by their IDs. Images that are already attached are skipped. Requires a secret key.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id | string |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
image_ids | string[] | Yes |
Request
curl -X POST https://api.hydrajs.dev/v1/products/:id/images/attach \
-H "Authorization: Bearer sk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"image_ids": []
}'Response 201
{
"data": []
}Reorder images
PATCH /v1/images/reorderUpdates the display position of images. Accepts an array of `{ id, position }` objects to set the sort order. Requires a secret key.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
images | object[] | Yes |
Request
curl -X PATCH https://api.hydrajs.dev/v1/images/reorder \
-H "Authorization: Bearer sk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"images": []
}'