# Pesquisar canais públicos

POST /newsletter/search

Pesquisa canais/newsletters públicos no diretório do WhatsApp pelo texto.

Observações:
- `searchText` é obrigatório: o WhatsApp só pesquisa o diretório por texto
- sem `searchText`, a API responde 400 antes de chamar o WhatsApp
- não há filtro por país nem listagem por categoria: o WhatsApp recusa busca sem texto, com filtro de país ou por `view`
- use `after` com o valor de `response.after` para buscar a próxima página
- quando `response.after` vier `null`, não há mais páginas


## Autenticação

```json
[
  {
    "token": []
  }
]
```

```json
{
  "token": {
    "name": "token",
    "type": "apiKey",
    "in": "header"
  }
}
```

## Corpo da requisição

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "required": [
          "searchText"
        ],
        "properties": {
          "searchText": {
            "type": "string",
            "minLength": 1,
            "description": "Texto pesquisado no diretório de canais.",
            "example": "promo"
          },
          "limit": {
            "type": "integer",
            "example": 20
          },
          "after": {
            "type": "string",
            "description": "Cursor da próxima página, vindo de `response.after`. A API também aceita os apelidos `cursor`, `startCursor` e `start_cursor`.",
            "example": "YXJyYXljb25uZWN0aW9uOjE5"
          }
        }
      }
    }
  }
}
```

## Respostas

```json
{
  "200": {
    "description": "Pesquisa executada com sucesso",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "response"
          ],
          "properties": {
            "response": {
              "type": "object",
              "properties": {
                "after": {
                  "type": "string",
                  "nullable": true,
                  "example": "YXJyYXljb25uZWN0aW9uOjIw"
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "400": {
    "description": "Payload inválido ou `searchText` ausente",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "example": "searchText is required: WhatsApp only searches the channel directory by text"
            }
          }
        }
      }
    }
  },
  "401": {
    "description": "Instância não autenticada ou cliente não encontrado",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "example": "client not found"
            }
          }
        }
      }
    }
  },
  "500": {
    "description": "Erro interno ao pesquisar canais",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "example": "connection closed"
            }
          }
        }
      }
    }
  }
}
```

## Guias relacionados

[Autenticação](/docs/authentication) · [Erros e retries](/docs/errors-and-retries) · [Server URL](/docs/server-url)
