Product Images

Information

The product_images resource type is used to associate a particular image with a product. Weedmaps Content Delivery Network (CDN) caches based on URL. When you have an existing image and then upload a new image using the same URL, you may not see the new image. We recommend using a different URL to ensure the new image is displayed.

A primary, or default, image for a product is denoted by the attribute is_primary: true. While a product can have multiple product_images, currently only the primary product_image will be displayed. If you do not set one of the product_images with the attribute is_primary: true, no image will be displayed.

A few additional things to note about a product_image:

  • Must be a valid image URL ending in .jpg, .jpeg, or .png.
  • The content-type for the image must be image/jpeg, image/png, or application/octet-stream.
  • The maximum image size for any product_image is 75 MB.

API Requests

The request types and routes available for this resource as well as details on how to structure your requests are below. See API Reference - ProductImage for examples on how the requests might look in various languages and to test the requests in the browser.

RequestRouteDescription
POST/catalogs/v1/product_imagesCreate a new product_image (see Note 1 below)
GET/catalogs/v1/product_imagesRequest the information for all product_images
GET/catalogs/v1/product_images/:idRequest the information for a particular product_image
PATCH/catalogs/v1/product_images/:idUpdate the information for an existing product_image
DELETE/catalogs/v1/product_images/:idDelete an existing product_image

🚧

If you receive a 422 error when sending a POST request for a Product Image, double-check that the Product is not a Master Product. The Product Images for Master Products can only be created by the Brands that produce them.

POST

To create a ProductImage, send a payload with the below structure to
/catalog/v1/product_images?scope_by[organization_id]=ORGANIZATION_ID.

{
  "data": {
    "type": "product_images",
    "attributes": {
      "is_primary": true,
      "image_url": "PRODUCT_IMAGE_URL"
    },
    "relationships": {
      "product": {
        "data": {
          "type": "products",
          "id": "PRODUCT_ID"
        }
      }
    }
  }
}

Path

scope_by[organization_id] string
Required. Organization UUID.

Attributes

id string
Optional. UUID for the resource.


image_url string
Required. URL for the ProductImage. Example: http://i.imgur.com/AD3MBi.jpg.


is_primary boolean
Required. Defaults to false. Is this image the primary ProductImage for the Product?


type string
Required. Must be product_images.

Relationships

Product

product_id string
Required. Related Product UUID.


type string
Required. Must be products.

GET Index

To fetch all ProductImages, send a request to
/catalog/v1/product_images?scope_by[organization_id]=ORGANIZATION_ID. By default, we only return the first 10 results from the request. You can adjust the number of returned results with page[size], or adjust the returned page with page[page].

Path

scope_by[organization_id] string
Required. Organization UUID.


page[size] int32
Optional. Number of elements per page.


page[page] int32
Optional. Number of the page.


filter[product_id] string
Optional. Filters by Product UUID.

GET Show

To fetch a ProductImage, send a request to
/catalog/v1/product_images/PRODUCT_IMAGE_ID?scope_by[organization_id]=ORGANIZATION_ID.

Path

scope_by[organization_id] string
Required. Organization UUID.


product_image_id string
Required. ProductImage UUID you want to fetch.

PATCH

To update a ProductImage, send a payload with the below structure to
/catalog/v1/product_images/PRODUCT_IMAGE_ID?scope_by[organization_id]=ORGANIZATION_ID.

{
  "data": {
    "id": "PRODUCT_IMAGE_ID",
    "type": "product_images",
    "attributes": {
      "is_primary": true,
      "image_url": "PRODUCT_IMAGE_URL"
    },
    "relationships": {
      "product": {
        "data": {
          "type": "products",
          "id": "PRODUCT_ID"
        }
      }
    }
  }
}

Path

scope_by[organization_id] string
Required. Organization UUID.


product_image_id string
Required. ProductImage UUID you want to update.

Attributes

image_url string
Optional. URL for the ProductImage. Example: http://i.imgur.com/AD3MBi.jpg.


is_primary boolean
Optional. Defaults to false. Is this image the primary ProductImage for the Product?


type string
Required. Must be product_images.

Relationships

Product

product_id string
Required. Related Product UUID.


type string
Required. Must be products.

DELETE

To delete a ProductImage, send a request to
/catalog/v1/product_images/PRODUCT_IMAGE_ID?scope_by[organization_id]=ORGANIZATION_ID.

Path

scope_by[organization_id] string
Required. Organization UUID.


product_image_id string
Required. ProductImage UUID you want to delete.