> ## 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 Oferta

> Atualiza uma oferta existente de um produto

## Visão Geral

Este endpoint permite atualizar as informações de uma oferta existente vinculada a um produto.

## Endpoint

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

## Parâmetros

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

<ParamField path="offerHash" type="string" required>
  Hash identificador único da oferta
</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 da oferta
</ParamField>

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

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

## Exemplo de Requisição

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT 'https://api.klivopay.com.br/api/public/v1/products/prod123abc/offers/offer123' \
    -H 'Content-Type: application/json' \
    -d '{
      "api_token": "seu_token_aqui",
      "title": "Super Promoção",
      "amount": 14900
    }'
  ```

  ```javascript JavaScript theme={null}
  const productHash = 'prod123abc';
  const offerHash = 'offer123';
  const response = await fetch(
    `https://api.klivopay.com.br/api/public/v1/products/${productHash}/offers/${offerHash}`,
    {
      method: 'PUT',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        api_token: 'seu_token_aqui',
        title: 'Super Promoção',
        amount: 14900
      })
    }
  );

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

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

  product_hash = 'prod123abc'
  offer_hash = 'offer123'
  url = f'https://api.klivopay.com.br/api/public/v1/products/{product_hash}/offers/{offer_hash}'
  payload = {
      'api_token': 'seu_token_aqui',
      'title': 'Super Promoção',
      'amount': 14900
  }

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

  ```php PHP theme={null}
  <?php
  $productHash = 'prod123abc';
  $offerHash = 'offer123';
  $url = "https://api.klivopay.com.br/api/public/v1/products/{$productHash}/offers/{$offerHash}";
  $data = [
      'api_token' => 'seu_token_aqui',
      'title' => 'Super Promoção',
      'amount' => 14900
  ];

  $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": "offer123",
    "title": "Super Promoção",
    "amount": 14900,
    "product_hash": "prod123abc",
    "updated_at": "2025-01-20T15:30:00Z"
  }
}
```

## Códigos de Resposta

<ResponseField name="200" type="OK">
  Oferta atualizada 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 ou oferta 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>
