Product Tutorial

How to add your first products

Take a look at the relationships between prices and other resources in the Emporix Commerce Engine:

Adding your first product is a process made up of two main steps:

Define sales tax rates

Sales tax rates are stored in tax configurations. Each configuration indicates a country and defines tax classes applicable to it.

You can manage your tax configurations through the Emporix API Tax Service.

To define sales tax rates for a country, you need to send a request to the Creating a new tax configuration endpoint.

https://github.com/emporix/api-references/blob/main/products-labels-and-brands/tax-service/api-reference/README.md
curl -i -X POST \
  'https://api.emporix.io/tax/{tenant}/taxes' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
    "location": {
      "countryCode": "DE"
    },
    "taxClasses": [
      {
        "code": "STANDARD",
        "name": {
          "en": "Standard"
        },
        "order": 0,
        "rate": 19,
        "isDefault": true
      },
      {
        "code": "REDUCED",
        "name": {
          "en": "Reduced"
        },
        "order": 1,
        "rate": 7
      },
      {
        "code": "ZERO",
        "name": {
          "en": "Zero"
        },
        "order": 2,
        "rate": 0
      }
    ]
  }'

Add products

To add a single basic product, you need to send a request to the Creating a new product endpoint.

API Reference
curl -i -X POST \
  'https://api.emporix.io/product/{tenant}/products?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Smartphone Zony Yperia X2",
    "code": "BASIC001",
    "description": "The world'\''s best camera and camcorder in a waterproof smartphone.",
    "published": false,
    "taxClasses": {
      "EN": "STANDARD"
    },
    "productType": "BASIC",
    "template": {
      "id": "634cea2740033d7c2e7b03a8",
      "version": 1
    },
    "relatedItems": [
      {
        "refId": "634cea2740033d7c2e7b03a9",
        "type": "CONSUMABLE"
      }
    ],
    "mixins": {
      "salePricesData": [
        {
          "salePriceStart": "2021-07-20T22:00:00.000+0000",
          "salePriceAmount": 6.7,
          "salePriceEnd": "2021-07-25T21:59:59.000+0000",
          "enabled": false
        }
      ],
      "productCustomAttributes": {
        "pricingMeasurePrice": 13,
        "unitPricingMeasure": {
          "value": 133,
          "unitCode": "GRM"
        },
        "unitPricingBaseMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "pricingMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "orderUnit": "H87",
        "minOrderQuantity": 2,
        "maxOrderQuantity": 10,
        "defaultOrderQuantity": 5
      }
    },
    "metadata": {
      "mixins": {
        "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json",
        "salePricesData": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/salePriceData.json"
      }
    }
  }'

You can also add multiple basic products at the same time. To achieve that, you need to send a request to the Creating multiple products endpoint.

API Reference
curl -i -X POST \
  'https://api.emporix.io/product/{tenant}/products/bulk?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{ [
    {
        "id": "abc-123",
        "code": "532432412331",
        "name": "Product 1",
        "productType": "BASIC"
    },
    {
        "id": "abc-124",
        "code": "532432412332",
        "name": "Product 2",
        "productType": "BASIC"
    },
    {
        "id": "abc-125",
        "code": "532432412333",
        "name": "Product 3",
        "productType": "BASIC"
    }
 ]
}'

Add media for a product

To add media files, for example images or videos, for a particular product, you can upload them directly to the Emporix database, or link to their location on an external website. In the following example, we are creating a public type of an asset that is linked to the product of our choice by sending a request to the Creating an asset endpoint with the media.asset_manage scope.

API Reference
curl -i -X POST \
  'https://api.emporix.io/media/{tenant}/assets' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=[object Object]' \
  -F 'body=[object Object]'

How to create a bundle of personalized products

With Emporix API, you can group together two or more products that already exist in the system so that they can be sold at one collective price.

You can also personalize your products by using the Emporix-provided templates, or by creating your own ones. The values of the template's attributes are specified in the product's mixins.productTemplateAttributes field.

