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

# Atualizar Produto

> Aprenda a atualizar produtos usando o endpoint PUT /stores/{storeId}/products/{productId}.

## 📌 Endpoint

`PUT /stores/{storeId}/products/{productId}`

Atualiza os dados de um produto existente.

***

## 🔐 Autenticação

* **Rota privada**.
* Requer header `Authorization` com sua API key e plano ativo.

```json theme={null}
{
	"Authorization": "SUA_API_KEY_AQUI"
}
```

***

## 🧾 Parâmetros de rota

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `storeId` | string | Sim | ID da loja |
| `productId` | string | Sim | ID do produto |

***

## 🧍 Body (JSON)

Todos os campos são opcionais (enviar `null` mantém o valor atual do campo), mas devem respeitar as regras abaixo quando enviados:

* `name` (3-32)
* `image` (string até 512 caracteres; enviar `""` remove a imagem, enquanto `null` mantém inalterada)
* `description` (12-256)
* `categoryIds` (array de IDs de categorias da loja)
* `delivery` (`DIGITAL` ou `PHYSICAL`)
* `price` (0.5 a 9999)
* `stock` (inteiro -1 a 9999, `-1` ilimitado)
* `disabled` (`true` ou `false`)
* `position` (inteiro maior ou igual a 1)
* `metadata` (objeto)

***

## ✅ Exemplo de requisição

```bash theme={null}
curl -X PUT "https://api.cabrapi.com.br/v1/stores/STORE_ID/products/PRODUCT_ID" \
	-H "Authorization: SUA_API_KEY_AQUI" \
	-H "Content-Type: application/json" \
	-d '{
		"name": "Curso Premium Atualizado",
		"price": 59.9,
		"stock": 80,
		"disabled": true
	}'
```

***

## Snippet padrao (cURL)

Use o exemplo cURL da secao Exemplo de requisicao acima como snippet oficial.

***

## 📦 Resposta de sucesso (200)

```json theme={null}
{
	"code": "SUCCESS",
	"product": {
		"id": "PRODUCT_ID",
		"name": "Curso Premium Atualizado",
		"position": 2,
		"description": "Acesso completo ao conteúdo.",
		"price": 59.9,
		"image": null,
		"delivery": "DIGITAL",
		"stock": 80,
		"sold": 12,
		"storeId": "STORE_ID",
		"disabled": true,
		"metadata": {},
		"createdAt": "2026-03-02T20:00:00.000Z",
		"updatedAt": "2026-03-02T21:00:00.000Z",
		"categories": [
			{
				"id": "CATEGORY_ID",
				"name": "Cursos"
			}
		]
	}
}
```

***

## ⚠️ Possíveis erros

* `400 INVALID_DATA` → body, parâmetros ou item de `categoryIds` inválido
* `400 INVALID_DATA_NAME_MIN` → `name` com menos de 3 caracteres
* `400 INVALID_DATA_NAME_MAX` → `name` com mais de 32 caracteres
* `400 INVALID_DATA_IMAGE` → `image` com mais de 512 caracteres
* `400 INVALID_DATA_DESCRIPTION_MIN` → `description` com menos de 12 caracteres
* `400 INVALID_DATA_DESCRIPTION_MAX` → `description` com mais de 256 caracteres
* `400 INVALID_DATA_DELIVERY` → `delivery` diferente de `DIGITAL` ou `PHYSICAL`
* `400 INVALID_DATA_PRICE` → `price` fora do intervalo `0.5` a `9999`
* `400 INVALID_DATA_STOCK` → `stock` fora do intervalo `-1` a `9999`
* `400 INVALID_DATA_POSITION` → `position` menor que `1`
* `400 CATEGORY_NOT_FOUND` → uma ou mais categorias em `categoryIds` não encontradas na loja
* `400 NAME_ALREADY_EXISTS` → nome já utilizado
* `401 API_KEY_NOT_PROVIDED` → header `Authorization` não enviado (ou `TOKEN_NOT_PROVIDED` via Bearer)
* `401 INVALID_API_KEY` → API Key inválida (ou `INVALID_TOKEN` / `TOKEN_EXPIRED` / `SESSION_NOT_FOUND` / `SESSION_EXPIRED` / `UNAUTHENTICATED` via Bearer)
* `403 USER_DISABLED` → usuário desativado ou excluído
* `403 NO_ACTIVE_SUBSCRIPTION` → plano inativo ou expirado (ou `PENDING_2FA` via Bearer)
* `404 STORE_NOT_FOUND` → loja não encontrada
* `404 PRODUCT_NOT_FOUND` → produto não encontrado
* `429 RATE_LIMIT_EXCEEDED` → limite de requisições por minuto excedido
* `500 INTERNAL_SERVER_ERROR` → erro interno
* `503 SERVICE_UNAVAILABLE` → serviço ou banco de dados indisponível


## OpenAPI

````yaml PUT /stores/{storeId}/products/{productId}
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/products/{productId}:
    put:
      tags:
        - Products
      summary: Update product
      operationId: updateProduct
      parameters:
        - $ref: '#/components/parameters/StoreId'
        - $ref: '#/components/parameters/ProductId'
      requestBody:
        required: true
        description: Product fields to update.
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 3
                  maxLength: 32
                image:
                  type: string
                  maxLength: 512
                  nullable: true
                description:
                  maxLength: 256
                  minLength: 12
                  type: string
                categoryIds:
                  type: array
                  items:
                    type: string
                    minLength: 1
                    maxLength: 50
                delivery:
                  enum:
                    - DIGITAL
                    - PHYSICAL
                  type: string
                price:
                  type: number
                  minimum: 0.5
                  maximum: 9999
                stock:
                  type: integer
                  minimum: -1
                  maximum: 9999
                position:
                  minimum: 1
                  type: integer
                metadata:
                  type: object
                disabled:
                  type: boolean
              minProperties: 1
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: SUCCESS
                    type: string
                  product:
                    $ref: '#/components/schemas/Product'
                required:
                  - code
                  - product
                type: object
          description: Update product.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Invalid request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid API key.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Forbidden (inactive plan or insufficient permissions).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Rate limit exceeded.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal server error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Service unavailable.
      security:
        - ApiKey: []
components:
  parameters:
    StoreId:
      in: path
      name: storeId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
    ProductId:
      in: path
      name: productId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
  schemas:
    Product:
      description: Store product.
      properties:
        categories:
          items:
            properties:
              id:
                format: uuid
                type: string
              name:
                type: string
            required:
              - id
              - name
            type: object
          type: array
        createdAt:
          format: date-time
          type: string
        delivery:
          enum:
            - DIGITAL
            - PHYSICAL
          type: string
        description:
          nullable: true
          type: string
        disabled:
          type: boolean
        id:
          format: uuid
          type: string
        image:
          nullable: true
          type: string
        metadata:
          nullable: true
          type: object
        name:
          type: string
        position:
          type: integer
        price:
          type: number
        sold:
          type: integer
        stock:
          type: integer
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - id
        - name
        - position
        - price
        - delivery
        - stock
        - sold
        - storeId
        - disabled
        - createdAt
        - updatedAt
        - categories
      type: object
    Error:
      properties:
        code:
          example: STORE_NOT_FOUND
          type: string
      required:
        - code
      type: object
  securitySchemes:
    ApiKey:
      in: header
      name: Authorization
      type: apiKey
      x-default: YOUR_API_KEY_HERE

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.