docs
  1. SCAYLE Resource Center
  2. Onboarding Guide
  3. Onboarding: Backend
  4. Create your first product variants

Create your first product variants

Now that you've created your first product in SCAYLE, we’ll focus on variants. As you'll remember from the three-level product structure, a variant is a sellable entity. It represents one size of a product. For example, imagine you have a black T-shirt from Adidas as a product. An item with a specific size (e.g. “size m”) is one variant of that product.

You can also create variants via the same three ways you create products: via the Admin API, manually within the panel, and manually via product list import. However, as we mentioned earlier, we’ll only focus on the Admin API because this is the most common and recommended way to handle lots of variants.

The Admin API allows you to create, update, delete, and fetch product variants. We describe each endpoint in deeper detail in the variants section of the Admin API reference guide. For the sake of this tutorial, we’ll focus on creating variants via the create endpoint.

Breaking down the product variant creation endpoint

POST /products/{productIdentifier}/variants

As you already know, the productIdentifier accepts the product id (generated by SCAYLE and provided in the response of a product creation request) or the product referenceKey (also provided in the product creation request). This corresponds to a product and the variant (the size). For more details, see Identifiers.

Furthermore, the endpoint supports a couple of query parameters that can be used to customize the variant creation request. For example, you can specify what information you want the Admin API to provide in the request response.

Request Body

Specify all product variant details you want to create in the request body. Please find a list of the parameters relevant to this tutorial in the table below. A full list of all parameters can be found here.

ParameterTypeDetails
referenceKeySTRINGA key that uniquely identifies the variant of a product (usually an SKU) within the tenant's ecosystem.
attributesARRAY OBJECTA list of attributes attached to the product variant.

Creating a variant in its most basic form only requires a referenceKey. However, we recommend adding further information as attributes (e.g. the size of the variant).

Guiding principles when integrating this endpoint

Technically, you can also send the price and stock information along with the create variant request. However, we recommend using the dedicated endpoints to perform this task, especially for updates. To ensure quick processing, only add information when it needs to be updated.

Creating an example product variant for the Fashion Store

Now let’s create the first variant for the T-shirt we created via the Admin APIs variant creation endpoint. In the URL of the endpoint, we use the product referenceKey as the productIdentifier to specify which product we want to create a variant for.

POST /products/FS-100-black/variants

Only one variant can be created per request. Therefore, you must create multiple requests for multiple variants.

Example Payload:

{
  "referenceKey": "FS-100-black-S",
  "attributes": [
    {
      "name": "size",
      "type": "simple",
      "value": "s"
    }
  ]
}
ParameterDescription
referenceKey"FS-100-black-S" is an example for an unique variant identifier provided by the tenants ERP system.
attributesHere we can provide attributes on variant level. For Fashion Store we want to provide a value for the simple and not translatable size attribute group.

Congratulations: You have successfully created your first product variant in SCAYLE!

Further education - SCAYLE Academy