To create personalized products and then group them in a bundle, perform the following steps:

Before you start

Ensure that you have defined sales tax rates.

Create a product template

You can create a product template that contains additional attributes describing your product. To create a new product template, you need to call the Creating a new product template endpoint.

API Reference
curl -i -X POST \
  'https://api.emporix.io/product/{tenant}/product-templates' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
    "id": "545b4e3dfaee4c10def3db24",
    "name": {
      "en": "T-shirt"
    },
    "attributes": [
    {
      "key": "size",
      "name": {
        "en": "Size",
        "pl": "Rozmiar"
      },
      "type": "BOOLEAN",
      "metadata": {
        "mandatory": false,
        "variantAttribute": true,
        "defaultValue": true
      },
      "values": [
        {
          "key": "XS"
        },
        {
          "key": "S"
        },
        {
          "key": "M"
        },
        {
          "key": "L"
        },
        {
          "key": "XL"
        }
      ]
  }'

The id from the response is further referred to as {{product_template_Id}}.

Create a product by using a product template

By applying a product template, you can create a product that contains additional attributes, which are included in the product's mixins.productTemplateAttributes field.

To create a new product by applying a product template to it, you need to call the Creating a new product endpoint and provide the template's ID in the request body.

API Reference
curl -i -X POST \
  'https://api.emporix.io/product/{tenant}/products?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": {
    "en": "T-shirt",
    "de": "T-shirt"
  },
  "code": "tshirt01",
  "description": "Cotton T-shirt",
  "published": false,
  "taxClasses": {
    "EN": "STANDARD",
    "DE": "STANDARD"
  },
  "productType": "BASIC",
  "template": {
    "id": "{{product_template_Id}}",
    "version": "1"
  },
  "relatedItems": [
    {
      "refId": "634cea2740033d7c2e7b03a9",
      "type": "CONSUMABLE"
    }
  ],
  "mixins": {
    "salePricesData": [
      {
        "salePriceStart": "2021-07-20T22:00:00.000+0000",
        "salePriceAmount": 6.7,
        "salePriceEnd": "2021-07-25T21:59:59.000+0000",
        "enabled": false
      }
    ],
    "productCustomAttributes": {
      "pricingMeasurePrice": 13,
      "unitPricingMeasure": {
        "value": 133,
        "unitCode": "GRM"
      },
      "unitPricingBaseMeasure": {
        "value": 100,
        "unitCode": "GRM"
      },
      "pricingMeasure": {
        "value": 100,
        "unitCode": "GRM"
      },
      "orderUnit": "H87",
      "minOrderQuantity": 2,
      "maxOrderQuantity": 10,
      "defaultOrderQuantity": 5
    },
    "productTemplateAttributes": {
      "color": "GREEN",
      "size": "L",
      "discount": 30
    }
  },
  "metadata": {
    "mixins": {
      "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json",
      "salePricesData": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/salePriceData.json"
    }
  }
}

Create a bundle of products

You can group together two or more products that already exist in the system so that they can be sold at one collective price. To achieve that, you need to call the Creating a new product endpoint.

In this example, we will create a bundle of the T-shirt product we created above, and join it with the socks product that already exists.

API Reference
curl -i -X POST \
  'https://api.emporix.io/product/{tenant}/products?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "T-shirt and socks bundle",
  "code": "tshirt_socks_bundle",
  "description": "A bundle of t-shirt and socks.",
  "published": false,
  "taxClasses": {
    "EN": "STANDARD",
    "DE": "STANDARD"
  },
  "bundledProducts": [
    {
      "id": "{{bundled_product_1_Id}}",
      "amount": 1
    },
    {
      "id": "{{bundled_product_2_Id}}",
      "amount": 2
    }
  ],
  "productType": "BUNDLE",
  "template": {
    "id": "634cea2740033d7c2e7b03a8",
    "version": 1
  },
  "relatedItems": [
    {
      "refId": "634cea2740033d7c2e7b03a9",
      "type": "CONSUMABLE"
    }
  ],
  "mixins": {
    "productCustomAttributes": {
      "pricingMeasurePrice": 1,
      "unitPricingMeasure": {
        "value": 1350,
        "unitCode": "H87"
      },
      "unitPricingBaseMeasure": {
        "value": 1,
        "unitCode": "H87"
      },
      "pricingMeasure": {
        "value": 1,
        "unitCode": "H87"
      },
      "orderUnit": "H87",
      "minOrderQuantity": 1,
      "maxOrderQuantity": 10,
      "defaultOrderQuantity": 1
    }
  },
  "metadata": {
    "mixins": {
      "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
    }
  }
}

