{
  "openapi": "3.1.0",
  "info": {
    "title": "AllyOneCRM API",
    "version": "1.0.0",
    "description": "Superfície de integração documentada em https://allyone.com.br/docs/pt/crm. Rotas fora desta especificação são internas e podem mudar sem aviso. Autenticação: `Authorization: Bearer <JWT>` ou `X-API-Key: crm_live_…` (o tenant vem da credencial)."
  },
  "servers": [
    {
      "url": "https://api.allyone.com.br"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Autenticação"
    },
    {
      "name": "Chaves de API"
    },
    {
      "name": "Contatos"
    },
    {
      "name": "Listas"
    },
    {
      "name": "Segmentos"
    },
    {
      "name": "Templates"
    },
    {
      "name": "Campanhas"
    },
    {
      "name": "Formulários"
    },
    {
      "name": "Vendas"
    },
    {
      "name": "Conversas"
    },
    {
      "name": "WhatsApp"
    },
    {
      "name": "Webhooks"
    }
  ],
  "paths": {
    "/v1/auth/register": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Cria conta e tenant",
        "operationId": "postV1AuthRegister",
        "x-allyone-guard": "none",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Register"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/auth/login": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Login com e-mail e senha",
        "operationId": "postV1AuthLogin",
        "x-allyone-guard": "none",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Login"
              },
              "example": {
                "email": "voce@empresa.com",
                "password": "{{password}}"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Session"
                    },
                    {
                      "$ref": "#/components/schemas/TwoFactorChallenge"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/auth/2fa-verify": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Segundo passo do login com 2FA",
        "operationId": "postV1Auth2faVerify",
        "x-allyone-guard": "none",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tempToken": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "tempToken",
                  "code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/auth/refresh": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Renova o par de tokens",
        "operationId": "postV1AuthRefresh",
        "x-allyone-guard": "none",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshToken"
              },
              "example": {
                "refreshToken": "{{refreshToken}}"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenPair"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/auth/logout": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Revoga o refresh token",
        "operationId": "postV1AuthLogout",
        "x-allyone-guard": "none",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshToken"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/auth/forgot-password": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Pede o link de redefinição de senha",
        "operationId": "postV1AuthForgotPassword",
        "x-allyone-guard": "none",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/auth/reset-password": {
      "post": {
        "tags": [
          "Autenticação"
        ],
        "summary": "Redefine a senha com o token recebido",
        "operationId": "postV1AuthResetPassword",
        "x-allyone-guard": "none",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "required": [
                  "token",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/api-keys": {
      "get": {
        "tags": [
          "Chaves de API"
        ],
        "summary": "Lista chaves (sem o valor)",
        "operationId": "getV1ApiKeys",
        "x-allyone-guard": "none",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Chaves de API"
        ],
        "summary": "Cria chave — só o owner; o valor aparece apenas aqui",
        "operationId": "postV1ApiKeys",
        "x-allyone-guard": "owner",
        "description": "Só o owner da conta.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKey"
              },
              "example": {
                "name": "ERP",
                "permissions": [
                  "contacts.read",
                  "contacts.*"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedApiKey"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/api-keys/{id}/permissions": {
      "patch": {
        "tags": [
          "Chaves de API"
        ],
        "summary": "Ajusta permissões sem invalidar a chave — só o owner",
        "operationId": "patchV1ApiKeysIdPermissions",
        "x-allyone-guard": "owner",
        "description": "Só o owner da conta.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "permissions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "permissions"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/api-keys/{id}": {
      "delete": {
        "tags": [
          "Chaves de API"
        ],
        "summary": "Revoga a chave",
        "operationId": "deleteV1ApiKeysId",
        "x-allyone-guard": "none",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/contacts": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Lista contatos",
        "operationId": "getV1Contacts",
        "x-allyone-guard": "contacts.read",
        "description": "Exige a permissão `contacts.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "A partir de 1",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Padrão 50, máximo 100",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Busca em e-mail, nome e sobrenome",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "description": "Contém",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "Tag exata",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Contatos"
        ],
        "summary": "Cria contato (e-mail ou telefone E.164 obrigatório)",
        "operationId": "postV1Contacts",
        "x-allyone-guard": "contacts.*",
        "description": "Exige a permissão `contacts.*` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateContact"
              },
              "example": {
                "email": "maria@empresa.com",
                "firstName": "Maria",
                "phone": "+5511999998888",
                "tags": [
                  "cliente"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/contacts/search": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Busca rápida (seletores)",
        "operationId": "getV1ContactsSearch",
        "x-allyone-guard": "contacts.read",
        "description": "Exige a permissão `contacts.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Termo",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Máximo de resultados",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/contacts/{id}": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Um contato",
        "operationId": "getV1ContactsId",
        "x-allyone-guard": "contacts.read",
        "description": "Exige a permissão `contacts.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "patch": {
        "tags": [
          "Contatos"
        ],
        "summary": "Atualiza contato (campos ausentes não mudam; null apaga)",
        "operationId": "patchV1ContactsId",
        "x-allyone-guard": "contacts.*",
        "description": "Exige a permissão `contacts.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateContact"
              },
              "example": {
                "tags": [
                  "vip"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Contatos"
        ],
        "summary": "Remove contato",
        "operationId": "deleteV1ContactsId",
        "x-allyone-guard": "contacts.*",
        "description": "Exige a permissão `contacts.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/contacts/{id}/events": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Linha do tempo de eventos",
        "operationId": "getV1ContactsIdEvents",
        "x-allyone-guard": "contacts.read",
        "description": "Exige a permissão `contacts.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/contacts/{id}/lists": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Listas a que o contato pertence",
        "operationId": "getV1ContactsIdLists",
        "x-allyone-guard": "contacts.read",
        "description": "Exige a permissão `contacts.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/contacts/import": {
      "post": {
        "tags": [
          "Contatos"
        ],
        "summary": "Importa CSV (multipart) — processa em fila",
        "operationId": "postV1ContactsImport",
        "x-allyone-guard": "contacts.*",
        "description": "Exige a permissão `contacts.*` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                },
                "required": [
                  "file"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/contacts/import/{jobId}/status": {
      "get": {
        "tags": [
          "Contatos"
        ],
        "summary": "Andamento de uma importação",
        "operationId": "getV1ContactsImportJobIdStatus",
        "x-allyone-guard": "contacts.read",
        "description": "Exige a permissão `contacts.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/lists": {
      "get": {
        "tags": [
          "Listas"
        ],
        "summary": "Lista listas",
        "operationId": "getV1Lists",
        "x-allyone-guard": "lists.read",
        "description": "Exige a permissão `lists.read` (usuário ou chave de API).",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Listas"
        ],
        "summary": "Cria lista",
        "operationId": "postV1Lists",
        "x-allyone-guard": "lists.*",
        "description": "Exige a permissão `lists.*` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateList"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/lists/{id}": {
      "get": {
        "tags": [
          "Listas"
        ],
        "summary": "Uma lista",
        "operationId": "getV1ListsId",
        "x-allyone-guard": "lists.read",
        "description": "Exige a permissão `lists.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "patch": {
        "tags": [
          "Listas"
        ],
        "summary": "Altera lista",
        "operationId": "patchV1ListsId",
        "x-allyone-guard": "lists.*",
        "description": "Exige a permissão `lists.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateList"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Listas"
        ],
        "summary": "Apaga lista",
        "operationId": "deleteV1ListsId",
        "x-allyone-guard": "lists.*",
        "description": "Exige a permissão `lists.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/lists/{id}/contacts": {
      "get": {
        "tags": [
          "Listas"
        ],
        "summary": "Contatos da lista",
        "operationId": "getV1ListsIdContacts",
        "x-allyone-guard": "lists.read",
        "description": "Exige a permissão `lists.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "A partir de 1",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Padrão 50, máximo 100",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Listas"
        ],
        "summary": "Adiciona contatos à lista",
        "operationId": "postV1ListsIdContacts",
        "x-allyone-guard": "lists.*",
        "description": "Exige a permissão `lists.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddContactsToList"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/lists/{id}/contacts/{contactId}": {
      "delete": {
        "tags": [
          "Listas"
        ],
        "summary": "Tira um contato da lista",
        "operationId": "deleteV1ListsIdContactsContactId",
        "x-allyone-guard": "lists.*",
        "description": "Exige a permissão `lists.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/segments": {
      "get": {
        "tags": [
          "Segmentos"
        ],
        "summary": "Lista segmentos",
        "operationId": "getV1Segments",
        "x-allyone-guard": "segments.read",
        "description": "Exige a permissão `segments.read` (usuário ou chave de API).",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Segmentos"
        ],
        "summary": "Cria segmento",
        "operationId": "postV1Segments",
        "x-allyone-guard": "segments.*",
        "description": "Exige a permissão `segments.*` (usuário ou chave de API).",
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/segments/{id}": {
      "get": {
        "tags": [
          "Segmentos"
        ],
        "summary": "Um segmento",
        "operationId": "getV1SegmentsId",
        "x-allyone-guard": "segments.read",
        "description": "Exige a permissão `segments.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "patch": {
        "tags": [
          "Segmentos"
        ],
        "summary": "Altera segmento",
        "operationId": "patchV1SegmentsId",
        "x-allyone-guard": "segments.*",
        "description": "Exige a permissão `segments.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Segmentos"
        ],
        "summary": "Apaga segmento",
        "operationId": "deleteV1SegmentsId",
        "x-allyone-guard": "segments.*",
        "description": "Exige a permissão `segments.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/segments/{id}/contacts": {
      "get": {
        "tags": [
          "Segmentos"
        ],
        "summary": "Contatos do segmento agora",
        "operationId": "getV1SegmentsIdContacts",
        "x-allyone-guard": "segments.read",
        "description": "Exige a permissão `segments.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "A partir de 1",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Padrão 50, máximo 100",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/segments/preview": {
      "post": {
        "tags": [
          "Segmentos"
        ],
        "summary": "Conta contatos de um filtro sem salvar",
        "operationId": "postV1SegmentsPreview",
        "x-allyone-guard": "segments.*",
        "description": "Exige a permissão `segments.*` (usuário ou chave de API).",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/templates": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Lista templates de e-mail",
        "operationId": "getV1Templates",
        "x-allyone-guard": "templates.*",
        "description": "Exige a permissão `templates.*` (usuário ou chave de API).",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Templates"
        ],
        "summary": "Cria template",
        "operationId": "postV1Templates",
        "x-allyone-guard": "templates.*",
        "description": "Exige a permissão `templates.*` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTemplate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/templates/{id}": {
      "get": {
        "tags": [
          "Templates"
        ],
        "summary": "Um template",
        "operationId": "getV1TemplatesId",
        "x-allyone-guard": "templates.*",
        "description": "Exige a permissão `templates.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "patch": {
        "tags": [
          "Templates"
        ],
        "summary": "Altera template",
        "operationId": "patchV1TemplatesId",
        "x-allyone-guard": "templates.*",
        "description": "Exige a permissão `templates.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTemplate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Templates"
        ],
        "summary": "Apaga template",
        "operationId": "deleteV1TemplatesId",
        "x-allyone-guard": "templates.*",
        "description": "Exige a permissão `templates.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/campaigns": {
      "get": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Lista campanhas",
        "operationId": "getV1Campaigns",
        "x-allyone-guard": "campaigns.read",
        "description": "Exige a permissão `campaigns.read` (usuário ou chave de API).",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Cria campanha em rascunho",
        "operationId": "postV1Campaigns",
        "x-allyone-guard": "campaigns.*",
        "description": "Exige a permissão `campaigns.*` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCampaign"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/campaigns/{id}": {
      "get": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Uma campanha",
        "operationId": "getV1CampaignsId",
        "x-allyone-guard": "campaigns.read",
        "description": "Exige a permissão `campaigns.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "patch": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Edita campanha",
        "operationId": "patchV1CampaignsId",
        "x-allyone-guard": "campaigns.*",
        "description": "Exige a permissão `campaigns.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Apaga campanha",
        "operationId": "deleteV1CampaignsId",
        "x-allyone-guard": "campaigns.*",
        "description": "Exige a permissão `campaigns.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/campaigns/{id}/stats": {
      "get": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Métricas da campanha",
        "operationId": "getV1CampaignsIdStats",
        "x-allyone-guard": "campaigns.read",
        "description": "Exige a permissão `campaigns.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/campaigns/{id}/schedule": {
      "patch": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Agenda o envio",
        "operationId": "patchV1CampaignsIdSchedule",
        "x-allyone-guard": "campaigns.*",
        "description": "Exige a permissão `campaigns.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduleCampaign"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/campaigns/{id}/send": {
      "post": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Dispara agora (processa em fila)",
        "operationId": "postV1CampaignsIdSend",
        "x-allyone-guard": "campaigns.*",
        "description": "Exige a permissão `campaigns.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/campaigns/{id}/pause": {
      "post": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Pausa",
        "operationId": "postV1CampaignsIdPause",
        "x-allyone-guard": "campaigns.*",
        "description": "Exige a permissão `campaigns.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/campaigns/{id}/resume": {
      "post": {
        "tags": [
          "Campanhas"
        ],
        "summary": "Retoma",
        "operationId": "postV1CampaignsIdResume",
        "x-allyone-guard": "campaigns.*",
        "description": "Exige a permissão `campaigns.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/forms": {
      "get": {
        "tags": [
          "Formulários"
        ],
        "summary": "Lista formulários",
        "operationId": "getV1Forms",
        "x-allyone-guard": "forms.*",
        "description": "Exige a permissão `forms.*` (usuário ou chave de API).",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Formulários"
        ],
        "summary": "Cria formulário",
        "operationId": "postV1Forms",
        "x-allyone-guard": "forms.*",
        "description": "Exige a permissão `forms.*` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateForm"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/forms/{id}": {
      "patch": {
        "tags": [
          "Formulários"
        ],
        "summary": "Altera formulário",
        "operationId": "patchV1FormsId",
        "x-allyone-guard": "forms.*",
        "description": "Exige a permissão `forms.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateForm"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Formulários"
        ],
        "summary": "Apaga formulário",
        "operationId": "deleteV1FormsId",
        "x-allyone-guard": "forms.*",
        "description": "Exige a permissão `forms.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/forms/{id}/submissions": {
      "get": {
        "tags": [
          "Formulários"
        ],
        "summary": "Respostas recebidas",
        "operationId": "getV1FormsIdSubmissions",
        "x-allyone-guard": "forms.*",
        "description": "Exige a permissão `forms.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "A partir de 1",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Padrão 50, máximo 100",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/sales/pipelines": {
      "get": {
        "tags": [
          "Vendas"
        ],
        "summary": "Funis",
        "operationId": "getV1SalesPipelines",
        "x-allyone-guard": "sales.read",
        "description": "Exige a permissão `sales.read` (usuário ou chave de API).",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/sales/deals": {
      "get": {
        "tags": [
          "Vendas"
        ],
        "summary": "Lista negócios",
        "operationId": "getV1SalesDeals",
        "x-allyone-guard": "sales.read",
        "description": "Exige a permissão `sales.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "A partir de 1",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "description": "Padrão 50, máximo 100",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Vendas"
        ],
        "summary": "Cria negócio",
        "operationId": "postV1SalesDeals",
        "x-allyone-guard": "sales.*",
        "description": "Exige a permissão `sales.*` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDeal"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/sales/deals/{id}": {
      "get": {
        "tags": [
          "Vendas"
        ],
        "summary": "Um negócio",
        "operationId": "getV1SalesDealsId",
        "x-allyone-guard": "sales.read",
        "description": "Exige a permissão `sales.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "patch": {
        "tags": [
          "Vendas"
        ],
        "summary": "Altera negócio (inclui mover de etapa)",
        "operationId": "patchV1SalesDealsId",
        "x-allyone-guard": "sales.*",
        "description": "Exige a permissão `sales.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Vendas"
        ],
        "summary": "Apaga negócio",
        "operationId": "deleteV1SalesDealsId",
        "x-allyone-guard": "sales.*",
        "description": "Exige a permissão `sales.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/sales/deals/{id}/activities": {
      "post": {
        "tags": [
          "Vendas"
        ],
        "summary": "Registra atividade no negócio",
        "operationId": "postV1SalesDealsIdActivities",
        "x-allyone-guard": "sales.*",
        "description": "Exige a permissão `sales.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/chat/conversations": {
      "get": {
        "tags": [
          "Conversas"
        ],
        "summary": "Lista conversas",
        "operationId": "getV1ChatConversations",
        "x-allyone-guard": "chat.read",
        "description": "Exige a permissão `chat.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filtra por status",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "description": "Filtra por prioridade",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "A partir de 1",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Padrão 30, máximo 100",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/chat/conversations/{id}": {
      "get": {
        "tags": [
          "Conversas"
        ],
        "summary": "Uma conversa com mensagens",
        "operationId": "getV1ChatConversationsId",
        "x-allyone-guard": "chat.read",
        "description": "Exige a permissão `chat.read` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/chat/conversations/{id}/messages": {
      "post": {
        "tags": [
          "Conversas"
        ],
        "summary": "Envia mensagem",
        "operationId": "postV1ChatConversationsIdMessages",
        "x-allyone-guard": "chat.*",
        "description": "Exige a permissão `chat.*` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendChatMessage"
              },
              "example": {
                "content": "Olá! Posso ajudar?"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/waba-accounts": {
      "get": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "Contas WABA",
        "operationId": "getV1WabaAccounts",
        "x-allyone-guard": "none",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "Cadastra conta (token manual ou BSP)",
        "operationId": "postV1WabaAccounts",
        "x-allyone-guard": "none",
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/waba-accounts/embedded-signup/config": {
      "get": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "appId e configId do Embedded Signup",
        "operationId": "getV1WabaAccountsEmbeddedSignupConfig",
        "x-allyone-guard": "none",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/waba-accounts/embedded-signup/exchange": {
      "post": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "Troca o code do Embedded Signup",
        "operationId": "postV1WabaAccountsEmbeddedSignupExchange",
        "x-allyone-guard": "none",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/waba-accounts/{id}": {
      "patch": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "Atualiza conta / credenciais",
        "operationId": "patchV1WabaAccountsId",
        "x-allyone-guard": "none",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "Remove conta",
        "operationId": "deleteV1WabaAccountsId",
        "x-allyone-guard": "none",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/waba-accounts/{id}/test-connection": {
      "post": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "Testa a credencial",
        "operationId": "postV1WabaAccountsIdTestConnection",
        "x-allyone-guard": "none",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/waba-accounts/{id}/webhook-url": {
      "get": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "URL de webhook do BSP",
        "operationId": "getV1WabaAccountsIdWebhookUrl",
        "x-allyone-guard": "none",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/waba-accounts/{id}/phone-numbers": {
      "post": {
        "tags": [
          "WhatsApp"
        ],
        "summary": "Cadastra número",
        "operationId": "postV1WabaAccountsIdPhoneNumbers",
        "x-allyone-guard": "none",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/webhooks/events": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Eventos assináveis",
        "operationId": "getV1WebhooksEvents",
        "x-allyone-guard": "none",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Lista endpoints (secret mascarado)",
        "operationId": "getV1Webhooks",
        "x-allyone-guard": "none",
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Cadastra endpoint (secret aparece só aqui)",
        "operationId": "postV1Webhooks",
        "x-allyone-guard": "integrations:manage",
        "description": "Exige a permissão `integrations:manage` (usuário ou chave de API).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhook"
              },
              "example": {
                "name": "ERP",
                "url": "https://erp.exemplo.com/hooks/allyone",
                "events": [
                  "contact.created",
                  "deal.won"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/webhooks/{id}": {
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Altera URL, eventos ou reativa",
        "operationId": "patchV1WebhooksId",
        "x-allyone-guard": "integrations:manage",
        "description": "Exige a permissão `integrations:manage` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhook"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Remove endpoint",
        "operationId": "deleteV1WebhooksId",
        "x-allyone-guard": "integrations:manage",
        "description": "Exige a permissão `integrations:manage` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sem conteúdo"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/webhooks/{id}/rotate-secret": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Gera secret novo",
        "operationId": "postV1WebhooksIdRotateSecret",
        "x-allyone-guard": "integrations:manage",
        "description": "Exige a permissão `integrations:manage` (usuário ou chave de API).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/v1/webhooks/{id}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Últimas entregas",
        "operationId": "getV1WebhooksIdDeliveries",
        "x-allyone-guard": "none",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sucesso"
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Texto para humanos, em português"
          },
          "message": {
            "type": "string",
            "description": "Presente em erros de validação e do servidor HTTP"
          },
          "statusCode": {
            "type": "integer"
          }
        }
      },
      "Register": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "password": {
            "type": "string",
            "minLength": 8,
            "maxLength": 128
          },
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100
          },
          "tenantName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 200
          },
          "tenantSlug": {
            "type": "string",
            "minLength": 3,
            "maxLength": 63,
            "pattern": "^[a-z0-9-]+$"
          }
        },
        "required": [
          "email",
          "password",
          "name",
          "tenantName",
          "tenantSlug"
        ]
      },
      "Login": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "password": {
            "type": "string"
          }
        },
        "required": [
          "email",
          "password"
        ]
      },
      "RefreshToken": {
        "type": "object",
        "properties": {
          "refreshToken": {
            "type": "string"
          }
        },
        "required": [
          "refreshToken"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string",
            "description": "JWT"
          },
          "refreshToken": {
            "type": "string",
            "description": "Opaco; uso único, renovado a cada /refresh"
          },
          "user": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "role": {
                "type": "string"
              }
            }
          },
          "tenant": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "tier": {
                "type": "string"
              }
            }
          },
          "mustChangePassword": {
            "type": "boolean"
          }
        }
      },
      "TwoFactorChallenge": {
        "type": "object",
        "properties": {
          "requires2FA": {
            "type": "boolean",
            "const": true
          },
          "tempToken": {
            "type": "string",
            "description": "Vale 5 minutos"
          }
        }
      },
      "TokenPair": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "refreshToken": {
            "type": "string"
          }
        }
      },
      "CreateContact": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "pattern": "^\\+[1-9]\\d{7,14}$"
          },
          "mobile": {
            "type": "string"
          },
          "firstName": {
            "type": "string",
            "maxLength": 100
          },
          "lastName": {
            "type": "string",
            "maxLength": 100
          },
          "cpf": {
            "type": "string",
            "pattern": "^\\d{3}\\.?\\d{3}\\.?\\d{3}-?\\d{2}$"
          },
          "companyId": {
            "type": "string",
            "format": "uuid"
          },
          "address": {
            "type": "string",
            "maxLength": 255
          },
          "city": {
            "type": "string",
            "maxLength": 100
          },
          "state": {
            "type": "string",
            "maxLength": 100
          },
          "zipCode": {
            "type": "string",
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "maxLength": 100
          },
          "subscribedAt": {
            "type": "string",
            "format": "date-time"
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {},
            "default": {}
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 50
            },
            "default": []
          },
          "optInEmail": {
            "type": "boolean",
            "default": false
          },
          "optInWhatsapp": {
            "type": "boolean",
            "default": false
          },
          "optInPush": {
            "type": "boolean",
            "default": false
          },
          "optInSms": {
            "type": "boolean",
            "default": false
          },
          "optInRcs": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "UpdateContact": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "oneOf": [
              {
                "type": "string",
                "pattern": "^\\+[1-9]\\d{7,14}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "mobile": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "firstName": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "lastName": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "cpf": {
            "type": "string",
            "pattern": "^\\d{3}\\.?\\d{3}\\.?\\d{3}-?\\d{2}$"
          },
          "companyId": {
            "oneOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "address": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ]
          },
          "city": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "zipCode": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 20
              },
              {
                "type": "null"
              }
            ]
          },
          "country": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "subscribedAt": {
            "type": "string",
            "format": "date-time"
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {},
            "default": {}
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 50
            },
            "default": []
          },
          "optInEmail": {
            "type": "boolean",
            "default": false
          },
          "optInWhatsapp": {
            "type": "boolean",
            "default": false
          },
          "optInPush": {
            "type": "boolean",
            "default": false
          },
          "optInSms": {
            "type": "boolean",
            "default": false
          },
          "optInRcs": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "attributes": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateList": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "type": {
            "type": "string",
            "enum": [
              "static",
              "dynamic"
            ],
            "default": "static"
          },
          "filters": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "name"
        ]
      },
      "UpdateList": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "filters": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "AddContactsToList": {
        "type": "object",
        "properties": {
          "contactIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "required": [
          "contactIds"
        ]
      },
      "CreateTemplate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "channel": {
            "type": "string",
            "enum": [
              "email",
              "whatsapp",
              "sms",
              "push",
              "push_web",
              "push_app",
              "push_inapp",
              "rcs"
            ],
            "default": "email"
          },
          "content": {
            "type": "string",
            "minLength": 1
          },
          "blocks": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {}
            }
          },
          "subject": {
            "type": "string",
            "maxLength": 500
          },
          "preheader": {
            "type": "string",
            "maxLength": 200
          },
          "aiBrief": {
            "type": "object",
            "additionalProperties": {}
          }
        },
        "required": [
          "name",
          "content"
        ]
      },
      "UpdateTemplate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "content": {
            "type": "string",
            "minLength": 1
          },
          "blocks": {
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "subject": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ]
          },
          "preheader": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ]
          },
          "aiBrief": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "CreateCampaign": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "type": {
            "type": "string",
            "enum": [
              "email",
              "whatsapp",
              "sms",
              "rcs",
              "web_push",
              "app_push",
              "inapp_push",
              "multi"
            ]
          },
          "subject": {
            "type": "string",
            "maxLength": 255
          },
          "templateId": {
            "type": "string",
            "format": "uuid"
          },
          "fromName": {
            "type": "string",
            "maxLength": 100
          },
          "fromEmail": {
            "type": "string",
            "format": "email"
          },
          "scheduledAt": {
            "type": "string",
            "format": "date-time"
          },
          "targetListIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "excludedListIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "default": []
          },
          "controlGroupPct": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "default": 0
          },
          "settings": {
            "type": "object",
            "additionalProperties": {},
            "default": {}
          }
        },
        "required": [
          "name",
          "type",
          "targetListIds"
        ]
      },
      "ScheduleCampaign": {
        "type": "object",
        "properties": {
          "scheduledAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "scheduledAt"
        ]
      },
      "CreateForm": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "listIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "default": []
          },
          "schema": {
            "type": "object",
            "properties": {
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "text",
                        "email",
                        "phone",
                        "select",
                        "checkbox",
                        "textarea"
                      ]
                    },
                    "required": {
                      "type": "boolean",
                      "default": false
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "name",
                    "label",
                    "type"
                  ]
                }
              },
              "submitLabel": {
                "type": "string",
                "default": "Enviar"
              },
              "successMessage": {
                "type": "string",
                "default": "Obrigado! Você foi cadastrado."
              }
            },
            "required": [
              "fields"
            ]
          },
          "settings": {
            "type": "object",
            "properties": {
              "redirectUrl": {
                "type": "string",
                "format": "uri"
              },
              "doubleOptIn": {
                "type": "boolean",
                "default": false
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "default": []
              }
            },
            "default": {}
          }
        },
        "required": [
          "name",
          "schema"
        ]
      },
      "UpdateForm": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "listIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "default": []
          },
          "schema": {
            "type": "object",
            "properties": {
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "text",
                        "email",
                        "phone",
                        "select",
                        "checkbox",
                        "textarea"
                      ]
                    },
                    "required": {
                      "type": "boolean",
                      "default": false
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "name",
                    "label",
                    "type"
                  ]
                }
              },
              "submitLabel": {
                "type": "string",
                "default": "Enviar"
              },
              "successMessage": {
                "type": "string",
                "default": "Obrigado! Você foi cadastrado."
              }
            },
            "required": [
              "fields"
            ]
          },
          "settings": {
            "type": "object",
            "properties": {
              "redirectUrl": {
                "type": "string",
                "format": "uri"
              },
              "doubleOptIn": {
                "type": "boolean",
                "default": false
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "default": []
              }
            },
            "default": {}
          }
        }
      },
      "CreateApiKey": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "permissions": {
            "description": "Lista explícita de permissões (ex.: [\"contacts.read\",\"contacts.*\"]) ou [\"*\"] para acesso irrestrito",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "name",
          "permissions"
        ]
      },
      "CreatedApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "key": {
            "type": "string",
            "description": "crm_live_… — aparece só nesta resposta"
          },
          "key_prefix": {
            "type": "string"
          }
        }
      },
      "CreateWebhook": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "https obrigatório; IP privado/reservado é recusado"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "contact.created",
                "contact.updated",
                "contact.unsubscribed",
                "form.submitted",
                "survey.responded",
                "deal.created",
                "deal.stage_changed",
                "deal.won",
                "deal.lost",
                "campaign.completed",
                "journey.enrolled",
                "journey.completed",
                "score.rule_fired"
              ]
            }
          },
          "active": {
            "type": "boolean",
            "default": true
          }
        },
        "required": [
          "name",
          "url",
          "events"
        ]
      },
      "UpdateWebhook": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "contact.created",
                "contact.updated",
                "contact.unsubscribed",
                "form.submitted",
                "survey.responded",
                "deal.created",
                "deal.stage_changed",
                "deal.won",
                "deal.lost",
                "campaign.completed",
                "journey.enrolled",
                "journey.completed",
                "score.rule_fired"
              ]
            }
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "SendChatMessage": {
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "description": "Obrigatório se não houver mediaUrl"
          },
          "mediaUrl": {
            "type": "string"
          },
          "mediaType": {
            "type": "string",
            "enum": [
              "audio",
              "image",
              "video",
              "document"
            ]
          }
        }
      },
      "CreateDeal": {
        "type": "object",
        "properties": {
          "pipelineId": {
            "type": "string"
          },
          "stageId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "contactId": {
            "type": "string"
          },
          "companyId": {
            "type": "string"
          },
          "value": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "probability": {
            "type": "number"
          },
          "expectedClose": {
            "type": "string"
          },
          "ownerId": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": "string"
          },
          "customFields": {
            "type": "object",
            "additionalProperties": true
          },
          "appointmentAt": {
            "type": "string",
            "format": "date-time"
          },
          "productId": {
            "type": "string"
          }
        },
        "required": [
          "pipelineId",
          "stageId",
          "title"
        ]
      },
      "ContactPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Contact"
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "pageSize": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        }
      }
    },
    "responses": {
      "E400": {
        "description": "Corpo ou parâmetro inválido",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E401": {
        "description": "Sem credencial, token inválido/expirado ou chave de API inválida",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E403": {
        "description": "Sem permissão",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E404": {
        "description": "Não encontrado (ou de outro tenant)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E429": {
        "description": "Rate limit — veja Retry-After",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
