Template Docs Commerce APIs Webhooks
Get Started
Get Started

Update a product image

POST https://api.squarespace.com/{api-version}/commerce/products/{productId}/images/{imageId}

Updates information for a product image. Currently, the endpoint only supports updates to the alt text for an image.

Note: This endpoint does not replace the product image itself. See the "Related endpoints" section to learn how to replace an existing product image.

A successful request returns the updated ProductImage resource. Read the Overview to learn more about ProductImages.

Parameters

If needed, see the "Related endpoints" section to learn how to retrieve resource ids.

{api-version} string
required

See the Products API Overview page for the current API version.


{productId} string
required

Specifies the Product that owns the ProductImage to update.


{imageId} string
required

Specifies the ProductImage to update.

Request example

Read the Making requests guide to learn why specific headers are necessary, and why some are omitted. Every request should also abide by Squarespace rate limits.

curl "https://api.squarespace.com/1.0/commerce/products/123/images/456" \
  -i \
  -H "Authorization: Bearer YOUR_API_KEY_OR_OAUTH_TOKEN" \
  -H "User-Agent: YOUR_CUSTOM_APP_DESCRIPTION" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{'
  # Required; string, 200 char limit.
  # Alt text for the image; impacts SEO and appears in search results.
  # See the link below for Squarespace alt text best practices:
  # https://support.squarespace.com/hc/en-us/articles/206542357#toc-alt-text-best-practices
  '"altText": "Steak"'
'}'

Response example

A response to a successful request will contain the updated Product.

{
  // Unique ProductImage id.
  "id": "5ed539bc8367410cdc0c984a",
  // Alt text for the image.
  // Impacts SEO and appears in search results.
  "altText": "Steak",
  // Absolute URL of the image hosted on Squarespace.
  "url": "https://static1.squarespace.com/static/steak.png",
  // Image size when first uploaded.
  "originalSize": {
    // Width in pixels.
    "width": 512,
    // Height in pixels.
    "height": 256
  },
  // Available image sizes. Use with `url` and a `format` query parameter
  // to retrieve the image at a particular width.
  // E.g., https://static1.squarespace.com/static/steak.png?format=300w
  "availableFormats": ["100w", "300w", "500w"]
}

Status codes and error conditions

200 OK

The request was successful. The message body contains data in the format specified above.


400 BAD REQUEST

Type: INVALID_REQUEST_ERROR

Subtype: null
The request body does not conform to the required specification.


404 NOT FOUND

Type: INVALID_REQUEST_ERROR

Subtype: INVALID_ARGUMENT
The requested ProductImage was not found.

Related endpoints

Ids
To retrieve ids for Products and their ProductImages, use these suggested endpoints:

Images
To replace an existing product image, you must delete the existing product image, then upload a new product image.