The value of the productId from the response is the {{bundle_Id}}.

How to create a parent variant product with variants

Variants are derivatives of the parent variant product. They contain the same attributes as their parent variant, but assume different attribute values.

Create a parent variant product

Variants are created automatically whenever their parent variant product is created or updated. The combinations of variants are created based on the attributes defined in the product template applied to the parent variant, and the attributes and values specified in the variantAttributes field of the parent variant.

Before you start, ensure that the skipVariantGeneration parameter is set to false.

To create a single parent_variant type of product with variants, you need to send a request to the Creating a new product endpoint.

API Reference
curl -i -X POST \
  'https://api.emporix.io/product/{tenant}/products?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "T-shirt with variants",
  "code": "PARENT001",
  "description": "Plain cotton T-shirt.",
  "published": false,
  "taxClasses": {
    "EN": "STANDARD"
  },
  "productType": "PARENT_VARIANT",
  "template": {
    "id": "634cea2740033d7c2e7b03a8",
    "version": 1
  },
  "relatedItems": [
    {
      "refId": "634cea2740033d7c2e7b03a9",
      "type": "CONSUMABLE"
    }
  ],
  "variantAttributes": {
    "color": [
      {
        "key": "RED"
      },
      {
        "key": "GREEN"
      },
      {
        "key": "BLUE"
      }
    ],
    "size": [
      {
        "key": "XS"
      },
      {
        "key": "S"
      },
      {
        "key": "M"
      },
      {
        "key": "L"
      },
      {
        "key": "XL"
      }
    ]
  },
  "mixins": {
    "productCustomAttributes": {
      "pricingMeasurePrice": 13,
      "unitPricingMeasure": {
        "value": 133,
        "unitCode": "GRM"
      },
      "unitPricingBaseMeasure": {
        "value": 100,
        "unitCode": "GRM"
      },
      "pricingMeasure": {
        "value": 100,
        "unitCode": "GRM"
      },
      "orderUnit": "H87",
      "minOrderQuantity": 2,
      "maxOrderQuantity": 10,
      "defaultOrderQuantity": 5
    },
    "productTemplateAttributes": {
      "color": [
        {
          "key": "RED"
        },
        {
          "key": "GREEN"
        },
        {
          "key": "BLUE"
        }
      ]
    }
  },
  "metadata": {
    "mixins": {
      "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
    }
  }
}'

If you want to create multiple parent_variant products at the same time, send a request to the Creating multiple products endpoint.

