variantUpdate
Required scope: edit_products
Update fields on an existing variant. Only the fields provided in the input will be modified.
CMS source restriction
Variants with source: CMS can only be updated by the same OAuth client that originally created them.
Mutation
graphql
mutation VariantUpdate($input: VariantInput!) {
variantUpdate(input: $input) {
id
sku
title
weight
weightUnit
}
}Input — VariantInput
| Field | Type | Required | Description |
|---|---|---|---|
organizationId | String | ✅ | Organization UUID |
productId | String | ❌ | Parent product ID |
sku | String | ❌ | Updated SKU (must remain unique within organization) |
title | String | ❌ | Updated variant label |
status | ProductStatusEnum | ❌ | Updated status (prefer dedicated lifecycle mutations) |
model | ProductModelEnum | ❌ | Updated model (prefer variantChangeModel) |
weight | Float | ❌ | Updated weight value |
weightUnit | WeightUnitEnum | ❌ | G, KG, LB, or OZ |
height | Float | ❌ | Updated height |
width | Float | ❌ | Updated width |
length | Float | ❌ | Updated length |
distanceUnit | DistanceUnitEnum | ❌ | CM or IN |
barcode | String | ❌ | Updated barcode |
originCountry | String | ❌ | Updated ISO country code |
hsCode | String | ❌ | Updated HS tariff code |
Example
Variables
json
{
"input": {
"organizationId": "org_123",
"weight": 210,
"weightUnit": "G",
"height": 32,
"width": 26,
"length": 5,
"distanceUnit": "CM"
}
}Response
json
{
"data": {
"variantUpdate": {
"id": "var_001",
"sku": "TSHIRT-S-BLUE",
"title": "Small / Blue",
"weight": 210,
"weightUnit": "G"
}
}
}Code Examples
bash
curl -X POST https://api-v3.happycolis.com/graphql \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation VariantUpdate($input: VariantInput!) { variantUpdate(input: $input) { id sku title weight weightUnit } }",
"variables": {
"input": {
"organizationId": "org_123",
"weight": 210,
"weightUnit": "G",
"height": 32,
"width": 26,
"length": 5,
"distanceUnit": "CM"
}
}
}'js
async function updateVariant(accessToken, variantData) {
const response = await fetch('https://api-v3.happycolis.com/graphql', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
mutation VariantUpdate($input: VariantInput!) {
variantUpdate(input: $input) {
id
sku
title
weight
weightUnit
}
}
`,
variables: { input: variantData },
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
return data.variantUpdate;
}
// Usage
const variant = await updateVariant(accessToken, {
organizationId: 'org_123',
weight: 210,
weightUnit: 'G',
height: 32,
width: 26,
length: 5,
distanceUnit: 'CM',
});python
import requests
def update_variant(access_token, variant_data):
response = requests.post(
'https://api-v3.happycolis.com/graphql',
headers={
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json',
},
json={
'query': '''
mutation VariantUpdate($input: VariantInput!) {
variantUpdate(input: $input) {
id
sku
title
weight
weightUnit
}
}
''',
'variables': {'input': variant_data},
},
)
result = response.json()
if 'errors' in result:
raise Exception(result['errors'][0]['message'])
return result['data']['variantUpdate']
# Usage
variant = update_variant(access_token, {
'organizationId': 'org_123',
'weight': 210,
'weightUnit': 'G',
'height': 32,
'width': 26,
'length': 5,
'distanceUnit': 'CM',
})php
function updateVariant(string $accessToken, array $variantData): array
{
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api-v3.happycolis.com/graphql', [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json',
],
'json' => [
'query' => '
mutation VariantUpdate($input: VariantInput!) {
variantUpdate(input: $input) {
id
sku
title
weight
weightUnit
}
}
',
'variables' => ['input' => $variantData],
],
]);
$result = json_decode($response->getBody()->getContents(), true);
if (isset($result['errors'])) {
throw new \Exception($result['errors'][0]['message']);
}
return $result['data']['variantUpdate'];
}
// Usage
$variant = updateVariant($accessToken, [
'organizationId' => 'org_123',
'weight' => 210,
'weightUnit' => 'G',
'height' => 32,
'width' => 26,
'length' => 5,
'distanceUnit' => 'CM',
]);go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type VariantUpdateInput struct {
OrganizationID string `json:"organizationId"`
SKU string `json:"sku,omitempty"`
Title string `json:"title,omitempty"`
Weight *float64 `json:"weight,omitempty"`
WeightUnit string `json:"weightUnit,omitempty"`
Height *float64 `json:"height,omitempty"`
Width *float64 `json:"width,omitempty"`
Length *float64 `json:"length,omitempty"`
DistanceUnit string `json:"distanceUnit,omitempty"`
Barcode string `json:"barcode,omitempty"`
OriginCountry string `json:"originCountry,omitempty"`
HsCode string `json:"hsCode,omitempty"`
}
func updateVariant(accessToken string, input VariantUpdateInput) (map[string]interface{}, error) {
query := `
mutation VariantUpdate($input: VariantInput!) {
variantUpdate(input: $input) {
id
sku
title
weight
weightUnit
}
}
`
body, _ := json.Marshal(map[string]interface{}{
"query": query,
"variables": map[string]interface{}{"input": input},
})
req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+accessToken)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
if errs, ok := result["errors"]; ok {
return nil, fmt.Errorf("graphql error: %v", errs)
}
data := result["data"].(map[string]interface{})
return data["variantUpdate"].(map[string]interface{}), nil
}