Stream global
GET
/v1/eventsdesde M3token adminQuando usar
Server-Sent Events de todas as instâncias (só token admin). Mesmo formato do stream da instância; use instance_id do envelope para separar.
Autenticação
Exige o token admin. Com um token de instância a resposta é 403 forbidden.
Parâmetros
Query
| Nome | Tipo | Descrição |
|---|---|---|
types | string | Filtro separado por vírgulas: tipos exatos (instance.status), famílias (message.*) ou *. Omitido: todos. chat.presence, status.received e channel.message são opt-in: nem * nem a omissão os incluem (use *,chat.presence,status.received). |
Exemplo
curl -sN "$LITEZAP_URL/v1/events" \ -H "Authorization: Bearer $LITEZAP_ADMIN_TOKEN"const res = await fetch("http://localhost:8787/v1/events", { headers: { Authorization: `Bearer ${process.env.LITEZAP_ADMIN_TOKEN}` },});const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();for (;;) { const { value, done } = await reader.read(); if (done) break; process.stdout.write(value); // linhas "id:", "event:" e "data:" (envelope JSON)}import osimport requests
r = requests.get( "http://localhost:8787/v1/events", headers={"Authorization": f"Bearer {os.environ['LITEZAP_ADMIN_TOKEN']}"}, stream=True, timeout=None,)for line in r.iter_lines(decode_unicode=True): if line.startswith("data: "): print(line[6:]) # envelope JSONpackage main
import ( "bufio" "fmt" "net/http" "os")
func main() { req, _ := http.NewRequest("GET", "http://localhost:8787/v1/events", nil) req.Header.Set("Authorization", "Bearer "+os.Getenv("LITEZAP_ADMIN_TOKEN")) resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() sc := bufio.NewScanner(resp.Body) for sc.Scan() { fmt.Println(sc.Text()) // "id:", "event:" e "data:" (envelope JSON) }}<?php$ch = curl_init('http://localhost:8787/v1/events');curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('LITEZAP_ADMIN_TOKEN')], CURLOPT_TIMEOUT => 0, CURLOPT_WRITEFUNCTION => function ($ch, $chunk) { echo $chunk; // linhas "id:", "event:" e "data:" (envelope JSON) return strlen($chunk); },]);curl_exec($ch);Nos exemplos, LITEZAP_URL é a URL base (ex.: http://localhost:8787) e o token vem deLITEZAP_TOKEN (instância) ou LITEZAP_ADMIN_TOKEN.
Resposta
200 Stream text/event-stream. Também: text/event-stream.
retry: 3000: connected
id: evt_0a7d3c9e1f5b2486event: instance.statusdata: {"id":"evt_0a7d3c9e1f5b2486","type":"instance.status","version":1,"instance_id":"inst_7f3a9c2e5b1d4086","timestamp":"2026-10-17T13:40:02.511Z","data":{"state":"connected"}}Erros
| Código | HTTP | Retentável | O que fazer |
|---|---|---|---|
validation_failed | 400 | não | Corrija o corpo ou os parâmetros; a message diz o campo. |
unauthorized | 401 | não | Envie Authorization: Bearer <token> válido. |
forbidden | 403 | não | Use o token certo (admin, ou o da própria instância). |
Todo erro usa o envelope {"error":{"code","message","retryable"}}. Tabela completa em Erros.
Equivalente na Z-API: (sem equivalente). Veja Migrar da Z-API.
Outras operações de Eventos em tempo real: Assinar presença de um contato · Stream da instância