API Reference
curl -i -X POST \
  'https://api.emporix.io/product/{tenant}/products/bulk?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{[
  {
    "id": "abc-123",
    "code": "532432412331",
    "name": "Dress 1 with variants",
    "productType": "PARENT_VARIANT",
    "description": "Plain cotton dress",
    "published": "false",
    "taxClasses": {
      "EN": "STANDARD"
    },
    "template": {
      "id": "908cdv2740033d7c2e7b03b9",
      "version": 1
    },
    "relatedItems": [
      {
        "refId": "908cea2740033d7c2e7b03a9",
        "type": "CONSUMABLE"
      }
    ],
    "variantAttributes": {
      "color": [
        {
          "key": "RED"
        },
        {
          "key": "BLUE"
        },
        {
          "key": "YELLOW"
        }
      ],
      "size": [
        {
          "key": "XS"
        },
        {
          "key": "S"
        },
        {
          "key": "M"
        },
        {
          "key": "L"
        },
        {
          "key": "XL"
        }
      ]
    },
    "mixins": {
      "productCustomAttributes": {
        "pricingMeasurePrice": 13,
        "unitPricingMeasure": {
          "value": 133,
          "unitCode": "GRM"
        },
        "unitPricingBaseMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "pricingMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "orderUnit": "H87",
        "minOrderQuantity": 2,
        "maxOrderQuantity": 10,
        "defaultOrderQuantity": 5
      },
      "productTemplateAttributes": {
        "color": [
          {
            "key": "RED"
          },
          {
            "key": "BLUE"
          },
          {
            "key": "YELLOW"
          }
        ]
      }
    },
    "metadata": {
      "mixins": {
        "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
      }
    }
  },
  {
    "id": "abc-124",
    "code": "532432412332",
    "name": "Dress 2 with variants",
    "productType": "PARENT_VARIANT",
    "description": "Pleaded cotton dress",
    "published": "false",
    "taxClasses": {
      "EN": "STANDARD"
    },
    "template": {
      "id": "908cdv2740033d7c2e7b03b9",
      "version": 1
    },
    "relatedItems": [
      {
        "refId": "908cea2740033d7c2e7b03a9",
        "type": "CONSUMABLE"
      }
    ],
    "variantAttributes": {
      "color": [
        {
          "key": "RED"
        },
        {
          "key": "BLUE"
        },
        {
          "key": "YELLOW"
        }
      ],
      "size": [
        {
          "key": "XS"
        },
        {
          "key": "S"
        },
        {
          "key": "M"
        },
        {
          "key": "L"
        },
        {
          "key": "XL"
        }
      ]
    },
    "mixins": {
      "productCustomAttributes": {
        "pricingMeasurePrice": 13,
        "unitPricingMeasure": {
          "value": 133,
          "unitCode": "GRM"
        },
        "unitPricingBaseMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "pricingMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "orderUnit": "H87",
        "minOrderQuantity": 2,
        "maxOrderQuantity": 10,
        "defaultOrderQuantity": 5
      },
      "productTemplateAttributes": {
        "color": [
          {
            "key": "RED"
          },
          {
            "key": "BLUE"
          },
          {
            "key": "YELLOW"
          }
        ]
      }
    },
    "metadata": {
      "mixins": {
        "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
      }
    }
  },
  {
    "id": "abc-125",
    "code": "532432412336",
    "name": "Dress 3 with variants",
    "productType": "PARENT_VARIANT",
    "description": "Cotton dress with lace",
    "published": "false",
    "taxClasses": {
      "EN": "STANDARD"
    },
    "template": {
      "id": "908cdv2740033d7c2e7b03c7",
      "version": 1
    },
    "relatedItems": [
      {
        "refId": "908cea2740033d7c2e7b03a9",
        "type": "CONSUMABLE"
      }
    ],
    "variantAttributes": {
      "color": [
        {
          "key": "RED"
        },
        {
          "key": "BLUE"
        },
        {
          "key": "YELLOW"
        }
      ],
      "size": [
        {
          "key": "XS"
        },
        {
          "key": "S"
        },
        {
          "key": "M"
        },
        {
          "key": "L"
        },
        {
          "key": "XL"
        }
      ]
    },
    "mixins": {
      "productCustomAttributes": {
        "pricingMeasurePrice": 13,
        "unitPricingMeasure": {
          "value": 133,
          "unitCode": "GRM"
        },
        "unitPricingBaseMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "pricingMeasure": {
          "value": 100,
          "unitCode": "GRM"
        },
        "orderUnit": "H87",
        "minOrderQuantity": 2,
        "maxOrderQuantity": 10,
        "defaultOrderQuantity": 5
      },
      "productTemplateAttributes": {
        "color": [
          {
            "key": "RED"
          },
          {
            "key": "BLUE"
          },
          {
            "key": "YELLOW"
          }
        ]
      }
    },
    "metadata": {
      "mixins": {
        "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
      }
    }
  }
]
}'

