{
  "openapi": "3.1.0",
  "info": {
    "title": "Autenticação, Sessão e Mídia",
    "description": "Token de acesso, sessão ativa da loja e upload/gestão de imagens (utilitário compartilhado entre produtos e anúncios).",
    "version": "1.0.0",
    "contact": {
      "name": "UniSupri"
    }
  },
  "servers": [
    {
      "url": "https://api.sandbox.samdevel.com.br",
      "description": "Sandbox (ambiente de homologação)"
    }
  ],
  "tags": [
    {
      "name": "Autenticação",
      "description": "Obtenha um token de acesso a partir da credencial (username + senha) criada no Portal do Vendedor.\n\nO token vale por **30 dias** e cada chamada rotaciona — invalida o token anterior. Endpoint público, protegido por rate limit por IP+username.\n\nFluxo completo, erros, troca de senha e boas práticas: ver guia de [Autenticação](/guia/autenticacao)."
    },
    {
      "name": "Sessão",
      "description": "Confirma o token e retorna os dados da loja autenticada, a `company` associada e os escopos. Útil pra validar que a integração está apontando pra loja certa antes de fazer qualquer outra chamada."
    },
    {
      "name": "Media",
      "description": "Upload, listagem e remoção de imagens.\n\n**Formatos aceitos:** JPEG, PNG, WebP (máx. 2MB)\n\n**Fluxo de uso:**\n1. Envie a imagem via `POST /api/media/upload` (multipart/form-data)\n2. Use o `id` retornado para vincular a galeria de produtos ou à página da loja\n\n**Regras de retenção:**\n- Imagens não associadas a nenhum recurso são excluídas por uma rotina de limpeza da plataforma (janela de **~72h**)\n- Enquanto uma imagem estiver vinculada a um produto ou à loja, a exclusão é bloqueada (erro 409) — assim você não derruba sem querer uma imagem que está no ar. Desvincule do recurso primeiro e só então exclua."
    }
  ],
  "paths": {
    "/api/media": {
      "get": {
        "summary": "Listar Imagens",
        "description": "Retorna uma lista paginada de imagens do seller autenticado. Suporta filtros por `reference_id`, `reference_model` e `in_use`, além de ordenação por `created_at` e `updated_at`.",
        "tags": [
          "Media"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Número da página atual.",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "description": "Quantidade de itens por página (min: 1, max: 100).",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 15,
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "filter[in_use]",
            "in": "query",
            "description": "Filtrar por imagens que estão em uso ou não.",
            "required": false,
            "schema": {
              "type": "boolean",
              "example": true
            }
          },
          {
            "name": "filter[reference_id]",
            "in": "query",
            "description": "Filtrar pelo ID do recurso referenciado.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter[reference_model]",
            "in": "query",
            "description": "Filtra por tipo de recurso vinculado. Use sempre o nome curto (`product`, `publication`, `store`) — esses aliases são a forma estável e pública; nomes de classe internos não são aceitos e retornam 422.",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "product",
                "publication",
                "store"
              ]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Campo de ordenação. Prefixe com `-` para descendente. Valores permitidos: `created_at`, `updated_at`.",
            "required": false,
            "schema": {
              "type": "string",
              "example": "-created_at"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso. Retorna a coleção paginada de imagens.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaCollectionResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/api/media/upload": {
      "post": {
        "summary": "Upload de Imagem",
        "description": "Realiza o upload de uma nova imagem. Formatos aceitos: JPEG, PNG e WebP. Tamanho máximo: 2 MB. A imagem é convertida para WebP e redimensionada automaticamente nas variações `thumbnail`, `sm`, `md`, `lg` e `xl`.",
        "tags": [
          "Media"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "image"
                ],
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "Arquivo de imagem (jpeg, png, webp). Máximo 2 MB."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Imagem enviada e processada com sucesso.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaCreatedResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "description": "Erro de validação no upload",
            "content": {
              "application/json": {
                "examples": {
                  "image_required": {
                    "summary": "Imagem não enviada",
                    "value": {
                      "success": false,
                      "code": 422,
                      "message_code": "VALIDATION_ERROR",
                      "description": "Foram encontrados erros de validação na requisição.",
                      "data": [],
                      "errors": {
                        "image": [
                          "A imagem é obrigatória."
                        ]
                      },
                      "meta": []
                    }
                  },
                  "invalid_mime": {
                    "summary": "Tipo de arquivo inválido",
                    "value": {
                      "success": false,
                      "code": 422,
                      "message_code": "VALIDATION_ERROR",
                      "description": "Foram encontrados erros de validação na requisição.",
                      "data": [],
                      "errors": {
                        "image": [
                          "A imagem deve ser dos tipos: jpeg, png ou webp."
                        ]
                      },
                      "meta": []
                    }
                  },
                  "file_too_large": {
                    "summary": "Arquivo excede 2 MB",
                    "value": {
                      "success": false,
                      "code": 422,
                      "message_code": "VALIDATION_ERROR",
                      "description": "Foram encontrados erros de validação na requisição.",
                      "data": [],
                      "errors": {
                        "image": [
                          "A imagem deve ter no máximo 2MB."
                        ]
                      },
                      "meta": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/media/clone-from-skus": {
      "post": {
        "summary": "Clonar fotos a partir de produtos (SKUs)",
        "description": "Copia as fotos da galeria dos produtos informados e devolve **novas mídias independentes**, prontas para usar em um anúncio.\n\nNo nosso modelo, uma mídia pertence a uma única entidade — a foto da galeria do produto não pode ser vinculada diretamente a um anúncio. Esta rota resolve isso: os arquivos são copiados no storage e cada cópia vira um registro novo, com `source_image_id` apontando para a imagem de origem.\n\nCada alvo é um par `key` + `sku`. A `key` é um rótulo livre seu (por exemplo, o valor do atributo de variação — `\"Azul\"` — ou `\"general\"` para a galeria do anúncio) e serve só para você reencontrar as cópias na resposta. O mesmo SKU em duas keys diferentes gera **cópias distintas** — é o esperado, já que cada variação do anúncio precisa das suas próprias mídias.\n\nNão se preocupe com sobras: cópia que não for usada em nenhum anúncio é removida automaticamente pela limpeza diária de mídia (após ~72 horas).\n\nSKU que não pertence (ou não está associado) à sua loja não gera erro — ele apenas aparece em `ignored_skus` e a key correspondente volta vazia.",
        "tags": [
          "Media"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "targets"
                ],
                "properties": {
                  "targets": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 30,
                    "description": "Lista de alvos de clonagem. Máximo de 30 por requisição.",
                    "items": {
                      "type": "object",
                      "required": [
                        "key",
                        "sku"
                      ],
                      "properties": {
                        "key": {
                          "type": "string",
                          "maxLength": 100,
                          "description": "Rótulo livre para agrupar as cópias na resposta (ex.: valor da variação ou \"general\").",
                          "example": "Azul"
                        },
                        "sku": {
                          "type": "string",
                          "maxLength": 100,
                          "description": "SKU do produto cuja galeria será clonada.",
                          "example": "CAMISETA-AZUL-M"
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "targets": [
                  {
                    "key": "Azul",
                    "sku": "CAMISETA-AZUL-M"
                  },
                  {
                    "key": "Vermelho",
                    "sku": "CAMISETA-VERM-M"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cópias criadas. As keys do `results` são as mesmas enviadas nos targets — keys de SKUs ignorados ou sem fotos voltam com lista vazia. As fotos vêm na ordem de exibição do produto (thumbnail primeiro).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaCloneFromSkusResponse"
                },
                "example": {
                  "success": true,
                  "message_code": "OK",
                  "data": {
                    "results": {
                      "Azul": [
                        {
                          "id": "01JNB2T4G93QRT5V6W7X8Y9Z0A",
                          "source_image_id": "01JMZXZ72881MD2P37N2K97YJJ",
                          "original_source": "https://cdn.example.com/products/2026/06/11/original_01JNB2T4G93QRT5V6W7X8Y9Z0A.webp",
                          "urls": [
                            {
                              "name": "sm",
                              "size": "200x200",
                              "url": "https://cdn.example.com/products/2026/06/11/sm_01JNB2T4G93QRT5V6W7X8Y9Z0A.webp"
                            }
                          ]
                        }
                      ],
                      "Vermelho": []
                    },
                    "ignored_skus": [
                      "CAMISETA-VERM-M"
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "description": "Erro de validação nos targets.",
            "content": {
              "application/json": {
                "examples": {
                  "targets_required": {
                    "summary": "Nenhum alvo informado",
                    "value": {
                      "success": false,
                      "code": 422,
                      "message_code": "VALIDATION_ERROR",
                      "description": "Foram encontrados erros de validação na requisição.",
                      "data": [],
                      "errors": {
                        "targets": [
                          "Informe ao menos um alvo (key + sku)."
                        ]
                      },
                      "meta": []
                    }
                  },
                  "too_many_targets": {
                    "summary": "Mais de 30 alvos",
                    "value": {
                      "success": false,
                      "code": 422,
                      "message_code": "VALIDATION_ERROR",
                      "description": "Foram encontrados erros de validação na requisição.",
                      "data": [],
                      "errors": {
                        "targets": [
                          "Máximo de 30 alvos por requisição."
                        ]
                      },
                      "meta": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/media/{file_hash}": {
      "get": {
        "summary": "Detalhes da Imagem",
        "description": "Retorna detalhes de uma imagem específica pelo hash/ID.",
        "tags": [
          "Media"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "file_hash",
            "in": "path",
            "description": "ID da imagem.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso. Retorna os dados da imagem.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaItemResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "summary": "Excluir Imagem",
        "description": "Remove uma imagem permanentemente. Imagens que estão em uso (`in_use = true`) não podem ser excluídas (retorna 409).",
        "tags": [
          "Media"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "file_hash",
            "in": "path",
            "description": "ID da imagem.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Imagem excluída com sucesso. Sem conteúdo no corpo da resposta."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/api/integration/auth": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Obter token de acesso",
        "description": "Recebe o **username** e a **senha** de uma credencial criada no Portal do Vendedor e devolve um **token de acesso** (`sk_live_*`) válido por 30 dias.\n\n**Rotação:** cada chamada bem-sucedida invalida o token anterior — só existe 1 token ativo por credencial. Crie credenciais separadas para sistemas que precisam de tokens independentes.\n\n**Endpoint público:** não exige `Authorization` — a própria credencial autentica.\n\n**Rate limit:** 5 tentativas por minuto por `(IP, username)`. Excedeu → 429.\n\n**Erros 401:** mensagem genérica de propósito (não revela se a falha foi por username inexistente, senha errada ou credencial inativa) para evitar enumeração.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password"
                ],
                "properties": {
                  "username": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "Username da credencial, no formato `slug-loja@cnpj-curto` (ex.: `loja-xpto@12345678`). Gerado automaticamente na criação da credencial."
                  },
                  "password": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "Senha da credencial. Mostrada uma única vez na criação (e na troca de senha) — guarde em cofre de senhas."
                  }
                }
              },
              "example": {
                "username": "loja-xpto@12345678",
                "password": "Xk9p2Lm7nQ4rT8vW3yZ1"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token emitido. O token anterior, se houver, deixa de funcionar.",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "message_code": "SUCCESS",
                  "data": {
                    "token": "sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6",
                    "expires_at": "2026-06-19T12:34:56-03:00"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Credenciais inválidas. Username não encontrado, senha errada **ou** credencial inativa — a mensagem é a mesma para não vazar oracle.",
            "content": {
              "application/json": {
                "example": {
                  "success": false,
                  "message_code": "UNAUTHORIZED",
                  "data": {
                    "message": "Credenciais inválidas."
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validação falhou (username ou password ausente/vazio).",
            "content": {
              "application/json": {
                "example": {
                  "success": false,
                  "code": 422,
                  "message_code": "VALIDATION_ERROR",
                  "description": "Foram encontrados erros de validação na requisição.",
                  "data": [],
                  "errors": {
                    "username": [
                      "O campo username é obrigatório."
                    ],
                    "password": [
                      "O campo password é obrigatório."
                    ]
                  },
                  "meta": []
                }
              }
            }
          },
          "429": {
            "description": "Muitas tentativas — limite de 5 por minuto por (IP, username). Aguarde o `Retry-After` antes de tentar novamente. Atenção: hoje o corpo vem com `message_code` genérico — confie no status HTTP 429 e no header `Retry-After`, não no corpo.",
            "content": {
              "application/json": {
                "example": {
                  "success": false,
                  "code": 500,
                  "message_code": "SERVER_ERROR",
                  "description": "Não foi possivel processar a sua solicitação, revise os dados e tente novamente.",
                  "data": [],
                  "errors": [
                    "Muitas tentativas. Por favor, tente novamente mais tarde."
                  ],
                  "meta": []
                }
              }
            }
          }
        }
      }
    },
    "/api/stores/auth/session": {
      "get": {
        "tags": [
          "Sessão"
        ],
        "summary": "Sessão Ativa",
        "description": "Confirma o token e retorna os dados da loja autenticada. Para tokens de integração, a resposta traz `auth.auth_type: \"integration_token\"`, `auth.is_owner: false` e `scopes` com a lista de habilidades concedidas à credencial — use esse retorno pra validar que a integração está apontando pra loja certa e com as permissões esperadas. A loja vem com seus dados e a `company` associada.",
        "responses": {
          "200": {
            "description": "Sessão ativa",
            "content": {
              "application/json": {
                "example": {
                  "success": true,
                  "message_code": "SUCCESS",
                  "data": {
                    "store": {
                      "store_id": "01KS3PRGYQHHDCRYNRXGSZHP41",
                      "store_name": "EcomShop",
                      "store_code": "ecomshop",
                      "store_status": "active",
                      "store_url": "ecomshop",
                      "store_type": "default",
                      "commission_table_id": null,
                      "max_locations": 5,
                      "features": [],
                      "company": {
                        "company_id": "01KS3PRGYGAAQDJ3APCXNDXRPS",
                        "name": "Empresa de João",
                        "social_name": "João Silva LTDA",
                        "document": {
                          "name": "CNPJ",
                          "type": "cnpj",
                          "number": "94105981000185",
                          "description": "Cadastro Nacional da Pessoa Jurídica"
                        },
                        "state_registration": null,
                        "tax_regime": "simples",
                        "has_primary_store": true,
                        "primary_store_name": null,
                        "allow_partner_branches": false
                      },
                      "shares_products": false,
                      "shares_stock_locations": false,
                      "shares_logistics": false,
                      "is_primary": true,
                      "primary_store": null
                    },
                    "scopes": [
                      "store_products_read",
                      "store_orders_read",
                      "store_rating_read"
                    ],
                    "auth": {
                      "is_owner": false,
                      "auth_type": "integration_token"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "integrationToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Token de Integração da loja (formato: sk_...). Criado em Configurações → Tokens de Integração no painel do seller."
      }
    },
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID do produto (26 caracteres)"
          },
          "name": {
            "type": "string"
          },
          "sku": {
            "type": "string"
          },
          "price_type": {
            "type": "string",
            "enum": [
              "default",
              "wholesale"
            ]
          },
          "base_unit": {
            "type": "string",
            "enum": [
              "un",
              "kg",
              "pc",
              "cx",
              "pct",
              "lt",
              "mt",
              "m2",
              "m3"
            ]
          },
          "dimensions": {
            "type": "object",
            "properties": {
              "width": {
                "type": "number",
                "description": "Largura em cm"
              },
              "height": {
                "type": "number",
                "description": "Altura em cm"
              },
              "length": {
                "type": "number",
                "description": "Comprimento em cm"
              },
              "weight": {
                "type": "number",
                "description": "Peso em kg"
              }
            }
          },
          "is_available_for_sale": {
            "type": "boolean",
            "description": "Indica se o produto está disponível para venda",
            "default": true
          },
          "is_industrializable": {
            "type": "boolean",
            "description": "Indica se o produto pode ser fabricado sob demanda"
          },
          "auto_wholesale_pricing": {
            "type": "boolean",
            "description": "Indica se os preços das faixas de atacado são derivados automaticamente do percentual de desconto"
          },
          "allow_sale_without_stock": {
            "type": "boolean",
            "description": "Permite venda sem estoque disponível (pedido sob encomenda)"
          },
          "dimensions_formatted": {
            "type": "object",
            "nullable": true,
            "description": "Dimensões formatadas para exibição (somente se include_dimensions_formatted=true)",
            "properties": {
              "width": {
                "type": "string",
                "nullable": true,
                "example": "10,00 cm"
              },
              "height": {
                "type": "string",
                "nullable": true,
                "example": "10,00 cm"
              },
              "length": {
                "type": "string",
                "nullable": true,
                "example": "10,00 cm"
              },
              "weight": {
                "type": "string",
                "nullable": true,
                "example": "500g"
              }
            }
          },
          "quantity": {
            "type": "number",
            "description": "Quantidade total em estoque"
          },
          "reserved_quantity": {
            "type": "number",
            "description": "Quantidade reservada"
          },
          "available_quantity": {
            "type": "number",
            "description": "Quantidade disponível para venda (quantity - reserved_quantity)"
          },
          "price": {
            "type": "number",
            "description": "Preço de venda (somente para price_type=default)"
          },
          "min_price": {
            "type": "number",
            "description": "Menor preço entre as faixas (somente para price_type=wholesale)"
          },
          "max_price": {
            "type": "number",
            "description": "Maior preço entre as faixas (somente para price_type=wholesale)"
          },
          "thumbnail": {
            "type": "object",
            "nullable": true,
            "description": "Imagem de destaque do produto (variantes thumbnail e md)",
            "properties": {
              "id": {
                "type": "string",
                "description": "ID da imagem"
              },
              "resources": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Nome da variante (thumbnail, sm, md, lg)"
                    },
                    "size": {
                      "type": "string",
                      "description": "Dimensões da variante (ex: 400x400)"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "ProductInput": {
        "type": "object",
        "required": [
          "name",
          "sku",
          "base_unit",
          "price_type",
          "dimensions"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "sku": {
            "type": "string",
            "maxLength": 50,
            "description": "Deve ser único por loja"
          },
          "base_unit": {
            "type": "string",
            "enum": [
              "un",
              "kg",
              "pc",
              "cx",
              "pct",
              "lt",
              "mt",
              "m2",
              "m3"
            ]
          },
          "price_type": {
            "type": "string",
            "enum": [
              "default",
              "wholesale"
            ]
          },
          "is_available_for_sale": {
            "type": "boolean",
            "default": true
          },
          "is_industrializable": {
            "type": "boolean",
            "nullable": true
          },
          "allow_sale_without_stock": {
            "type": "boolean",
            "nullable": true,
            "description": "Permite venda sem estoque disponível (pedido sob encomenda)"
          },
          "auto_wholesale_pricing": {
            "type": "boolean",
            "description": "Opcional. Deriva automaticamente os preços das faixas de atacado a partir do percentual de desconto"
          },
          "dimensions": {
            "type": "object",
            "required": [
              "width",
              "height",
              "length",
              "weight"
            ],
            "properties": {
              "width": {
                "type": "number",
                "minimum": 0.001,
                "description": "Largura em cm"
              },
              "height": {
                "type": "number",
                "minimum": 0.001,
                "description": "Altura em cm"
              },
              "length": {
                "type": "number",
                "minimum": 0.001,
                "description": "Comprimento em cm"
              },
              "weight": {
                "type": "number",
                "minimum": 0.001,
                "description": "Peso em kg"
              }
            }
          }
        }
      },
      "ProductUpdateInput": {
        "type": "object",
        "description": "Corpo da atualização de produto. Diferente da criação, o `sku` não é aceito (é ignorado se enviado) e apenas `name` e `dimensions` são obrigatórios.",
        "required": [
          "name",
          "dimensions"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "base_unit": {
            "type": "string",
            "description": "Opcional. Mantém o valor atual quando omitido",
            "enum": [
              "un",
              "kg",
              "pc",
              "cx",
              "pct",
              "lt",
              "mt",
              "m2",
              "m3"
            ]
          },
          "price_type": {
            "type": "string",
            "description": "Opcional. Veja as regras de troca na descrição do endpoint",
            "enum": [
              "default",
              "wholesale"
            ]
          },
          "is_available_for_sale": {
            "type": "boolean",
            "description": "Opcional"
          },
          "is_industrializable": {
            "type": "boolean",
            "description": "Opcional"
          },
          "allow_sale_without_stock": {
            "type": "boolean",
            "description": "Opcional. Permite venda sem estoque disponível (pedido sob encomenda)"
          },
          "auto_wholesale_pricing": {
            "type": "boolean",
            "description": "Opcional. Deriva automaticamente os preços das faixas de atacado a partir do percentual de desconto"
          },
          "dimensions": {
            "type": "object",
            "required": [
              "width",
              "height",
              "length",
              "weight"
            ],
            "properties": {
              "width": {
                "type": "number",
                "minimum": 0.001,
                "description": "Largura em cm"
              },
              "height": {
                "type": "number",
                "minimum": 0.001,
                "description": "Altura em cm"
              },
              "length": {
                "type": "number",
                "minimum": 0.001,
                "description": "Comprimento em cm"
              },
              "weight": {
                "type": "number",
                "minimum": 0.001,
                "description": "Peso em kg"
              }
            }
          }
        }
      },
      "Price": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number",
            "description": "Valor unitário da faixa"
          },
          "min_quantity": {
            "type": "integer",
            "description": "Quantidade mínima para a faixa valer"
          },
          "discount_percent": {
            "type": "number",
            "nullable": true,
            "description": "Percentual de desconto da faixa em relação ao preço-base (usado no atacado automático)"
          },
          "package_weight": {
            "type": "number",
            "nullable": true,
            "description": "Peso da embalagem da faixa em kg"
          },
          "package_height": {
            "type": "number",
            "nullable": true,
            "description": "Altura da embalagem da faixa em cm"
          },
          "package_width": {
            "type": "number",
            "nullable": true,
            "description": "Largura da embalagem da faixa em cm"
          },
          "package_length": {
            "type": "number",
            "nullable": true,
            "description": "Comprimento da embalagem da faixa em cm"
          }
        }
      },
      "Stock": {
        "type": "object",
        "properties": {
          "location_stock": {
            "type": "object",
            "properties": {
              "location_id": {
                "type": "string",
                "description": "ID do local de estoque"
              },
              "store_id": {
                "type": "string",
                "description": "ID da loja"
              },
              "name": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "available",
                  "unavailable"
                ]
              },
              "location_type": {
                "type": "string",
                "enum": [
                  "seller_location",
                  "fulfillment"
                ]
              },
              "allows_pickup": {
                "type": "boolean",
                "description": "Local permite retirada"
              },
              "allows_production": {
                "type": "boolean",
                "description": "Local permite produção sob demanda"
              }
            }
          },
          "quantity": {
            "type": "number"
          },
          "reserved_quantity": {
            "type": "number"
          },
          "available_quantity": {
            "type": "number"
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "properties": {
          "search_query": {
            "type": "string"
          },
          "filters": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "pagination": {
            "type": "object",
            "properties": {
              "page": {
                "type": "integer"
              },
              "per_page": {
                "type": "integer"
              },
              "last_page": {
                "type": "integer"
              },
              "has_prev_page": {
                "type": "boolean"
              },
              "has_next_page": {
                "type": "boolean"
              },
              "records": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "integer"
                  },
                  "to": {
                    "type": "integer"
                  },
                  "records": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      },
      "PriceInput": {
        "type": "object",
        "properties": {
          "price": {
            "type": "number",
            "nullable": true,
            "description": "Valor monetário da faixa. Obrigatório na precificação manual (se omitido vira 0). Em produtos `wholesale` com `auto_wholesale_pricing` ligado é ignorado nas faixas `min_quantity >= 2` — o preço é calculado a partir do preço base e do `discount_percent`."
          },
          "min_quantity": {
            "type": "integer",
            "default": 1,
            "description": "Quantidade mínima para ativar este preço (Padrão: 1). Produtos `default` só aceitam `min_quantity = 1`."
          },
          "discount_percent": {
            "type": "number",
            "nullable": true,
            "minimum": 0,
            "description": "Percentual de desconto sobre o preço base unitário (0 a menos de 100). Usado nas faixas de atacado automáticas; os descontos precisam ser progressivos (faixa de quantidade maior exige desconto maior).",
            "exclusiveMaximum": 100
          },
          "package_weight": {
            "type": "number",
            "nullable": true,
            "minimum": 0.001,
            "description": "Peso da embalagem fechada, em kg. Faz parte das medidas obrigatórias das faixas de atacado (`min_quantity >= 2`)."
          },
          "package_height": {
            "type": "number",
            "nullable": true,
            "minimum": 0.01,
            "description": "Altura da embalagem fechada, em cm. Faz parte das medidas obrigatórias das faixas de atacado."
          },
          "package_width": {
            "type": "number",
            "nullable": true,
            "minimum": 0.01,
            "description": "Largura da embalagem fechada, em cm. Faz parte das medidas obrigatórias das faixas de atacado."
          },
          "package_length": {
            "type": "number",
            "nullable": true,
            "minimum": 0.01,
            "description": "Comprimento da embalagem fechada, em cm. Faz parte das medidas obrigatórias das faixas de atacado."
          }
        }
      },
      "ProductStockOverview": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "description": "Quantidade total de estoque somando todas as localizações.",
            "example": 150
          },
          "stocks": {
            "type": "array",
            "description": "Lista detalhada de estoque do produto em cada localização.",
            "items": {
              "$ref": "#/components/schemas/ProductStockDetail"
            }
          },
          "locations": {
            "type": "array",
            "description": "Lista de todas as localizações disponíveis para a loja.",
            "items": {
              "$ref": "#/components/schemas/LocationStock"
            }
          }
        }
      },
      "ProductStock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Identificador interno do registro de estoque.",
            "example": 321
          },
          "product_id": {
            "type": "string",
            "description": "ID do produto.",
            "example": "01H81AV32307PVBSV4RXF15EK9"
          },
          "location_id": {
            "type": "string",
            "description": "ID da localização de estoque.",
            "example": "01H81AV32307PVBSV4RXF15LOC"
          },
          "quantity": {
            "type": "integer",
            "description": "Quantidade atual em estoque.",
            "example": 50
          },
          "reserved_quantity": {
            "type": "integer",
            "description": "Quantidade reservada (não disponível para venda imediata).",
            "example": 0
          },
          "available_quantity": {
            "type": "integer",
            "description": "Quantidade disponível para venda (quantity - reserved_quantity).",
            "example": 50
          }
        }
      },
      "ProductStockDetail": {
        "type": "object",
        "description": "Registro de estoque do produto em uma localização, com o produto e o local aninhados.",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Identificador interno do registro de estoque.",
            "example": 321
          },
          "product_sku": {
            "type": "object",
            "description": "Dados do produto (id, name, sku, base_unit, dimensions, flags de venda, prices, totais de estoque, thumbnail e images)."
          },
          "location_stock": {
            "$ref": "#/components/schemas/LocationStock"
          },
          "quantity": {
            "type": "integer",
            "description": "Quantidade física nesta localização.",
            "example": 100
          },
          "reserved_quantity": {
            "type": "integer",
            "description": "Quantidade reservada em carrinhos/pedidos abertos.",
            "example": 5
          },
          "available_quantity": {
            "type": "integer",
            "description": "Quantidade disponível para venda (quantity - reserved_quantity).",
            "example": 95
          }
        }
      },
      "LocationStock": {
        "type": "object",
        "properties": {
          "location_id": {
            "type": "string",
            "description": "ID da localização.",
            "example": "01H81AV32307PVBSV4RXF15LOC"
          },
          "store_id": {
            "type": "integer",
            "description": "Identificador interno da loja dona do local.",
            "example": 42
          },
          "name": {
            "type": "string",
            "description": "Nome da localização.",
            "example": "Matriz - São Paulo"
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ],
            "description": "Status da localização.",
            "example": "available"
          },
          "location_type": {
            "type": "string",
            "enum": [
              "seller_location",
              "fulfillment"
            ],
            "description": "Tipo da localização.",
            "example": "seller_location"
          },
          "allows_pickup": {
            "type": "boolean",
            "description": "Indica se o local permite retirada em mãos.",
            "example": false
          },
          "allows_production": {
            "type": "boolean",
            "description": "Indica se o local permite produção sob demanda.",
            "example": false
          }
        }
      },
      "StockUpdateInput": {
        "type": "object",
        "required": [
          "location_id",
          "quantity"
        ],
        "properties": {
          "location_id": {
            "type": "string",
            "description": "ID da localização onde o estoque será alterado.",
            "example": "01H81AV32307PVBSV4RXF15LOC"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "description": "Quantidade a ser definida, incrementada ou decrementada.",
            "example": 10
          },
          "increment": {
            "type": "boolean",
            "description": "Se verdadeiro, soma a quantidade ao estoque atual.",
            "default": false,
            "example": false
          },
          "decrement": {
            "type": "boolean",
            "description": "Se verdadeiro, subtrai a quantidade do estoque atual.",
            "default": false,
            "example": false
          }
        }
      },
      "SuccessResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "message_code": {
            "type": "string",
            "example": "SUCCESS"
          },
          "data": {
            "type": "object"
          },
          "meta": {
            "type": "object",
            "description": "Presente apenas quando há metadados a retornar."
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "code": {
            "type": "integer",
            "example": 400
          },
          "message_code": {
            "type": "string",
            "example": "BAD_REQUEST"
          },
          "description": {
            "type": "string",
            "example": "Erro na requisição."
          },
          "data": {
            "type": "array",
            "items": {},
            "example": []
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "meta": {
            "type": "array",
            "items": {},
            "example": []
          }
        }
      },
      "LocationStockInput": {
        "type": "object",
        "required": [
          "name",
          "status",
          "location_type"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ],
            "default": "available"
          },
          "location_type": {
            "type": "string",
            "enum": [
              "seller_location"
            ],
            "default": "seller_location"
          },
          "allows_pickup": {
            "type": "boolean",
            "default": false,
            "description": "Permite retirada no local"
          },
          "allows_production": {
            "type": "boolean",
            "default": false,
            "description": "Permite producao sob demanda"
          },
          "company_branch_uid": {
            "type": "string",
            "nullable": true,
            "description": "ID da filial a vincular ao local. Precisa ser uma filial ativa da empresa; omita para deixar o local respondendo pela matriz."
          }
        }
      },
      "Address": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID do endereco"
          },
          "uid": {
            "type": "string",
            "description": "Mesmo valor de id (mantido por compatibilidade)"
          },
          "street": {
            "type": "string"
          },
          "number": {
            "type": "string"
          },
          "complement": {
            "type": "string",
            "nullable": true
          },
          "reference": {
            "type": "string",
            "nullable": true,
            "description": "Ponto de referencia"
          },
          "can_deliver_to_neighbor": {
            "type": "boolean",
            "description": "Se o entregador pode deixar com um vizinho"
          },
          "delivery_instructions": {
            "type": "string",
            "nullable": true,
            "description": "Instrucoes de entrega"
          },
          "district": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "zip_code": {
            "type": "string",
            "description": "CEP formatado (00000-000)"
          },
          "latitude": {
            "type": "number"
          },
          "longitude": {
            "type": "number"
          },
          "place_id": {
            "type": "string",
            "nullable": true,
            "description": "Identificador do lugar no provedor de geocodificacao"
          },
          "address_components": {
            "nullable": true,
            "description": "Componentes estruturados do endereco retornados pelo provedor de geocodificacao"
          },
          "full_address": {
            "type": "string",
            "description": "Endereco completo em uma unica linha"
          },
          "is_complete": {
            "type": "boolean",
            "description": "Indica se o endereco ja possui coordenadas resolvidas"
          },
          "type": {
            "type": "string",
            "enum": [
              "logistics",
              "local_real",
              "local_devolucao"
            ],
            "description": "O tipo do endereco. Pelo menos um endereco do tipo 'logistics' e obrigatorio para o local de estoque operar."
          },
          "type_label": {
            "type": "string",
            "nullable": true,
            "description": "Rotulo legivel do tipo"
          }
        }
      },
      "AddressInput": {
        "type": "object",
        "required": [
          "zip_code",
          "street",
          "number",
          "district",
          "city",
          "state",
          "type"
        ],
        "properties": {
          "zip_code": {
            "type": "string",
            "description": "CEP (apenas numeros ou com traco, formato 00000-000 ou 00000000)"
          },
          "street": {
            "type": "string",
            "minLength": 3
          },
          "number": {
            "type": "string",
            "maxLength": 20
          },
          "complement": {
            "type": "string",
            "nullable": true,
            "maxLength": 255
          },
          "reference": {
            "type": "string",
            "nullable": true,
            "maxLength": 60,
            "description": "Ponto de referencia"
          },
          "can_deliver_to_neighbor": {
            "type": "boolean",
            "nullable": true,
            "description": "Se o entregador pode deixar com um vizinho"
          },
          "delivery_instructions": {
            "type": "string",
            "nullable": true,
            "maxLength": 150,
            "description": "Instrucoes de entrega"
          },
          "district": {
            "type": "string",
            "minLength": 2
          },
          "city": {
            "type": "string",
            "minLength": 2
          },
          "state": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2
          },
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "default": "BR"
          },
          "latitude": {
            "type": "number",
            "nullable": true,
            "description": "Se omitido, a plataforma tenta resolver as coordenadas pelo CEP ou por geocodificacao"
          },
          "longitude": {
            "type": "number",
            "nullable": true
          },
          "place_id": {
            "type": "string",
            "nullable": true
          },
          "address_components": {
            "type": "array",
            "nullable": true,
            "items": {}
          },
          "type": {
            "type": "string",
            "enum": [
              "logistics",
              "local_real",
              "local_devolucao"
            ],
            "description": "Tipo de endereco para este local. Valores validos: logistics, local_real, local_devolucao"
          }
        }
      },
      "AddressUpdateInput": {
        "type": "object",
        "description": "Mesmos campos do cadastro, porem todos opcionais — envie apenas o que quer alterar.",
        "properties": {
          "zip_code": {
            "type": "string",
            "description": "CEP (apenas numeros ou com traco, formato 00000-000 ou 00000000)"
          },
          "street": {
            "type": "string",
            "minLength": 3
          },
          "number": {
            "type": "string",
            "maxLength": 20
          },
          "complement": {
            "type": "string",
            "nullable": true,
            "maxLength": 255
          },
          "reference": {
            "type": "string",
            "nullable": true,
            "maxLength": 60
          },
          "can_deliver_to_neighbor": {
            "type": "boolean",
            "nullable": true
          },
          "delivery_instructions": {
            "type": "string",
            "nullable": true,
            "maxLength": 150
          },
          "district": {
            "type": "string",
            "minLength": 2
          },
          "city": {
            "type": "string",
            "minLength": 2
          },
          "state": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2
          },
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2
          },
          "latitude": {
            "type": "number",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "nullable": true
          },
          "place_id": {
            "type": "string",
            "nullable": true
          },
          "address_components": {
            "type": "array",
            "nullable": true,
            "items": {}
          },
          "type": {
            "type": "string",
            "nullable": true,
            "enum": [
              "logistics",
              "local_real",
              "local_devolucao"
            ],
            "description": "Novo tipo do vinculo do endereco com o local"
          }
        }
      },
      "CategoriesResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message_code": {
            "type": "string"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "Category": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID da categoria"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "departament": {
            "$ref": "#/components/schemas/Department"
          },
          "parent": {
            "$ref": "#/components/schemas/ParentCategory"
          },
          "is_visible": {
            "type": "boolean"
          },
          "priority": {
            "type": "integer"
          },
          "domain": {
            "type": "string"
          },
          "level": {
            "type": "integer"
          },
          "hierarchy": {
            "type": "array",
            "description": "Breadcrumb completo da categoria (cada nível com id e nome)",
            "items": {
              "$ref": "#/components/schemas/HierarchyLevel"
            }
          },
          "settings": {
            "type": "array",
            "items": {}
          },
          "catalog_overrides": {
            "type": [
              "object",
              "null"
            ]
          },
          "total_children": {
            "type": "integer"
          },
          "children": {
            "type": "array",
            "description": "Subcategorias (recursivo). Na busca, só voltam folhas — portanto vazio.",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          }
        },
        "required": [
          "id",
          "name",
          "departament",
          "parent"
        ]
      },
      "HierarchyLevel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "Department": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID do departamento"
          },
          "name": {
            "type": "string"
          },
          "icon_svg": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "ParentCategory": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "hierarchy": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HierarchyLevel"
            }
          }
        },
        "required": [
          "id",
          "parent_id",
          "name"
        ]
      },
      "CategoryAttributesResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message_code": {
            "type": "string"
          },
          "data": {
            "type": "array",
            "description": "Com `matrix=true`, lista de grupos (`AttributeGroup`). Sem `matrix`, lista plana de atributos (`AttributeItem`).",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/AttributeGroup"
                },
                {
                  "$ref": "#/components/schemas/AttributeItem"
                }
              ]
            }
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "AttributeGroup": {
        "type": "object",
        "properties": {
          "key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Chave da matriz (ex: identification, appearance, technical). `null` para atributos sem matriz."
          },
          "label": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttributeItem"
            }
          }
        },
        "required": [
          "key",
          "label",
          "items"
        ]
      },
      "AttributeItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID do vínculo categoria-atributo"
          },
          "attribute_id": {
            "type": "integer",
            "description": "ID do atributo"
          },
          "category_id": {
            "type": "integer",
            "description": "ID da categoria"
          },
          "is_required": {
            "type": "boolean",
            "description": "Indica se o atributo e obrigatorio para a categoria"
          },
          "is_feature": {
            "type": "boolean",
            "description": "Indica se e uma caracteristica do produto"
          },
          "is_variant": {
            "type": "boolean",
            "description": "Indica se e um atributo de variacao"
          },
          "is_combinable": {
            "type": "boolean",
            "description": "Indica se pode ser usado em combinacoes para variacoes"
          },
          "is_filter": {
            "type": "boolean",
            "description": "Indica se o atributo aparece como filtro na vitrine"
          },
          "attribute_data": {
            "$ref": "#/components/schemas/AttributeData"
          }
        },
        "required": [
          "id",
          "attribute_id",
          "category_id",
          "is_required",
          "is_feature",
          "is_variant",
          "is_combinable",
          "is_filter"
        ]
      },
      "AttributeData": {
        "type": "object",
        "description": "Definição do atributo. O bloco `value_definition` é autodescritivo: traz os campos esperados (`fields`), as opções pré-cadastradas (`options`, quando houver) e as unidades disponíveis.",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID do atributo"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "default",
              "default_unit",
              "default_list",
              "dimension_3d",
              "dimension_2d",
              "color",
              "image",
              "brand",
              "packaging"
            ],
            "description": "Tipo estrutural do atributo. `default_unit` exige `unit`; `dimension_2d/3d` exigem width/height(/depth)+unit; `color` aceita opção pré-cadastrada ou cor customizada (value + hex)."
          },
          "value_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "text",
              "float",
              "number",
              "date",
              "boolean",
              "select",
              "radio",
              "checkbox",
              null
            ],
            "description": "Tipo do valor para atributos default. Tipos especializados (color, image, brand, packaging) ignoram este campo."
          },
          "is_feature": {
            "type": "boolean"
          },
          "is_variant": {
            "type": "boolean"
          },
          "is_calculable": {
            "type": "boolean",
            "description": "Atributo usado em cálculos (ex: Quantidade, que precisa casar com a unidade base do SKU)"
          },
          "domain": {
            "type": [
              "string",
              "null"
            ]
          },
          "ui": {
            "type": "object",
            "properties": {
              "public_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "matrix": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Matriz de organização (identification, appearance, technical, dimensions, ...)"
              },
              "select_type": {
                "type": "string",
                "enum": [
                  "select",
                  "radio",
                  "checkbox",
                  "text"
                ],
                "description": "Como o valor é escolhido. `text` = digitação livre; os demais exigem opção pré-cadastrada (exceto atributos de cor, que aceitam cor customizada)."
              }
            }
          },
          "value_definition": {
            "type": "object",
            "properties": {
              "fields": {
                "type": "object",
                "description": "Schema dos campos esperados no valor (montagem dinâmica de formulário)"
              },
              "options": {
                "type": "array",
                "description": "Opções pré-cadastradas (presente apenas quando o atributo tem opções)",
                "items": {
                  "$ref": "#/components/schemas/AttributeOption"
                }
              },
              "default_unit": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "available_units": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "AttributeOption": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID da opção (use em `value_id` ao criar o anúncio)"
          },
          "attribute_id": {
            "type": "integer"
          },
          "value": {
            "type": "string"
          },
          "component": {
            "type": "object",
            "description": "Payload visual da opção, varia por tipo de atributo. Para cor: `{ value, main_color, hex, brightness }`.",
            "additionalProperties": true
          },
          "position": {
            "type": "integer"
          },
          "is_default": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "attribute_id",
          "value",
          "component",
          "position",
          "is_default"
        ]
      },
      "AttributeCombinationsResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message_code": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "combinations": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AttributeCombination"
                }
              },
              "primary_attribute": {
                "$ref": "#/components/schemas/PrimaryAttributeInfo"
              }
            },
            "required": [
              "combinations",
              "primary_attribute"
            ]
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "AttributeCombination": {
        "type": "object",
        "properties": {
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CombinationAttribute"
            }
          },
          "attributes_details": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          }
        },
        "required": [
          "attributes",
          "attributes_details",
          "description"
        ]
      },
      "CombinationAttribute": {
        "type": "object",
        "properties": {
          "attribute_id": {
            "type": "integer",
            "description": "ID do atributo"
          },
          "attribute_name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "unit": {
            "type": "string",
            "description": "Unidade de medida (presente apenas quando aplicável)"
          },
          "hex": {
            "type": "string",
            "description": "Cor em hexadecimal (presente apenas para atributos de cor)"
          },
          "main_color": {
            "type": "string",
            "description": "Cor principal (presente apenas para atributos de cor)"
          },
          "brightness": {
            "type": "string",
            "enum": [
              "light",
              "dark"
            ],
            "description": "Luminosidade calculada da cor (presente apenas para atributos de cor)"
          },
          "width": {
            "type": [
              "string",
              "number"
            ],
            "description": "Largura (presente apenas para atributos de dimensão)"
          },
          "height": {
            "type": [
              "string",
              "number"
            ],
            "description": "Altura (presente apenas para atributos de dimensão)"
          }
        },
        "required": [
          "attribute_id",
          "attribute_name",
          "value"
        ]
      },
      "PrimaryAttributeInfo": {
        "type": "object",
        "description": "Atributo principal das combinações — facilita organizar fotos por variação no front.",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID do atributo principal"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "has_options": {
            "type": "boolean"
          },
          "default_unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "values": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "hex": {
                  "type": "string"
                },
                "main_color": {
                  "type": "string"
                },
                "brightness": {
                  "type": "string"
                }
              },
              "required": [
                "value",
                "label"
              ]
            }
          }
        },
        "required": [
          "id",
          "name",
          "has_options",
          "default_unit",
          "values"
        ]
      },
      "CreateAdvertisementRequest": {
        "type": "object",
        "description": "É obrigatório informar `seller_sku` (anúncio sem variações) ou `variations` — um dos dois precisa estar presente. Os SKUs devem existir previamente na loja.",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 100,
            "description": "Titulo do anuncio"
          },
          "category_id": {
            "type": "integer",
            "description": "ID da categoria selecionada (precisa ser categoria folha existente)"
          },
          "gtin": {
            "$ref": "#/components/schemas/GTIN"
          },
          "seller_sku": {
            "type": [
              "string",
              "null"
            ],
            "description": "SKU do produto para anúncio sem variações. Obrigatório quando `variations` não for enviado. O SKU precisa existir na loja."
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdvertisementAttribute"
            },
            "description": "Atributos de caracteristicas do produto. Obrigatório quando a categoria possui atributos com `is_required=true`."
          },
          "variations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdvertisementVariation"
            },
            "description": "Variacoes do produto. Obrigatório quando `seller_sku` não for enviado."
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImageReference"
            },
            "description": "Imagens do anuncio principal. Opcional na criação, mas o checklist exige pelo menos uma imagem para publicar."
          },
          "description": {
            "$ref": "#/components/schemas/PublicationDescription",
            "description": "Descrição longa do anúncio. Opcional. Pode ser informada na criação ou depois via PUT /api/items/{id}/description."
          },
          "technical_sheets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TechnicalSheetInput"
            },
            "description": "Fichas técnicas do anúncio. Opcionais. Também podem ser criadas ou editadas depois via /api/items/{id}/technical-sheets."
          }
        },
        "required": [
          "title",
          "category_id"
        ]
      },
      "PublicationDescription": {
        "type": "object",
        "description": "Aceita um objeto `{ layout, raw_content }` ou uma string simples (legado, equivale a `layout=markdown`).",
        "properties": {
          "layout": {
            "type": "string",
            "enum": [
              "text",
              "html",
              "markdown"
            ],
            "description": "Formato do `raw_content`. Default: `markdown`."
          },
          "raw_content": {
            "type": "string",
            "description": "Conteúdo bruto da descrição no formato indicado por `layout`."
          }
        }
      },
      "TechnicalSheetInput": {
        "type": "object",
        "required": [
          "type",
          "title"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "technical_specification",
              "characteristics",
              "materials",
              "installation",
              "maintenance",
              "safety",
              "environmental",
              "custom"
            ],
            "description": "Tipo da ficha técnica."
          },
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Título exibido para a seção da ficha."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "item_key",
                "item_value"
              ],
              "properties": {
                "item_key": {
                  "type": "string",
                  "maxLength": 255
                },
                "item_value": {
                  "type": "string",
                  "maxLength": 1000
                },
                "display_order": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        }
      },
      "GTIN": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "integer",
              "string"
            ],
            "enum": [
              8,
              12,
              13,
              14,
              "8",
              "12",
              "13",
              "14"
            ],
            "description": "Tipo de GTIN: 8, 12, 13 ou 14 dígitos (13 para EAN-13). Nas respostas, vem como string."
          },
          "value": {
            "type": "string",
            "description": "Numero do codigo de barras"
          }
        }
      },
      "AdvertisementAttribute": {
        "type": "object",
        "description": "Valor de um atributo do anúncio. Campos extras dependem do tipo do atributo: cor customizada usa `hex`/`main_color`/`brightness`; dimensões usam `width`/`height`/`depth` + `unit`; listas usam `items`.",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID do atributo"
          },
          "value_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "ID da opção selecionada (para atributos com opcoes pré-cadastradas)"
          },
          "option_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Alias aceito para `value_id`"
          },
          "value": {
            "type": [
              "string",
              "integer",
              "null"
            ],
            "description": "Valor do atributo"
          },
          "unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Unidade de medida (obrigatória em atributos do tipo default_unit; precisa estar em available_units)"
          },
          "hex": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cor customizada em hexadecimal (#RGB ou #RRGGBB). Para atributos de cor, `value` (nome da cor) + `hex` válido dispensam opção pré-cadastrada."
          },
          "main_color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cor principal da cor customizada (ex: Vermelho)"
          },
          "brightness": {
            "type": [
              "string",
              "null"
            ],
            "description": "Luminosidade da cor (light/dark). Se omitido, é calculada a partir do hex."
          },
          "width": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Largura (atributos dimension_2d/dimension_3d)"
          },
          "height": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Altura (atributos dimension_2d/dimension_3d)"
          },
          "depth": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Profundidade (atributos dimension_3d)"
          },
          "fields": {
            "type": [
              "object",
              "null"
            ],
            "description": "Forma alternativa de enviar dimensões: `{ width, height, depth, unit }`",
            "properties": {
              "width": {},
              "height": {},
              "depth": {},
              "unit": {
                "type": "string"
              }
            }
          },
          "items": {
            "type": [
              "array",
              "null"
            ],
            "description": "Itens do atributo (obrigatório em atributos do tipo default_list)"
          }
        }
      },
      "AdvertisementVariation": {
        "type": "object",
        "properties": {
          "seller_sku": {
            "type": "string",
            "description": "SKU do produto para esta variacao (precisa existir na loja)"
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VariationAttribute"
            },
            "description": "Atributos que definem esta variacao"
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImageReference"
            },
            "description": "Imagens especificas desta variacao"
          }
        },
        "required": [
          "seller_sku"
        ]
      },
      "VariationAttribute": {
        "type": "object",
        "description": "Informe `attribute_id` e `value` (ou `value_id` para opção pré-cadastrada). Atributos de cor aceitam cor customizada com `value` + `hex` (+ `main_color`/`brightness` opcionais), sem opção pré-cadastrada.",
        "properties": {
          "attribute_id": {
            "type": "integer",
            "description": "ID do atributo"
          },
          "attribute_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "value": {
            "type": [
              "string",
              "integer",
              "null"
            ]
          },
          "unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "value_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "ID da opção pré-cadastrada"
          },
          "option_id": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Alias aceito para `value_id`"
          },
          "hex": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cor customizada em hexadecimal (#RGB ou #RRGGBB)"
          },
          "main_color": {
            "type": [
              "string",
              "null"
            ]
          },
          "brightness": {
            "type": [
              "string",
              "null"
            ]
          },
          "width": {
            "type": [
              "string",
              "number",
              "null"
            ]
          },
          "height": {
            "type": [
              "string",
              "number",
              "null"
            ]
          },
          "depth": {
            "type": [
              "string",
              "number",
              "null"
            ]
          },
          "fields": {
            "type": [
              "object",
              "null"
            ],
            "description": "Forma alternativa de enviar dimensões: `{ width, height, depth, unit }`"
          }
        }
      },
      "ImageReference": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID da imagem (UUID retornado por POST /api/media/upload)"
          }
        },
        "required": [
          "id"
        ]
      },
      "SimulatedAdvertisementResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message_code": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/CreatedAdvertisementData"
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "CreatedAdvertisementResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message_code": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/CreatedAdvertisementData"
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "CreatedAdvertisementData": {
        "type": "object",
        "description": "Objeto do anúncio, retornado por create, publish e simulate.",
        "properties": {
          "item_id": {
            "type": "string",
            "description": "ID do anúncio: prefixo da plataforma + 13 dígitos (ex: SAM-0000000000007)"
          },
          "title": {
            "type": "string"
          },
          "short_description": {
            "type": [
              "string",
              "null"
            ]
          },
          "slug": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TypeValue"
              }
            ],
            "description": "Tipo do anúncio: `default` (Padrão) ou `catalog` (Catálogo)"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StatusValue"
              }
            ],
            "description": "Status do anúncio: `draft`, `pending_review`, `active`, `paused` ou `inactive`"
          },
          "seller_sku": {
            "type": [
              "string",
              "null"
            ],
            "description": "SKU vinculado diretamente ao anúncio (quando não há variações)"
          },
          "price_range": {
            "type": [
              "array",
              "null"
            ],
            "description": "Faixa de preço calculada a partir das ofertas (pode ser null em rascunhos)"
          },
          "score": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Score de qualidade do anúncio"
          },
          "campaigns": {
            "type": "array"
          },
          "pricing_context": {
            "type": "array",
            "description": "Contexto de precificação por faixa de quantidade (descontos, campanhas)"
          },
          "frontend_sync_status": {
            "type": "string",
            "description": "Status de sincronização com a vitrine (ex: pending)"
          },
          "last_frontend_sync_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "Formato Y-m-d H:i:s"
          },
          "submitted_for_review_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "Quando o anúncio foi enviado para revisão. Formato Y-m-d H:i:s"
          },
          "reviewed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "Quando a plataforma revisou o anúncio. Formato Y-m-d H:i:s"
          },
          "rejection_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Motivo da rejeição quando o anúncio volta para rascunho"
          },
          "gtin": {
            "allOf": [
              {
                "$ref": "#/components/schemas/GTIN"
              }
            ],
            "description": "Presente apenas quando informado"
          },
          "store": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Store"
              }
            ],
            "description": "Loja dona do anúncio (presente quando carregada)"
          },
          "department": {
            "$ref": "#/components/schemas/Department"
          },
          "category": {
            "$ref": "#/components/schemas/CategoryRef"
          },
          "thumbnail": {
            "type": [
              "object",
              "null"
            ],
            "description": "Miniatura no tamanho `sm`: `{ id, resource }`"
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Image"
            }
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicationAttributeOut"
            }
          },
          "variations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicationVariationOut"
            }
          }
        },
        "required": [
          "item_id",
          "title",
          "type",
          "status",
          "department",
          "category",
          "images",
          "attributes",
          "variations"
        ]
      },
      "Image": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID da imagem (UUID)"
          },
          "resources": {
            "type": "array",
            "description": "Variações de tamanho da imagem (`{ name, url, ... }`)",
            "items": {
              "type": "object"
            }
          }
        },
        "required": [
          "id",
          "resources"
        ]
      },
      "PublicationAttributeOut": {
        "type": "object",
        "properties": {
          "attribute_id": {
            "type": "integer",
            "description": "ID do atributo"
          },
          "attribute_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "attribute_value": {
            "type": [
              "string",
              "integer",
              "null"
            ]
          },
          "value_unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "value_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "component": {
            "type": [
              "object",
              "null"
            ],
            "description": "Payload visual do valor. Para cor: `{ value, main_color, hex, brightness }`."
          }
        },
        "required": [
          "attribute_id",
          "attribute_name",
          "attribute_value",
          "value_unit",
          "value_id",
          "component"
        ]
      },
      "PublicationVariationOut": {
        "type": "object",
        "description": "Variação do anúncio. Em anúncios padrão o identificador vem como `offer_id`; em anúncios de catálogo, como `option_id`.",
        "properties": {
          "offer_id": {
            "type": "string",
            "description": "ID da variação (26 caracteres). Presente em anúncios padrão."
          },
          "option_id": {
            "type": "string",
            "description": "ID da opção de catálogo (26 caracteres). Presente em anúncios de catálogo."
          },
          "description": {
            "type": "string",
            "description": "Descrição legível da combinação (ex: Voltagem: 110 V, Cor: Azul)"
          },
          "attributes": {
            "type": "array",
            "description": "Atributos da variação (`{ attribute_id, attribute_name, value, unit?, value_id?, hex?, main_color?, brightness? }`)",
            "items": {
              "type": "object"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "pending",
              "hidden"
            ],
            "description": "Status da variação"
          },
          "type": {
            "type": "string",
            "enum": [
              "offer",
              "option"
            ]
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Image"
            }
          },
          "seller_sku": {
            "type": [
              "string",
              "null"
            ],
            "description": "Presente quando `type=offer`"
          },
          "offer": {
            "$ref": "#/components/schemas/OfferData"
          }
        },
        "required": [
          "description",
          "attributes",
          "status",
          "type",
          "images",
          "offer"
        ]
      },
      "OfferData": {
        "type": "object",
        "properties": {
          "price_type": {
            "type": "string",
            "description": "Tipo de precificação (ex: default, wholesale)"
          },
          "price_from": {
            "type": "number",
            "description": "Preço \"De\" quando há desconto"
          },
          "prices": {
            "type": "array",
            "description": "Faixas de preço (atacado)",
            "items": {
              "type": "object"
            }
          },
          "quantity": {
            "type": "integer"
          },
          "price": {
            "type": "number",
            "description": "Preço \"Por\""
          },
          "original_price": {
            "type": [
              "number",
              "null"
            ]
          },
          "has_discount": {
            "type": "boolean"
          },
          "discount_percent": {
            "type": "integer"
          },
          "wholesale_tiers": {
            "type": "array",
            "description": "Presente apenas quando há faixas de atacado",
            "items": {
              "type": "object"
            }
          },
          "buybox": {
            "type": "object",
            "description": "Dados da buybox (presente apenas em anúncios de catálogo)"
          }
        },
        "required": [
          "price_type",
          "price_from",
          "prices",
          "quantity",
          "price",
          "original_price",
          "has_discount",
          "discount_percent"
        ]
      },
      "TypeValue": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "enum": [
              "default",
              "catalog"
            ]
          },
          "label": {
            "type": "string"
          }
        },
        "required": [
          "value",
          "label"
        ]
      },
      "StatusValue": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "enum": [
              "draft",
              "pending_review",
              "active",
              "paused",
              "inactive"
            ]
          },
          "label": {
            "type": "string"
          }
        },
        "required": [
          "value",
          "label"
        ]
      },
      "Store": {
        "type": "object",
        "properties": {
          "store_id": {
            "type": "string",
            "description": "ID da loja (26 caracteres)"
          },
          "store_name": {
            "type": "string"
          },
          "store_code": {
            "type": "string"
          },
          "store_status": {
            "type": "string"
          },
          "store_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "store_type": {
            "type": "string"
          },
          "commission_table_id": {
            "type": [
              "integer",
              "string",
              "null"
            ],
            "description": "ID da tabela de comissão"
          },
          "max_locations": {
            "type": [
              "integer",
              "null"
            ]
          },
          "features": {
            "type": "array"
          },
          "company": {
            "type": "object",
            "description": "Dados cadastrais da empresa"
          },
          "shares_products": {
            "type": "boolean"
          },
          "shares_stock_locations": {
            "type": "boolean"
          },
          "shares_logistics": {
            "type": "boolean"
          },
          "is_primary": {
            "type": "boolean"
          },
          "primary_store": {
            "type": [
              "object",
              "null"
            ]
          }
        },
        "required": [
          "store_id",
          "store_name",
          "store_code"
        ]
      },
      "CategoryRef": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID da categoria"
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "hierarchy": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HierarchyLevel"
            }
          }
        },
        "required": [
          "id",
          "parent_id",
          "name"
        ]
      },
      "AttachSKURequest": {
        "type": "object",
        "properties": {
          "seller_sku": {
            "type": "string",
            "maxLength": 64,
            "description": "SKU do produto a vincular. Precisa pertencer (ou estar associado) à loja autenticada."
          },
          "status": {
            "type": "string",
            "description": "Status inicial da oferta. Default: `active`.",
            "enum": [
              "active",
              "paused",
              "inactive"
            ]
          }
        },
        "required": [
          "seller_sku"
        ]
      },
      "AttachedSKUResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message_code": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/AttachedSKUData"
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "AttachedSKUData": {
        "type": "object",
        "properties": {
          "offer_id": {
            "type": "string",
            "description": "ID da oferta criada (26 caracteres). Use em PUT/DELETE /api/items/catalog/offers/{offerId}."
          },
          "seller_sku": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "paused",
              "inactive",
              "pending"
            ]
          },
          "is_buybox_winner": {
            "type": "boolean",
            "description": "Recalculado em background após o vínculo — costuma vir `false` na resposta imediata"
          },
          "last_buybox_calculation": {
            "type": [
              "string",
              "null"
            ]
          },
          "price_data": {
            "$ref": "#/components/schemas/PriceData"
          },
          "stock_data": {
            "$ref": "#/components/schemas/StockData"
          },
          "publication": {
            "type": [
              "object",
              "null"
            ],
            "description": "Resumo do anúncio de catálogo",
            "properties": {
              "item_id": {
                "type": "string",
                "description": "ID do anúncio"
              },
              "title": {
                "type": "string"
              },
              "status": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "thumbnail_id": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "ID da imagem de capa (UUID)"
              }
            }
          },
          "option": {
            "$ref": "#/components/schemas/OptionData"
          }
        },
        "required": [
          "offer_id",
          "seller_sku",
          "status",
          "is_buybox_winner",
          "last_buybox_calculation",
          "price_data",
          "stock_data",
          "publication",
          "option"
        ]
      },
      "PriceData": {
        "type": "object",
        "description": "Snapshot de preço da oferta. Preço único: `{ price }`. Atacado: `{ type: \"wholesale\", tiers: [...] }`.",
        "properties": {
          "price": {
            "type": "number",
            "description": "Preço único (presente quando não há faixas de atacado)"
          },
          "type": {
            "type": "string",
            "enum": [
              "wholesale"
            ],
            "description": "Presente apenas quando há faixas de atacado"
          },
          "tiers": {
            "type": "array",
            "description": "Faixas de preço por quantidade (presente apenas no atacado)",
            "items": {
              "$ref": "#/components/schemas/PriceTier"
            }
          }
        }
      },
      "PriceTier": {
        "type": "object",
        "properties": {
          "min_quantity": {
            "type": "integer"
          },
          "price": {
            "type": "number"
          }
        },
        "required": [
          "min_quantity",
          "price"
        ]
      },
      "StockData": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "ID interno do registro de estoque"
          },
          "product_id": {
            "type": "string",
            "description": "ID do SKU do produto (26 caracteres)"
          },
          "location_id": {
            "type": "string",
            "description": "ID do local de estoque (26 caracteres)"
          },
          "quantity": {
            "type": "integer"
          },
          "reserved_quantity": {
            "type": "integer"
          },
          "available_quantity": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "product_id",
          "location_id",
          "quantity",
          "reserved_quantity",
          "available_quantity"
        ]
      },
      "OptionData": {
        "type": "object",
        "properties": {
          "uid": {
            "type": "string",
            "description": "ID da opção de catálogo (26 caracteres)"
          },
          "description": {
            "type": "string"
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OptionAttribute"
            }
          },
          "type": {
            "type": "string",
            "enum": [
              "option",
              "offer"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "pending",
              "hidden"
            ]
          },
          "images": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "required": [
          "uid",
          "description",
          "attributes",
          "type",
          "status",
          "images"
        ]
      },
      "OptionAttribute": {
        "type": "object",
        "properties": {
          "attribute_id": {
            "type": "integer",
            "description": "ID do atributo"
          },
          "attribute_name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "value_id": {
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "attribute_id",
          "attribute_name",
          "value"
        ]
      },
      "TechnicalSheet": {
        "type": "object",
        "description": "Ficha técnica de um anúncio: lista ordenada de pares chave/valor agrupada por tipo (especificações, materiais, segurança etc.).",
        "properties": {
          "sheet_id": {
            "type": "string",
            "description": "ID da ficha técnica (26 caracteres)"
          },
          "publication_id": {
            "type": "string",
            "description": "`item_id` do anúncio dono da ficha"
          },
          "type": {
            "type": "object",
            "description": "Tipo da ficha técnica",
            "properties": {
              "value": {
                "type": "string",
                "enum": [
                  "technical_specification",
                  "characteristics",
                  "materials",
                  "installation",
                  "maintenance",
                  "safety",
                  "environmental",
                  "custom"
                ]
              },
              "label": {
                "type": "string",
                "description": "Rótulo amigável do tipo (ex.: Ficha Técnica, Materiais)"
              },
              "description": {
                "type": "string"
              }
            },
            "required": [
              "value",
              "label",
              "description"
            ]
          },
          "title": {
            "type": "string",
            "maxLength": 255
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TechnicalSheetItem"
            }
          }
        },
        "required": [
          "sheet_id",
          "publication_id",
          "type",
          "title",
          "items"
        ]
      },
      "TechnicalSheetItem": {
        "type": "object",
        "description": "Linha da ficha técnica (par chave/valor).",
        "properties": {
          "item_id": {
            "type": "string",
            "description": "ID do item da ficha (26 caracteres)"
          },
          "item_key": {
            "type": "string",
            "maxLength": 255,
            "description": "Nome da característica (ex.: Potência)"
          },
          "item_value": {
            "type": "string",
            "maxLength": 1000,
            "description": "Valor da característica (ex.: 650 W)"
          },
          "display_order": {
            "type": "integer",
            "minimum": 0,
            "description": "Posição de exibição (0 = primeiro)"
          }
        },
        "required": [
          "item_id",
          "item_key",
          "item_value",
          "display_order"
        ]
      },
      "MediaCreatedResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "message_code": {
            "type": "string",
            "example": "RESOURCE_CREATED"
          },
          "data": {
            "$ref": "#/components/schemas/MediaItem"
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "MediaItemResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "message_code": {
            "type": "string",
            "example": "SUCCESS"
          },
          "data": {
            "$ref": "#/components/schemas/MediaItem"
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "MediaCollectionResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "message_code": {
            "type": "string",
            "example": "SUCCESS"
          },
          "data": {
            "type": "object",
            "properties": {
              "meta": {
                "$ref": "#/components/schemas/PaginationMeta"
              },
              "data": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/MediaItem"
                }
              }
            }
          }
        },
        "required": [
          "success",
          "message_code",
          "data"
        ]
      },
      "MediaItem": {
        "type": "object",
        "description": "Objeto que representa uma imagem/mídia na API de seller. Campos internos de propriedade (`owner_id`, `owner_model`) ficam de fora do payload de propósito — você não precisa deles para integrar, então não vai encontrá-los aqui.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identificador único da imagem (26 caracteres). É o valor usado como `{file_hash}` nas rotas de detalhe e exclusão.",
            "example": "01JMZXZ72881MD2P37N2K97YJJ"
          },
          "original_source": {
            "type": "string",
            "format": "uri",
            "description": "URL da imagem original, já convertida para WebP em alta qualidade.",
            "example": "https://cdn.example.com/products/2026/05/28/original_01JMZXZ72881MD2P37N2K97YJJ.webp"
          },
          "urls": {
            "type": "array",
            "description": "Variações de tamanho geradas automaticamente (todas em WebP). Uma entrada por variação: `thumbnail` (135x135), `sm` (200x200), `md` (400x400), `lg` (800x800) e `xl` (1600x1600).",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "enum": [
                    "thumbnail",
                    "sm",
                    "md",
                    "lg",
                    "xl"
                  ],
                  "description": "Nome da variação de tamanho.",
                  "example": "thumbnail"
                },
                "size": {
                  "type": "string",
                  "description": "Dimensões máximas da variação, no formato largura x altura.",
                  "example": "135x135"
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "description": "URL pública da variação.",
                  "example": "https://cdn.example.com/products/2026/05/28/thumbnail_01JMZXZ72881MD2P37N2K97YJJ.webp"
                }
              },
              "required": [
                "name",
                "size",
                "url"
              ]
            }
          },
          "in_use": {
            "type": "boolean",
            "description": "Indica se a imagem está associada a algum recurso.",
            "example": false
          },
          "reference_id": {
            "type": "string",
            "nullable": true,
            "description": "ID do recurso referenciado (se houver)."
          },
          "reference_model": {
            "type": "string",
            "nullable": true,
            "enum": [
              "product",
              "publication",
              "store"
            ],
            "description": "Tipo do recurso vinculado, em formato curto. Use o mesmo valor no filtro `filter[reference_model]=...`."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Data de criação da imagem.",
            "example": "2026-05-28T10:00:00-03:00"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "Data da última atualização da imagem.",
            "example": "2026-05-28T10:00:00-03:00"
          }
        },
        "required": [
          "id",
          "original_source",
          "urls",
          "in_use",
          "reference_id",
          "reference_model",
          "created_at",
          "updated_at"
        ]
      },
      "MediaCloneFromSkusResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "message_code": {
            "type": "string",
            "example": "OK"
          },
          "data": {
            "type": "object",
            "properties": {
              "results": {
                "type": "object",
                "description": "Mapa key → lista de mídias clonadas. As keys são exatamente as enviadas nos targets.",
                "additionalProperties": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClonedMediaItem"
                  }
                }
              },
              "ignored_skus": {
                "type": "array",
                "description": "SKUs que não pertencem (ou não estão associados) à loja autenticada. Não geram erro — as keys correspondentes voltam vazias.",
                "items": {
                  "type": "string"
                },
                "example": [
                  "CAMISETA-VERM-M"
                ]
              }
            },
            "required": [
              "results",
              "ignored_skus"
            ]
          }
        },
        "required": [
          "success",
          "data"
        ]
      },
      "ClonedMediaItem": {
        "type": "object",
        "description": "Mídia recém-clonada a partir de uma foto de produto. Nasce sem vínculo (`in_use=false`) — vincule ao anúncio normalmente via `images[].id`; se não for usada, a limpeza diária remove a cópia após ~72 horas.",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID da nova mídia (26 caracteres). Use este valor nas `images` do anúncio/variação.",
            "example": "01JNB2T4G93QRT5V6W7X8Y9Z0A"
          },
          "source_image_id": {
            "type": "string",
            "description": "ID da imagem de origem (foto da galeria do produto). Útil para rastrear de onde a cópia veio e evitar duplicar sugestões.",
            "example": "01JMZXZ72881MD2P37N2K97YJJ"
          },
          "original_source": {
            "type": "string",
            "format": "uri",
            "description": "URL da cópia em alta qualidade (WebP).",
            "example": "https://cdn.example.com/products/2026/06/11/original_01JNB2T4G93QRT5V6W7X8Y9Z0A.webp"
          },
          "urls": {
            "type": "array",
            "description": "Variações de tamanho copiadas da imagem de origem (mesmos nomes do upload: `thumbnail`, `sm`, `md`, `lg`, `xl`).",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "example": "sm"
                },
                "size": {
                  "type": "string",
                  "nullable": true,
                  "example": "200x200"
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "example": "https://cdn.example.com/products/2026/06/11/sm_01JNB2T4G93QRT5V6W7X8Y9Z0A.webp"
                }
              },
              "required": [
                "name",
                "url"
              ]
            }
          }
        },
        "required": [
          "id",
          "source_image_id",
          "original_source",
          "urls"
        ]
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Token não fornecido, inválido ou expirado",
        "content": {
          "application/json": {
            "example": {
              "success": false,
              "code": 401,
              "message_code": "UNAUTHORIZED",
              "description": "A autenticação é necessária e falhou ou não foi fornecida.",
              "data": [],
              "errors": [
                "O access_token da loja é obrigatório no cabeçalho Authorization"
              ],
              "meta": []
            }
          }
        }
      },
      "Forbidden": {
        "description": "Sem permissão para acessar este recurso",
        "content": {
          "application/json": {
            "example": {
              "success": false,
              "code": 403,
              "message_code": "FORBIDDEN",
              "description": "Você não tem permissão para acessar este recurso.",
              "data": [],
              "errors": [
                "Você não tem permissão para acessar este recurso (escopos ausentes: store_products_write)"
              ],
              "meta": []
            }
          }
        }
      },
      "NotFound": {
        "description": "Recurso não encontrado",
        "content": {
          "application/json": {
            "example": {
              "success": false,
              "code": 404,
              "message_code": "NOT_FOUND",
              "description": "O recurso solicitado não foi encontrado.",
              "data": [],
              "errors": [
                "Produto não encontrado."
              ],
              "meta": []
            }
          }
        }
      },
      "Duplicated": {
        "description": "Recurso duplicado (ex: SKU já existe nesta loja)",
        "content": {
          "application/json": {
            "example": {
              "success": false,
              "code": 409,
              "message_code": "DUPLICATED",
              "description": "Este SKU já está cadastrado para esta loja.",
              "data": [],
              "errors": [
                "Este SKU já está cadastrado para esta loja."
              ],
              "meta": []
            }
          }
        }
      },
      "ValidationError": {
        "description": "Erro de validação nos campos enviados",
        "content": {
          "application/json": {
            "example": {
              "success": false,
              "code": 422,
              "message_code": "VALIDATION_ERROR",
              "description": "Foram encontrados erros de validação na requisição.",
              "data": [],
              "errors": {
                "sku": [
                  "O campo SKU é obrigatório."
                ],
                "name": [
                  "O campo Nome é obrigatório."
                ],
                "dimensions.height": [
                  "O campo dimensions.height é obrigatório."
                ]
              },
              "meta": []
            }
          }
        }
      },
      "Conflict": {
        "description": "Endereco identico ja vinculado ao local de estoque",
        "content": {
          "application/json": {
            "example": {
              "success": false,
              "message_code": "CONFLICT",
              "data": {
                "message": "Já existe um endereço idêntico vinculado ao local de estoque."
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "integrationToken": []
    }
  ]
}