{
    "openapi": "3.1.0",
    "info": {
        "title": "API SuperEmpreendedor",
        "version": "1.0.0",
        "description": "API para criar e gerenciar páginas, links curtos e imagens na Comunidade SuperEmpreendedor, por sistemas e assistentes de IA, sempre com o consentimento do dono da conta.\n\nRegras:\n- Crie conta ou ligue uma conta SOMENTE quando o usuário pedir e informar nome, e-mail e telefone. Nunca invente dados.\n- A página nasce como RASCUNHO. Ela só vai ao ar depois que o usuário confirmar o e-mail (link enviado por nós) e você chamar o endpoint de publicar.\n- Não publique conteúdo ilegal, enganoso, adulto, golpe/phishing, nem se passe por outra pessoa ou empresa. Depoimentos devem ser reais e fornecidos pelo usuário.\n- Não envie links de encurtadores de terceiros nem endereços locais; eles são recusados.\n- Use a identidade do usuário: cores (hex #RRGGBB), fonte (sans, serif, rounded, mono), foto/logo enviados por /assets.\n- Também há um servidor MCP em /mcp (mesmas regras e limite). Vendas online ainda não existem e exigirão verificação de identidade (CPF/CNPJ).\n- Respeite os limites: 3 sites por conta, 100 links curtos, 60 MB de imagens, 30 requisições por minuto por chave.",
        "termsOfService": "https://superempreendedor.com/termos",
        "contact": {
            "url": "https://superempreendedor.com/desenvolvedores"
        }
    },
    "servers": [
        {
            "url": "https://superempreendedor.com"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Chave \"sea_…\" devolvida por /api/v1/agent/signup ou criada pelo usuário em Comunidade › Estúdio › Acessos de IA e API."
            }
        },
        "schemas": {
            "Erro": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean",
                        "example": false
                    },
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            },
                            "hint": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "SiteInput": {
                "type": "object",
                "properties": {
                    "kind": {
                        "type": "string",
                        "enum": [
                            "blank",
                            "bio",
                            "cartao",
                            "landing",
                            "catalogo",
                            "agenda"
                        ],
                        "description": "Modelo inicial. Use \"blank\" para montar tudo pelos blocos."
                    },
                    "title": {
                        "type": "string",
                        "maxLength": 90
                    },
                    "slug": {
                        "type": "string",
                        "description": "3 a 30 letras minúsculas, números e hífen."
                    },
                    "seo_desc": {
                        "type": "string",
                        "maxLength": 160
                    },
                    "theme": {
                        "type": "object",
                        "properties": {
                            "primary": {
                                "type": "string",
                                "example": "#ff5500"
                            },
                            "bg": {
                                "type": "string"
                            },
                            "bg2": {
                                "type": "string"
                            },
                            "text": {
                                "type": "string"
                            },
                            "btn_text": {
                                "type": "string"
                            },
                            "font": {
                                "type": "string",
                                "enum": [
                                    "sans",
                                    "serif",
                                    "rounded",
                                    "mono"
                                ]
                            },
                            "radius": {
                                "type": "string",
                                "enum": [
                                    "square",
                                    "round",
                                    "pill"
                                ]
                            },
                            "bg_type": {
                                "type": "string",
                                "enum": [
                                    "solid",
                                    "gradient",
                                    "image"
                                ]
                            },
                            "bg_asset": {
                                "type": "integer"
                            },
                            "width": {
                                "type": "string",
                                "enum": [
                                    "narrow",
                                    "wide"
                                ]
                            }
                        }
                    },
                    "blocks": {
                        "type": "array",
                        "maxItems": 40,
                        "items": {
                            "type": "object",
                            "required": [
                                "type",
                                "props"
                            ],
                            "properties": {
                                "type": {
                                    "type": "string",
                                    "enum": [
                                        "hero",
                                        "text",
                                        "button",
                                        "links",
                                        "image",
                                        "gallery",
                                        "social",
                                        "whatsapp",
                                        "video",
                                        "catalog",
                                        "products",
                                        "booking",
                                        "contact",
                                        "faq",
                                        "testimonials",
                                        "address",
                                        "vcard",
                                        "divider"
                                    ]
                                },
                                "props": {
                                    "type": "object",
                                    "description": "Veja GET /api/v1/schema para as propriedades de cada tipo."
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "paths": {
        "/api/v1/agent/signup": {
            "post": {
                "operationId": "agentSignup",
                "summary": "Cria a conta do usuário ou pede acesso a uma conta existente",
                "description": "Use somente quando o usuário pediu e forneceu os dados. Enviamos um e-mail ao usuário para autorizar. Resposta 201 = conta nova (rascunhos liberados); 202 = conta já existia, aguarde a aprovação do dono.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "agent_name",
                                    "name",
                                    "email",
                                    "phone",
                                    "accept_terms",
                                    "user_authorized"
                                ],
                                "properties": {
                                    "agent_name": {
                                        "type": "string",
                                        "example": "Meu Assistente"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "phone": {
                                        "type": "string",
                                        "example": "(92) 99999-8888"
                                    },
                                    "accept_terms": {
                                        "type": "boolean",
                                        "description": "O usuário aceitou os Termos e a Política de Privacidade."
                                    },
                                    "user_authorized": {
                                        "type": "boolean",
                                        "description": "O usuário pediu esta criação/ligação de conta."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Conta criada. Guarde o token."
                    },
                    "202": {
                        "description": "Conta existente: aguardando aprovação do dono."
                    },
                    "422": {
                        "description": "Dados inválidos",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erro"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Muitas tentativas"
                    }
                }
            }
        },
        "/api/v1/agent/status": {
            "get": {
                "operationId": "agentStatus",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Situação da chave e da conta",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/api/v1/schema": {
            "get": {
                "operationId": "schema",
                "summary": "Blocos, modelos, tema e limites",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/api/v1/me": {
            "get": {
                "operationId": "me",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Dados da conta",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/api/v1/sites": {
            "get": {
                "operationId": "listSites",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Lista os sites",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "post": {
                "operationId": "createSite",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Cria um site (rascunho)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SiteInput"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Criado"
                    },
                    "422": {
                        "description": "Inválido",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Erro"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/sites/{id}": {
            "get": {
                "operationId": "getSite",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "summary": "Lê um site",
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "404": {
                        "description": "Não encontrado"
                    }
                }
            },
            "put": {
                "operationId": "updateSite",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "summary": "Atualiza um site",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SiteInput"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "delete": {
                "operationId": "deleteSite",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "summary": "Exclui um site",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/api/v1/sites/{id}/publish": {
            "post": {
                "operationId": "publishSite",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "summary": "Publica (exige e-mail do dono confirmado)",
                "responses": {
                    "200": {
                        "description": "Publicado"
                    },
                    "403": {
                        "description": "Dono ainda não confirmou o e-mail"
                    }
                }
            }
        },
        "/api/v1/sites/{id}/unpublish": {
            "post": {
                "operationId": "unpublishSite",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "summary": "Despublica",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/api/v1/assets": {
            "get": {
                "operationId": "listAssets",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Lista imagens",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "post": {
                "operationId": "uploadAsset",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Envia imagem (JPG/PNG/WebP até 4 MB)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "data_base64"
                                ],
                                "properties": {
                                    "filename": {
                                        "type": "string"
                                    },
                                    "data_base64": {
                                        "type": "string",
                                        "format": "byte"
                                    }
                                }
                            }
                        },
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Enviada: devolve id e url"
                    }
                }
            }
        },
        "/api/v1/links": {
            "get": {
                "operationId": "listLinks",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Lista links curtos",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            },
            "post": {
                "operationId": "createLink",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "summary": "Cria link curto (exige e-mail confirmado)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "url"
                                ],
                                "properties": {
                                    "url": {
                                        "type": "string"
                                    },
                                    "code": {
                                        "type": "string"
                                    },
                                    "title": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Criado"
                    }
                }
            }
        },
        "/api/v1/links/{id}/stats": {
            "get": {
                "operationId": "linkStats",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "summary": "Cliques por dia",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/api/v1/links/{id}": {
            "delete": {
                "operationId": "deleteLink",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "summary": "Exclui link curto",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    }
}