How to create variants with new attributes and values

If you want to create variants by adding new variant attributes and/or values for a parent variant, you need to perform the following actions:

Update a product template with new attributes and values

To specify new attributes for your product's variants, you need to add them in the attributes field by calling the Updating a product template endpoint. Here, we've added a new key size to the list of available attributes.

To specify new values for your product's attributes, you need to add them in the values field. Here, we've added PURPLE to the list of available attribute values.

API Reference
curl -i -X PUT \
  'https://api.emporix.io/product/{tenant}/product-templates/{product-template-id}' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": {
    "en": "T-shirt"
  },
  "attributes": [
    {
      "key": "color",
      "name": {
        "en": "Color",
        "pl": "Kolor"
      },
      "type": "TEXT",
      "metadata": {
        "mandatory": false,
        "variantAttribute": true,
        "defaultValue": null
      },
      "values": [
        {
          "key": "GREEN"
        },
        {
          "key": "RED"
        },
        {
          "key": "BLUE"
        },
        {
          "key": "PURPLE"
        }
      ]
    },
    {
      "key": "discount",
      "name": {
        "en": "Discount"
      },
      "type": "NUMBER",
      "metadata": {
        "mandatory": false,
        "defaultValue": 0
      },
      "values": [
        {
          "key": 0
        },
        {
          "key": 30
        },
        {
          "key": 40
        },
        {
          "key": 50
        },
        {
          "key": 60
        }
      ]
    },
    {
      "key": "size",
      "name": {
        "en": "Size",
        "pl": "Rozmiar"
      },
      "type": "TEXT",
      "metadata": {
        "mandatory": false,
        "variantAttribute": true,
        "defaultValue": null
      },
      "values": [
        {
          "key": "XS"
        },
        {
          "key": "S"
        },
        {
          "key": "M"
        },
        {
          "key": "L"
        },
        {
          "key": "XL"
        }
      ]
    }
  ],
  "metadata": {
    "version": 1
  }
}'

Update the existing parent variant product with the new product template

Since updating the product template results in it being assigned a new version, you need to update the parent variant by sending a request to the Partially updating a product endpoint and providing the new template.version value.

API Reference
curl -i -X PATCH \
  'https://api.emporix.io/product/{tenant}/products/{productId}?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
    "published": true
    "template": {
    "id": "634cea2740033d7c2e7b03a8",
    "version": 2
  },
  "variantAttributes": {
    "color": [
      {
        "key": "GREEN"
      },
      {
        "key": "RED"
      },
      {
        "key": "BLUE"
      },
      {
        "key": "PURPLE"
      }
    ],
    "size": [
      {
        "key": "XS"
      },
      {
        "key": "S"
      },
      {
        "key": "M"
      },
      {
        "key": "L"
      },
      {
        "key": "XL"
      }
    ]
  }
}'

As a result, new product variants are created automatically, in combinations that include the newly specified attributes and values.

How to override variant attribute values

You may choose to update the basic fields of a particular variant, for example name, description, or relatedItems.

Updating a variant with new attribute values

By default, all variant products inherit their attributes from the parent variant. You need to include the name of the attribute in the metadata.overriden field to be able to replace the attribute values.

Update a specific variant product by sending a request to the Upserting a product endpoint.

In the following example, we override the following fields:

  • published

  • taxClasses

API Reference
curl -i -X PUT \
  'https://api.emporix.io/product/{tenant}/products/{productId}?partial=false&skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Blue T-shirt M",
    "code": "VARIANT001",
    "description": "The best T-shirt ever.",
    "published": true,
    "taxClasses": {
        "EN": "STANDARD",
        "PL": "STANDARD"
    },
    "productType": "VARIANT",
    "parentVariantId": "214cah2245033d9d2a2b17f1",
    "relatedItems": [
        {
        "refId": "634cea2740033d7c2e7b03a9",
        "type": "CONSUMABLE"
        }
    ],
    "metadata": {
        "version": 1,
        "overridden": [
        "published",
        "taxClasses"
        ]
    },
    "mixins": {
        "productVariantAttributes": {
        "color": "Blue",
        "size": "M"
        }
    }
}'

