{
    "openapi": "3.0.3",
    "info": {
        "title": "API Construção — CRM",
        "version": "1.0.0",
        "description": "Acesso externo ao módulo Construção (materiais com unidade de venda, rendimento e variações, estoque e movimentações, fornecedores e compras, orçamentos de obra com calculadora, entregas, vendas do PDV, clientes, indicadores e performance por canal).\n\nAutenticação: chave de API da empresa (Configurações › API) no cabeçalho `Authorization: Bearer <chave>` ou `X-Api-Key`. Limite: 300 requisições/min. A material é o mesmo cadastro do catálogo do CRM (products); `niche_revision` é o controle de concorrência."
    },
    "servers": [
        {
            "url": "/api/v1/construcao"
        }
    ],
    "components": {
        "securitySchemes": {
            "ApiKey": {
                "type": "http",
                "scheme": "bearer"
            }
        }
    },
    "security": [
        {
            "ApiKey": []
        }
    ],
    "paths": {
        "/materials": {
            "get": {
                "summary": "Listar materiais (paginado)",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "description": "Nome, código, categoria ou característica",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "ativo|inativo|baixo|zerado|sem_foto|sem_preco|promo|vitrine|sem_grade",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "tipo",
                        "in": "query",
                        "description": "Tipo de material",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "marca",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "local",
                        "in": "query",
                        "description": "Local de aplicação",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "unidade",
                        "in": "query",
                        "description": "Unidade de venda",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "category",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "color",
                        "in": "query",
                        "description": "Cor nas variações",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pack",
                        "in": "query",
                        "description": "Embalagem nas variações",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "supplier",
                        "in": "query",
                        "description": "Fornecedor",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "description": "recente|preco_asc|preco_desc|estoque|nome|vendidos",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Máx. 60",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Página de materiais",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "items": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "object"
                                                    }
                                                },
                                                "total": {
                                                    "type": "integer"
                                                },
                                                "page": {
                                                    "type": "integer"
                                                },
                                                "pages": {
                                                    "type": "integer"
                                                },
                                                "summary": {
                                                    "type": "object"
                                                },
                                                "facets": {
                                                    "type": "object"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Cadastrar material",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "price": {
                                        "type": "number"
                                    },
                                    "promo_price": {
                                        "type": "number"
                                    },
                                    "cost_price": {
                                        "type": "number"
                                    },
                                    "sku": {
                                        "type": "string"
                                    },
                                    "category": {
                                        "type": "string"
                                    },
                                    "product_url": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string"
                                    },
                                    "internal_notes": {
                                        "type": "string"
                                    },
                                    "min_stock": {
                                        "type": "number"
                                    },
                                    "track_stock": {
                                        "type": "boolean"
                                    },
                                    "stock_quantity": {
                                        "type": "number",
                                        "description": "Só na criação (saldo inicial, material sem grade)"
                                    },
                                    "media_items": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "url": {
                                                    "type": "string"
                                                },
                                                "type": {
                                                    "type": "string",
                                                    "enum": [
                                                        "image",
                                                        "video"
                                                    ]
                                                }
                                            }
                                        }
                                    },
                                    "attrs": {
                                        "type": "object",
                                        "properties": {
                                            "tipo_material": {
                                                "type": "string",
                                                "description": "Tipo de material"
                                            },
                                            "marca": {
                                                "type": "string",
                                                "description": "Marca"
                                            },
                                            "referencia": {
                                                "type": "string",
                                                "description": "Referência"
                                            },
                                            "unidade_venda": {
                                                "type": "string",
                                                "description": "Unidade de venda"
                                            },
                                            "cor_acabamento": {
                                                "type": "string",
                                                "description": "Cor / acabamento"
                                            },
                                            "espessura_mm": {
                                                "type": "string",
                                                "description": "Espessura (mm)"
                                            },
                                            "largura_peca_cm": {
                                                "type": "string",
                                                "description": "Largura da peça (cm)"
                                            },
                                            "altura_peca_cm": {
                                                "type": "string",
                                                "description": "Altura da peça (cm)"
                                            },
                                            "rendimento": {
                                                "type": "string",
                                                "description": "Rendimento"
                                            },
                                            "local_aplicacao": {
                                                "type": "string",
                                                "description": "Local de aplicação"
                                            },
                                            "fornecedor_id": {
                                                "type": "string",
                                                "description": "Fornecedor"
                                            },
                                            "ncm": {
                                                "type": "string",
                                                "description": "NCM"
                                            },
                                            "codigo_barras": {
                                                "type": "string",
                                                "description": "Código de barras"
                                            },
                                            "destaques": {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                },
                                                "description": "Destaques"
                                            },
                                            "instrucoes_aplicacao": {
                                                "type": "string",
                                                "description": "Instruções de aplicação"
                                            },
                                            "tempo_secagem": {
                                                "type": "string",
                                                "description": "Tempo de secagem"
                                            },
                                            "garantia": {
                                                "type": "string",
                                                "description": "Garantia"
                                            },
                                            "peso_kg": {
                                                "type": "string",
                                                "description": "Peso (kg)"
                                            },
                                            "volume_litros": {
                                                "type": "string",
                                                "description": "Volume (litros)"
                                            },
                                            "cores": {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                },
                                                "description": "Cores disponíveis"
                                            },
                                            "embalagens": {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                },
                                                "description": "Embalagens disponíveis"
                                            },
                                            "rendimento_m2": {
                                                "type": "string",
                                                "description": "Rendimento (m² por unidade)"
                                            },
                                            "demaos": {
                                                "type": "string",
                                                "description": "Demãos recomendadas"
                                            }
                                        },
                                        "description": "Características (tipo_material, marca, referencia, unidade_venda, cor_acabamento, espessura_mm, largura_peca_cm, altura_peca_cm, rendimento, local_aplicacao + extras do módulo)"
                                    },
                                    "is_active": {
                                        "type": "boolean"
                                    },
                                    "published_on_site": {
                                        "type": "boolean"
                                    },
                                    "featured": {
                                        "type": "boolean"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Ficha do material",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/materials/{id}": {
            "get": {
                "summary": "Ficha do material (variações, movimentações, vendas, compras, histórico)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ficha",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "summary": "Atualizar material (campos ausentes são mantidos)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "price": {
                                        "type": "number"
                                    },
                                    "promo_price": {
                                        "type": "number"
                                    },
                                    "cost_price": {
                                        "type": "number"
                                    },
                                    "sku": {
                                        "type": "string"
                                    },
                                    "category": {
                                        "type": "string"
                                    },
                                    "product_url": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string"
                                    },
                                    "internal_notes": {
                                        "type": "string"
                                    },
                                    "min_stock": {
                                        "type": "number"
                                    },
                                    "track_stock": {
                                        "type": "boolean"
                                    },
                                    "stock_quantity": {
                                        "type": "number",
                                        "description": "Só na criação (saldo inicial, material sem grade)"
                                    },
                                    "media_items": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "url": {
                                                    "type": "string"
                                                },
                                                "type": {
                                                    "type": "string",
                                                    "enum": [
                                                        "image",
                                                        "video"
                                                    ]
                                                }
                                            }
                                        }
                                    },
                                    "attrs": {
                                        "type": "object",
                                        "properties": {
                                            "tipo_material": {
                                                "type": "string",
                                                "description": "Tipo de material"
                                            },
                                            "marca": {
                                                "type": "string",
                                                "description": "Marca"
                                            },
                                            "referencia": {
                                                "type": "string",
                                                "description": "Referência"
                                            },
                                            "unidade_venda": {
                                                "type": "string",
                                                "description": "Unidade de venda"
                                            },
                                            "cor_acabamento": {
                                                "type": "string",
                                                "description": "Cor / acabamento"
                                            },
                                            "espessura_mm": {
                                                "type": "string",
                                                "description": "Espessura (mm)"
                                            },
                                            "largura_peca_cm": {
                                                "type": "string",
                                                "description": "Largura da peça (cm)"
                                            },
                                            "altura_peca_cm": {
                                                "type": "string",
                                                "description": "Altura da peça (cm)"
                                            },
                                            "rendimento": {
                                                "type": "string",
                                                "description": "Rendimento"
                                            },
                                            "local_aplicacao": {
                                                "type": "string",
                                                "description": "Local de aplicação"
                                            },
                                            "fornecedor_id": {
                                                "type": "string",
                                                "description": "Fornecedor"
                                            },
                                            "ncm": {
                                                "type": "string",
                                                "description": "NCM"
                                            },
                                            "codigo_barras": {
                                                "type": "string",
                                                "description": "Código de barras"
                                            },
                                            "destaques": {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                },
                                                "description": "Destaques"
                                            },
                                            "instrucoes_aplicacao": {
                                                "type": "string",
                                                "description": "Instruções de aplicação"
                                            },
                                            "tempo_secagem": {
                                                "type": "string",
                                                "description": "Tempo de secagem"
                                            },
                                            "garantia": {
                                                "type": "string",
                                                "description": "Garantia"
                                            },
                                            "peso_kg": {
                                                "type": "string",
                                                "description": "Peso (kg)"
                                            },
                                            "volume_litros": {
                                                "type": "string",
                                                "description": "Volume (litros)"
                                            },
                                            "cores": {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                },
                                                "description": "Cores disponíveis"
                                            },
                                            "embalagens": {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                },
                                                "description": "Embalagens disponíveis"
                                            },
                                            "rendimento_m2": {
                                                "type": "string",
                                                "description": "Rendimento (m² por unidade)"
                                            },
                                            "demaos": {
                                                "type": "string",
                                                "description": "Demãos recomendadas"
                                            }
                                        },
                                        "description": "Características (tipo_material, marca, referencia, unidade_venda, cor_acabamento, espessura_mm, largura_peca_cm, altura_peca_cm, rendimento, local_aplicacao + extras do módulo)"
                                    },
                                    "is_active": {
                                        "type": "boolean"
                                    },
                                    "published_on_site": {
                                        "type": "boolean"
                                    },
                                    "featured": {
                                        "type": "boolean"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Ficha",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "summary": "Excluir material (bloqueado se tiver vendas, negócios ou cobranças)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Resultado",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/materials/{id}/variants": {
            "get": {
                "summary": "Variações do material",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Variações",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "summary": "Salvar todas as variações",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "variants"
                                ],
                                "properties": {
                                    "variants": {
                                        "type": "array",
                                        "description": "Lista completa (linhas ausentes não podem ser removidas: desative com active=false)",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "label": {
                                                    "type": "string"
                                                },
                                                "color": {
                                                    "type": "string"
                                                },
                                                "pack": {
                                                    "type": "string"
                                                },
                                                "sku": {
                                                    "type": "string"
                                                },
                                                "price": {
                                                    "type": "number"
                                                },
                                                "promo_price": {
                                                    "type": "number"
                                                },
                                                "stock": {
                                                    "type": "number"
                                                },
                                                "image_url": {
                                                    "type": "string"
                                                },
                                                "active": {
                                                    "type": "boolean"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Ficha",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/materials/{id}/grid": {
            "post": {
                "summary": "Gerar variações cores × embalagens (mantém variações existentes)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "colors": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    },
                                    "packs": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    },
                                    "stock": {
                                        "type": "number"
                                    },
                                    "sku_base": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Ficha",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/materials/{id}/stock": {
            "post": {
                "summary": "Movimentar estoque (material ou variação)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "type",
                                    "quantity",
                                    "reason"
                                ],
                                "properties": {
                                    "type": {
                                        "type": "string",
                                        "enum": [
                                            "entrada",
                                            "saida",
                                            "ajuste"
                                        ]
                                    },
                                    "quantity": {
                                        "type": "number"
                                    },
                                    "reason": {
                                        "type": "string"
                                    },
                                    "variant_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Ficha",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/materials/bulk": {
            "post": {
                "summary": "Ação em lote",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "ids",
                                    "bulk"
                                ],
                                "properties": {
                                    "ids": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "format": "uuid"
                                        }
                                    },
                                    "bulk": {
                                        "type": "string",
                                        "enum": [
                                            "ativar",
                                            "desativar",
                                            "vitrine_on",
                                            "vitrine_off",
                                            "marca",
                                            "tipo",
                                            "local",
                                            "promo",
                                            "promo_off",
                                            "categoria",
                                            "estoque_minimo"
                                        ]
                                    },
                                    "value": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Resultado",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/stock/movements": {
            "get": {
                "summary": "Movimentações de estoque",
                "parameters": [
                    {
                        "name": "product_id",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "description": "entrada|saida|ajuste",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "days",
                        "in": "query",
                        "description": "Últimos N dias",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Máx. 300",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Movimentações",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/stock/low": {
            "get": {
                "summary": "Materiais com estoque baixo ou variação zerada",
                "responses": {
                    "200": {
                        "description": "Materiais",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/suppliers": {
            "get": {
                "summary": "Fornecedores",
                "parameters": [
                    {
                        "name": "active",
                        "in": "query",
                        "description": "1 só ativos",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Fornecedores",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Cadastrar fornecedor",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "cnpj": {
                                        "type": "string"
                                    },
                                    "contact_name": {
                                        "type": "string"
                                    },
                                    "phone": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string"
                                    },
                                    "city": {
                                        "type": "string"
                                    },
                                    "uf": {
                                        "type": "string"
                                    },
                                    "lead_days": {
                                        "type": "integer"
                                    },
                                    "payment_terms": {
                                        "type": "string"
                                    },
                                    "notes": {
                                        "type": "string"
                                    },
                                    "active": {
                                        "type": "boolean"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Fornecedor",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/suppliers/{id}": {
            "put": {
                "summary": "Alterar fornecedor",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "active": {
                                        "type": "boolean"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Fornecedor",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases": {
            "get": {
                "summary": "Compras",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "description": "rascunho|pedido|recebido|cancelado|abertas|a_pagar",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "supplier",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Compras",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Criar compra (rascunho ou pedido)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "supplier_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "rascunho",
                                            "pedido"
                                        ]
                                    },
                                    "order_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "expected_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "invoice_number": {
                                        "type": "string"
                                    },
                                    "freight": {
                                        "type": "number"
                                    },
                                    "discount": {
                                        "type": "number"
                                    },
                                    "due_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "notes": {
                                        "type": "string"
                                    },
                                    "items": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "product_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "variant_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "description": {
                                                    "type": "string"
                                                },
                                                "quantity": {
                                                    "type": "number"
                                                },
                                                "unit_cost": {
                                                    "type": "number"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Compra",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases/{id}": {
            "get": {
                "summary": "Compra com itens",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Compra",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "summary": "Alterar compra (só rascunho/pedido)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "supplier_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "rascunho",
                                            "pedido"
                                        ]
                                    },
                                    "order_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "expected_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "invoice_number": {
                                        "type": "string"
                                    },
                                    "freight": {
                                        "type": "number"
                                    },
                                    "discount": {
                                        "type": "number"
                                    },
                                    "due_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "notes": {
                                        "type": "string"
                                    },
                                    "items": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "product_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "variant_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "description": {
                                                    "type": "string"
                                                },
                                                "quantity": {
                                                    "type": "number"
                                                },
                                                "unit_cost": {
                                                    "type": "number"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Compra",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases/{id}/receive": {
            "post": {
                "summary": "Receber: entrada no estoque, custo atualizado, despesa no Caixa",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "invoice_number": {
                                        "type": "string"
                                    },
                                    "paid": {
                                        "type": "boolean"
                                    },
                                    "due_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "update_cost": {
                                        "type": "boolean"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Compra",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/purchases/{id}/cancel": {
            "post": {
                "summary": "Cancelar compra não recebida",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "reason": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Compra",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/sales": {
            "get": {
                "summary": "Vendas do PDV + resumo do mês (por vendedor, forma, mais vendidos, marcas, unidades)",
                "parameters": [
                    {
                        "name": "month",
                        "in": "query",
                        "description": "AAAA-MM",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "completed|canceled",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "user_id",
                        "in": "query",
                        "description": "Vendedor",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "description": "Cliente, nº ou material",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Vendas",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/sales/{id}": {
            "get": {
                "summary": "Venda com itens, pagamentos, devoluções e comissão",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Venda",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/customers": {
            "get": {
                "summary": "Clientes que compraram no PDV (recência, frequência, valor, marcas)",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "description": "recente|valor|frequencia|inativos",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Clientes",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/customers/{id}": {
            "get": {
                "summary": "Cliente com compras e materiais",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Cliente",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/quotes": {
            "get": {
                "summary": "Orçamentos de obra + resumo do mês",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "description": "rascunho|enviado|aprovado|perdido|cancelado|abertos",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "user_id",
                        "in": "query",
                        "description": "Vendedor",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "description": "Cliente, obra ou nº",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "month",
                        "in": "query",
                        "description": "AAAA-MM",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Orçamentos",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Criar orçamento (itens com material/variação ou descrição livre; preço vazio usa o do catálogo)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "contact_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "customer_name": {
                                        "type": "string"
                                    },
                                    "customer_phone": {
                                        "type": "string"
                                    },
                                    "site_name": {
                                        "type": "string"
                                    },
                                    "site_address": {
                                        "type": "string"
                                    },
                                    "seller_user_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "deal_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "valid_until": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "discount": {
                                        "type": "number"
                                    },
                                    "freight": {
                                        "type": "number"
                                    },
                                    "payment_terms": {
                                        "type": "string"
                                    },
                                    "notes": {
                                        "type": "string"
                                    },
                                    "items": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "product_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "variant_id": {
                                                    "type": "string",
                                                    "format": "uuid"
                                                },
                                                "description": {
                                                    "type": "string"
                                                },
                                                "unit": {
                                                    "type": "string"
                                                },
                                                "area_m2": {
                                                    "type": "number"
                                                },
                                                "coverage": {
                                                    "type": "number"
                                                },
                                                "quantity": {
                                                    "type": "number"
                                                },
                                                "unit_price": {
                                                    "type": "number"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Orçamento",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/quotes/{id}": {
            "get": {
                "summary": "Orçamento com itens e entregas",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Orçamento",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "summary": "Alterar orçamento (só rascunho/enviado)",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "items": {
                                        "type": "array",
                                        "items": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Orçamento",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/quotes/{id}/status": {
            "post": {
                "summary": "Enviar, aprovar (com pdv_sale_id opcional), perder ou cancelar",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "status"
                                ],
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "rascunho",
                                            "enviado",
                                            "aprovado",
                                            "perdido",
                                            "cancelado"
                                        ]
                                    },
                                    "reason": {
                                        "type": "string"
                                    },
                                    "pdv_sale_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Orçamento",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/calc": {
            "get": {
                "summary": "Calculadora de consumo: área ÷ rendimento × demãos com perda",
                "parameters": [
                    {
                        "name": "area",
                        "in": "query",
                        "description": "m²",
                        "required": true,
                        "schema": {
                            "type": "number"
                        }
                    },
                    {
                        "name": "coverage",
                        "in": "query",
                        "description": "m² por unidade",
                        "required": true,
                        "schema": {
                            "type": "number"
                        }
                    },
                    {
                        "name": "coats",
                        "in": "query",
                        "description": "Demãos",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "waste",
                        "in": "query",
                        "description": "% de perda (padrão 10)",
                        "required": false,
                        "schema": {
                            "type": "number"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Quantidade sugerida",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/deliveries": {
            "get": {
                "summary": "Entregas",
                "parameters": [
                    {
                        "name": "range",
                        "in": "query",
                        "description": "proximas|hoje|semana|passadas|todas",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "description": "agendada|saiu|entregue|falhou|cancelada",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "driver",
                        "in": "query",
                        "description": "Entregador",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "description": "Cliente, endereço ou nº",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Entregas",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Agendar entrega (entra na Agenda do entregador)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "address",
                                    "date",
                                    "time"
                                ],
                                "properties": {
                                    "pdv_sale_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "quote_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "contact_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "customer_name": {
                                        "type": "string"
                                    },
                                    "customer_phone": {
                                        "type": "string"
                                    },
                                    "address": {
                                        "type": "string"
                                    },
                                    "date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "time": {
                                        "type": "string",
                                        "description": "HH:MM"
                                    },
                                    "window_minutes": {
                                        "type": "integer"
                                    },
                                    "driver_user_id": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "items_summary": {
                                        "type": "string"
                                    },
                                    "fee": {
                                        "type": "number"
                                    },
                                    "notes": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Entrega",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/deliveries/{id}": {
            "get": {
                "summary": "Entrega",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Entrega",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "summary": "Alterar entrega",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [],
                                "properties": {
                                    "address": {
                                        "type": "string"
                                    },
                                    "date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "time": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Entrega",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/deliveries/{id}/status": {
            "post": {
                "summary": "Saiu, entregue (com receiver_name), não entregue ou cancelada",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Identificador (UUID)",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "status"
                                ],
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "agendada",
                                            "saiu",
                                            "entregue",
                                            "falhou",
                                            "cancelada"
                                        ]
                                    },
                                    "receiver_name": {
                                        "type": "string"
                                    },
                                    "notes": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Entrega",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/dashboard": {
            "get": {
                "summary": "Visão geral (catálogo, estoque, vendas do mês, compras, alertas)",
                "responses": {
                    "200": {
                        "description": "Indicadores",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/reports": {
            "get": {
                "summary": "Relatórios por período",
                "parameters": [
                    {
                        "name": "months",
                        "in": "query",
                        "description": "3 a 24 (padrão 12)",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Relatórios",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/channels/performance": {
            "get": {
                "summary": "Performance por canal (anúncios, leads, ganhos, custo) no mês",
                "parameters": [
                    {
                        "name": "month",
                        "in": "query",
                        "description": "AAAA-MM",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Performance",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}