> ## Documentation Index
> Fetch the complete documentation index at: https://docs.klivopay.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Atualizar Produto

> Atualiza as informações de um produto existente

## Visão Geral

Este endpoint permite atualizar as informações de um produto já cadastrado na plataforma KlivoPay.

## Endpoint

```
PUT https://api.klivopay.com.br/api/public/v1/products/{hash}
```

## Parâmetros

<ParamField path="hash" type="string" required>
  Hash identificador único do produto
</ParamField>

<ParamField body="api_token" type="string" required>
  Seu token de autenticação da API KlivoPay
</ParamField>

<ParamField body="title" type="string">
  Novo título/nome do produto
</ParamField>

<ParamField body="cover" type="string">
  Nova URL da imagem de capa
</ParamField>

<ParamField body="amount" type="integer">
  Novo valor em centavos
</ParamField>

<ParamField body="sale_page" type="string">
  Nova URL da página de vendas
</ParamField>

<ParamField body="product_type" type="string">
  Tipo do produto: `digital` ou `fisico`
</ParamField>

<ParamField body="id_category" type="integer">
  Novo ID da categoria
</ParamField>

## Exemplo de Requisição

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT 'https://api.klivopay.com.br/api/public/v1/products/prod123abc' \
    -H 'Content-Type: application/json' \
    -d '{
      "api_token": "seu_token_aqui",
      "title": "Curso Completo de Marketing Digital",
      "amount": 39900
    }'
  ```

  ```javascript JavaScript theme={null}
  const hash = 'prod123abc';
  const response = await fetch(
    `https://api.klivopay.com.br/api/public/v1/products/${hash}`,
    {
      method: 'PUT',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        api_token: 'seu_token_aqui',
        title: 'Curso Completo de Marketing Digital',
        amount: 39900
      })
    }
  );

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  hash_id = 'prod123abc'
  url = f'https://api.klivopay.com.br/api/public/v1/products/{hash_id}'
  payload = {
      'api_token': 'seu_token_aqui',
      'title': 'Curso Completo de Marketing Digital',
      'amount': 39900
  }

  response = requests.put(url, json=payload)
  print(response.json())
  ```

  ```php PHP theme={null}
  <?php
  $hash = 'prod123abc';
  $url = "https://api.klivopay.com.br/api/public/v1/products/{$hash}";
  $data = [
      'api_token' => 'seu_token_aqui',
      'title' => 'Curso Completo de Marketing Digital',
      'amount' => 39900
  ];

  $options = [
      'http' => [
          'header'  => "Content-Type: application/json\r\n",
          'method'  => 'PUT',
          'content' => json_encode($data)
      ]
  ];

  $context = stream_context_create($options);
  $result = file_get_contents($url, false, $context);
  print_r(json_decode($result));
  ?>
  ```
</CodeGroup>

## Resposta de Sucesso

```json 200 OK theme={null}
{
  "success": true,
  "data": {
    "hash": "prod123abc",
    "title": "Curso Completo de Marketing Digital",
    "cover": "https://exemplo.com/capa.jpg",
    "amount": 39900,
    "updated_at": "2025-01-20T15:30:00Z"
  }
}
```

## Códigos de Resposta

<ResponseField name="200" type="OK">
  Produto atualizado com sucesso
</ResponseField>

<ResponseField name="400" type="Bad Request">
  Dados inválidos na requisição
</ResponseField>

<ResponseField name="401" type="Unauthorized">
  Token de API inválido ou ausente
</ResponseField>

<ResponseField name="404" type="Not Found">
  Produto não encontrado
</ResponseField>

<ResponseField name="422" type="Unprocessable Entity">
  Erro de validação nos dados enviados
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Erro interno do servidor
</ResponseField>
