Skip to content

Images ​

Upload images to your media library, attach them to products, and control the display order.

MethodPathDescription
POST/v1/products/{id}/images/attachAttach existing images to a product
PATCH/v1/images/reorderReorder images
POST/v1/imagesUpload an image to the library
GET/v1/imagesList 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/images

Uploads 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

FieldTypeRequiredDescription
filestringNo
lqipstringNo

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/images

Returns 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

ParameterTypeDefaultDescription
limitinteger25
cursorstring-
fieldsstring-
unattachedstring- Values: true, false
searchstring-
categorystring- 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

ParameterTypeDescription
idstring

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

ParameterTypeDescription
idstring

Request body

FieldTypeRequiredDescription
altstringNo
positionintegerNo
slugstringNo
categorystringNo 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

ParameterTypeDescription
idstring

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/attach

Attaches 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

ParameterTypeDescription
idstring

Request body

FieldTypeRequiredDescription
image_idsstring[]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/reorder

Updates the display position of images. Accepts an array of `{ id, position }` objects to set the sort order. Requires a secret key.

Request body

FieldTypeRequiredDescription
imagesobject[]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": []
  }'