docs
  1. SCAYLE Resource Center
  2. Onboarding Guide
  3. Onboarding: Backend
  4. Add images to your products

Add images to your products

Images are essential for your products. All products need at least one image to be sellable via SCAYLE. You can add product images that are either stored in the SCAYLE Content Delivery Network (CDN) or images that are self-hosted, for example on your own CDN. Additionally, the Admin API offers endpoints to delete specific product images, update their position, or fetch them. We will focus on the create product image operation in this section. For further information about the other endpoints please refer to Images.

Details about creating product images via the Admin API

POST /products/{productIdentifier}/images

The productIdentifier either accepts the product identifier or the reference key. For more details see Identifiers.

When creating product images, you can either self-host the files or upload them to the SCAYLE CDN. When you upload a new image, it will be sorted into the last position. However, you can update the position and attributes after creating a product using the respective Admin API endpoint.

You can upload product images as base64 encoded attachments or by providing the URLs of the existing images. Furthermore, you can add product image meta information as simple attributes (remember, we already used simple attributes to enhance our product data in the Create Product section).

Supported Image File Types

The Admin API supports and recommends the following image file types:

  • JPEG (for high-quality product images)
  • PNG (for images with transparency)
  • GIF

Deciding when to use SCAYLE's CDN or self-host images

Opting for the SCAYLE CDN is an excellent choice if you don’t operate your own CDN already. However, the SCAYLE CDN only supports specific file types. This network should only be used for product images. Keep in mind that the SCAYLE CDN is not a replacement for content-relation images or a content management system.

Let’s add images to products of our demo shop

Now it is time to add images using the Admin API. We’ll assume that Fashion Store doesn’t have its own CDN, so we’ll use SCAYLE’s. Therefore, we won’t reference the image, but instead upload it using the Admin API. We will also assume the following:

  • The image format is jpeg.
  • Each product has one image.
  • We do not need to add simple attributes to the images.
  • The images are accessible, and we can reach them via their URLs.

POST /products/1/images

{
  "source": {
    "url": "https://fashion-store.com/images/image.jpeg"
  }
}
ParameterType
productIdentiferIn this case we use the id of the product, which was returned after the create product request. Technically, we could also have used the referenceKey.
source.urlWhen uploading an image to the CDN, you have to provide an asset source in the source property of an image. You can either specify a URL or a base64-encoded string containing valid binary image data. In our case, we specified the relevant URL.

Want to take a look at some other scenarios? For example, simply referencing images or uploading images based on binary data. Please see Create Product Image.

Amazing! You have successfully added images to your products via the Admin API.

Further education - SCAYLE Academy