# Copy of Produto Variável

## PUT - Atualizando a variação de um produto

Será necessário o método PUT com os mesmos headers para realizar a atualização da variação, porém o endpoint utilizado é o */variations* seguido do SKU da variação conforme abaixo:

```
https://api.skyhub.com.br/variations/{SKU_VARIACAO}
```

#### **Request headers:**

| Key                  | Value                                       |
| -------------------- | ------------------------------------------- |
| X-User-Email         | email\_de\_usuario                          |
| x-Api-Key            | token\_de\_integracao de sua conta SkyHub   |
| x-accountmanager-key | token\_account único de cada Plataforma/ERP |
| Accept               | application/json                            |
| Content-Type         | application/json                            |

#### **Request body:**

```
{
  "variation": {
    "price": 158,
    "promotional_price": 126.4,
    "images": [
      "https://foo"
    ],
    "ean": "0000000000000",
    "qty": "10",
    "specifications": [
      {
        "value": "Atributo",
        "key": "Valor"
      }
    ]
  }
}
```

{% hint style="danger" %}
O objeto ***product*** deve ser substituído pelo ***variation*** e não pode ser retirado da requisição, caso contrário um erro será retornado na tentativa de atualizar a variação.
{% endhint %}

#### **Example request:**

```
curl --location -g --request PUT 'https://api.skyhub.com.br/variations/{SKU_VARIACAO}' \
--header 'X-User-Email: email_de_usuario' \
--header 'x-Api-Key: token_de_integracao de sua conta SkyHub' \
--header 'x-accountmanager-key: token_account único de cada Plataforma/ERP' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
  "variation": {
    "price": 158,
    "promotional_price": 126.4
    "images": [
      "https://images-americanas.b2w.io/produtos/2638788562/imagens/regata-basic-feminina-canelada-branca/2638788562_1_xlarge.jpg"
    ],
    "ean": "0123456789012",
    "qty": "5",
    "specifications": [
      {
        "value": "crossdocking",
        "key": "3"
      }
    ]
  }
}'
```

#### **Response esperado:**

{% hint style="success" %}
204 \[Success] - No content
{% endhint %}

{% hint style="danger" %}
Para a atualização de **imagens** é necessário atentar-se a **URL** indexada: Para realizar alterações nas imagens de um produto é preciso encaminhar uma **nova URL**, ou seja, <mark style="color:red;">**não é possível reutilizar a URL previamente enviada**</mark>; somente com URLs diferentes a nova imagem será refletida pelo marketplace.&#x20;

\[Ver Comunicado: [Envio de Imagens para o Marketplace](/comunicados/comunicados-2021/envio-de-imagens-para-o-mktp-b2w.md)]
{% endhint %}

### Como atualizar preço e estoque

Assim como quaisquer atualizações em variações, para alterações nos campos de preço (*price* e *promotional\_price*) e estoque deve ser utilizado o método **PUT** no */variations/{SKU\_VARIACAO}*.&#x20;

{% hint style="info" %}
Deve ser realizado um PUT por variação.
{% endhint %}

A seguir temos exemplos de requisições para as atualizações de preço e estoque para variações:

#### Atualização de preço por variação:

```
curl --location -g --request PUT 'https://api.skyhub.com.br/variations/{SKU_VARIACAO}' \
--header 'X-User-Email: email_de_usuario' \
--header 'x-Api-Key: token_de_integracao de sua conta SkyHub' \
--header 'x-accountmanager-key: token_account único de cada Plataforma/ERP' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
  "variation": {
    "price": 158,
    "promotional_price": 126.4
  	"specifications": [
  		{
  			"key": "price",
  			"value": "50.00"
  		},
  		{
  			"key": "promotional_price",
  			"value": "45.00"
  		}
  	]
  }
}'
```

#### Atualização de estoque por variação:

```
curl --location -g --request PUT 'https://api.skyhub.com.br/variations/{SKU_VARIACAO}' \
--header 'X-User-Email: email_de_usuario' \
--header 'x-Api-Key: token_de_integracao de sua conta SkyHub' \
--header 'x-accountmanager-key: token_account único de cada Plataforma/ERP' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
  "variation": {
      "qty": 1
  }
}'
```

#### Atualização de preço e estoque:

```
curl --location -g --request PUT 'https://api.skyhub.com.br/variations/{SKU_VARIACAO}' \
--header 'X-User-Email: email_de_usuario' \
--header 'x-Api-Key: token_de_integracao de sua conta SkyHub' \
--header 'x-accountmanager-key: token_account único de cada Plataforma/ERP' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
  "variation": {
    "qty": 5,
    "price": 158,
    "promotional_price": 126.4
  	"specifications": [
  		{
  			"key": "price",
  			"value": "185.90"
  		},
  		{
  			"key": "promotional_price",
  			"value": "180.90"
  		}
  	]
  }
}'
```

{% hint style="info" %}
Caso deseje realizar alterações no SKU agrupador é possível seguir as orientações da guia Atualização de Produto > [Produto Simples](/produtos/atualizacao-produto/produto-simples.md#put-atualizando-um-produto-simples).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://desenvolvedores.skyhub.com.br/produtos/atualizacao-produto/produto-variavel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
