---
description: This is how you can create variable product via API.
---

# Create a variable product

{% hint style="info" %}
Please note that for this to work, you need to create a template beforehand. This mutation can only assign the product to an already existing template, and will NOT create a new one.&#x20;
{% endhint %}

{% hint style="info" %}
While templateCode is required, categoryCodes is not. But if used, also needed to be created beforehand.
{% endhint %}

```graphql
mutation {
  productCreateVariable(
    input: {
      sku: "SKU_VAR_PRODUCT"
      templateCode: "Tshirts"
      categoryCodes: "DELL"
    }
  ) {
    __typename
  }
}
```
