Appearance
Variantes de Produto
Gerencie as variantes de produtos do tipo variable. Cada variante representa uma combinação de atributos (ex: Tamanho P + Cor Azul).
TIP
Variantes só existem em produtos do tipo variable. Para criar variantes, primeiro crie os atributos e seus valores.
Listar variantes de um produto
http
GET /api/v1/products/{product_id}/variantsExemplo
bash
curl -X GET https://sualoja.com.br/api/v1/products/1/variants \
-H "X-API-Key: SUA_CHAVE"Resposta
json
{
"data": [
{
"id": 10,
"product_id": 1,
"variant_group_id": null,
"sku": "CAM-001-P-VERM",
"price": 89.90,
"sale_price": null,
"stock": 50,
"weight": 0.3,
"dimensions": {
"length": 30,
"width": 25,
"height": 3
},
"active": true,
"order": 0,
"attribute_values": [
{ "id": 1, "attribute": "Cor", "value": "Vermelho" },
{ "id": 5, "attribute": "Tamanho", "value": "P" }
],
"images": {
"cover": "https://sualoja.com.br/storage/.../variant-cover.webp",
"gallery": []
},
"created_at": "2026-01-15T10:30:00Z",
"updated_at": "2026-03-10T14:22:00Z"
}
]
}Criar variante
http
POST /api/v1/products/{product_id}/variantsCampos
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
attribute_value_ids | array | ✅ | IDs dos valores de atributo (ex: [1, 5]) |
sku | string | SKU da variante (deve ser único) | |
price | number | Preço (se diferente do produto pai) | |
sale_price | number | Preço promocional | |
stock | integer | Estoque da variante | |
weight | number | Peso em kg | |
length | number | Comprimento em cm | |
width | number | Largura em cm | |
height | number | Altura em cm | |
active | boolean | Ativa (padrão: true) | |
order | integer | Ordem de exibição |
Exemplo
bash
curl -X POST https://sualoja.com.br/api/v1/products/1/variants \
-H "X-API-Key: SUA_CHAVE" \
-H "Content-Type: application/json" \
-d '{
"attribute_value_ids": [1, 5],
"sku": "CAM-001-P-VERM",
"price": 89.90,
"stock": 50
}'Resposta 201 Created
json
{
"data": {
"id": 10,
"product_id": 1,
"sku": "CAM-001-P-VERM",
"price": 89.90,
"stock": 50,
"active": true,
"attribute_values": [
{ "id": 1, "attribute": "Cor", "value": "Vermelho" },
{ "id": 5, "attribute": "Tamanho", "value": "P" }
]
}
}Atualizar variante
http
PUT /api/v1/products/{product_id}/variants/{variant_id}Aceita os mesmos campos do POST, todos opcionais.
Exemplo
bash
curl -X PUT https://sualoja.com.br/api/v1/products/1/variants/10 \
-H "X-API-Key: SUA_CHAVE" \
-H "Content-Type: application/json" \
-d '{
"stock": 30,
"price": 79.90
}'Excluir variante
http
DELETE /api/v1/products/{product_id}/variants/{variant_id}Resposta
json
{
"message": "Variante removida."
}