How to update multiple products in one operation

If you want to update multiple products, use the bulk update feature to update several products in one operation. Send a request to the Upserting multiple products endpoint.

API Reference
curl -i -X PUT \
  'https://api.emporix.io/product/{tenant}/products/bulk?skipVariantGeneration=false&doIndex=true' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Language: string' \
  -H 'Content-Type: application/json' \
  -d '{
    "id": "65492420e492d916983c8431",
    "code": "pa-1",
    "name": {
      "en": "Product_A"
    },
    "metadata": {
      "version": 1,
      "mixins": {
        "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
      },
      "schema": "https://res.cloudinary.com/saas-ag/raw/upload/v1544786405/schemata/CAAS/product.v2"
    },
    "description": {
      "en": "Some product"
    },
    "productType": "BASIC",
    "published": false
  },
  {
    "id": "6549262ce492d916983c8432",
    "code": "pb-2",
    "name": {
      "en": "Product_B"
    },
    "metadata": {
      "version": 2,
      "mixins": {
        "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
      },
      "schema": "https://res.cloudinary.com/saas-ag/raw/upload/v1544786405/schemata/CAAS/product.v2"
    },
    "description": {
      "de": "",
      "ar": "",
      "en": "",
      "fr": ""
    },
    "productType": "BASIC",
    "published": false
  },
  {
    "id": "654926f4e492d916983c8433",
    "code": "pc-3",
    "name": {
      "en": "Product_C"
    },
    "metadata": {
      "version": 1,
      "mixins": {
        "productCustomAttributes": "https://res.cloudinary.com/saas-ag/raw/upload/schemata/productCustomAttributesMixIn.v29.json"
      },
      "schema": "https://res.cloudinary.com/saas-ag/raw/upload/v1544786405/schemata/CAAS/product.v2"
    },
    "description": {
      "en": "Another product"
    },
    "productType": "BASIC",
    "mixins": {
      "productCustomAttributes": {
        "brand": "63e9570adee051597612e36c"
      }
    },
    "published": true
}'

When the update request is sent successfully, the response for a particular product is returned at the same position (index) at which it is located in the request body. The expected response is as follows:

[
  {
      "index": 0,
      "id": "65492420e492d916983c8431",
      "code": 204,
      "status": "NO_CONTENT"
  },
  {
      "index": 1,
      "id": "6549262ce492d916983c8432",
      "code": 204,
      "status": "NO_CONTENT"
  },
  {
      "index": 2,
      "id": "654926f4e492d916983c8433",
      "code": 204,
      "status": "NO_CONTENT"
  }
]

When something goes wrong, you might see some error message in the response. See some examples of error notifications you might encounter:

[
    {
        "index": 0,
        "id": "65492420e492d916983c8431",
        "code": 404,
        "status": "NOT_FOUND",
        "message": "The product with id 65492420e492d916983c8431 has not been found."
    }
]

404: The first product was not found, check if you have provided the correct id.

[
    {
        "index": 1,
        "id": "6549262ce492d916983c8432",
        "code": 409,
        "status": "CONFLICT",
        "message": "The resource that was requested for update has changed. Please retry your request with valid version."
    }
]

409: The second product returns conflict, check if you have provided the correct product schema version.

[
    {
        "index": 2,
        "id": "654926f4e492d916983c8433",
        "code": 404,
        "status": "NOT_FOUND",
        "message": "Product template with id 634cea2740033d7c2e7b03a8 is not present in the database."
    }
]

404: The third product cannot be updated because the product template provided in the payload was not found, check if you have provided the correct data.

Last updated

Was this helpful?