This is how you can create variable product via API.
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.
While templateCode is required, categoryCodes is not. But if used, also needed to be created beforehand.