Canais

Canais (newsletters): criar, seguir e buscar.

Basehttps://app.onzap.io/v1/instances/{instanceId}AuthX-Instance-Token: SEU_TOKEN

Listar canais conhecidos

GET/v1/instances/{instanceId}/channels
API OnZap

Parâmetros de query

rolestringopcional
Requisição
curl "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta
[
  {
    "description": "Atendimento de segunda a sexta, das 9h às 18h.",
    "id": "123123123123@newsletter",
    "invite": "https://www.whatsapp.com/channel/111111111111111111111111",
    "name": "Channel Name",
    "picture": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
    "preview": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
    "role": "OWNER",
    "subscribersCount": 0,
    "verified": false
  }
]

Criar canal

POST/v1/instances/{instanceId}/channels
API OnZap

Corpo (JSON)

namestringobrigatório
descriptionstringopcional
pictureobjectopcional
Requisição
curl -X POST "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels" \
  -H "X-Instance-Token: $ONZAP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Channel Name"
  }'
Resposta
{
  "description": "Atendimento de segunda a sexta, das 9h às 18h.",
  "id": "123123123123@newsletter",
  "invite": "https://www.whatsapp.com/channel/111111111111111111111111",
  "name": "Channel Name",
  "picture": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
  "preview": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
  "role": "OWNER",
  "subscribersCount": 0,
  "verified": false
}

Buscar canais por visão

POST/v1/instances/{instanceId}/channels/search/by-view
API OnZap

Corpo (JSON)

categoriesarray de stringobrigatório
countriesarray de stringobrigatório
limitnumberobrigatório
startCursorstringobrigatório
viewstringobrigatório
Requisição
curl -X POST "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/search/by-view" \
  -H "X-Instance-Token: $ONZAP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "categories": [],
    "countries": [
      "US"
    ],
    "limit": 50,
    "startCursor": "",
    "view": "RECOMMENDED"
  }'
Resposta
{
  "channels": [
    {
      "description": "Atendimento de segunda a sexta, das 9h às 18h.",
      "id": "123123123123@newsletter",
      "invite": "https://www.whatsapp.com/channel/111111111111111111111111",
      "name": "Channel Name",
      "picture": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
      "preview": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
      "subscribersCount": 0,
      "verified": false
    }
  ],
  "page": {
    "endCursor": "eyJvZmZzZXQiOjUwfQ",
    "hasNextPage": false,
    "hasPreviousPage": false,
    "startCursor": "eyJvZmZzZXQiOjB9"
  }
}

Buscar canais por texto

POST/v1/instances/{instanceId}/channels/search/by-text
API OnZap

Corpo (JSON)

categoriesarray de stringobrigatório
limitnumberobrigatório
startCursorstringobrigatório
textstringobrigatório
Requisição
curl -X POST "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/search/by-text" \
  -H "X-Instance-Token: $ONZAP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "categories": [],
    "limit": 50,
    "startCursor": "",
    "text": "Donald Trump"
  }'
Resposta
{
  "channels": [
    {
      "description": "Atendimento de segunda a sexta, das 9h às 18h.",
      "id": "123123123123@newsletter",
      "invite": "https://www.whatsapp.com/channel/111111111111111111111111",
      "name": "Channel Name",
      "picture": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
      "preview": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
      "subscribersCount": 0,
      "verified": false
    }
  ],
  "page": {
    "endCursor": "eyJvZmZzZXQiOjUwfQ",
    "hasNextPage": false,
    "hasPreviousPage": false,
    "startCursor": "eyJvZmZzZXQiOjB9"
  }
}

Visões disponíveis para busca

GET/v1/instances/{instanceId}/channels/search/views
API OnZap
Requisição
curl "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/search/views" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta
[
  {
    "name": "Recomendados",
    "value": "RECOMMENDED"
  }
]

Países disponíveis para busca

GET/v1/instances/{instanceId}/channels/search/countries
API OnZap
Requisição
curl "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/search/countries" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta
[
  {
    "code": "ABCD-EFGH",
    "name": "Brasil"
  }
]

Categorias disponíveis para busca

GET/v1/instances/{instanceId}/channels/search/categories
API OnZap
Requisição
curl "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/search/categories" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta
[
  {
    "name": "Negócios",
    "value": "BUSINESS"
  }
]

Dados do canal

GET/v1/instances/{instanceId}/channels/{channelId}
API OnZap

Parâmetros do caminho

channelIdanyobrigatório
WhatsApp Channel ID or invite code from invite link https://www.whatsapp.com/channel/11111
Requisição
curl "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/120363000000000000@newsletter" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta
{
  "description": "Atendimento de segunda a sexta, das 9h às 18h.",
  "id": "123123123123@newsletter",
  "invite": "https://www.whatsapp.com/channel/111111111111111111111111",
  "name": "Channel Name",
  "picture": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
  "preview": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
  "role": "OWNER",
  "subscribersCount": 0,
  "verified": false
}

Prévia das mensagens do canal

GET/v1/instances/{instanceId}/channels/{channelId}/messages/preview
API OnZap

Parâmetros do caminho

channelIdanyobrigatório
Channel id or invite code

Parâmetros de query

downloadMediabooleanobrigatório
limitnumberobrigatório
Requisição
curl "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/120363000000000000@newsletter/messages/preview?downloadMedia=VALOR&limit=VALOR" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta
[
  {
    "message": {
      "_data": {},
      "ack": -1,
      "ackName": "READ",
      "author": "5521988887777@c.us",
      "body": "Olá! Seu pedido foi confirmado.",
      "from": "5511999999999@c.us",
      "fromMe": false,
      "hasMedia": false,
      "id": "false_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAA",
      "location": {
        "address": "Av. Paulista, 1000 - São Paulo, SP",
        "description": "Atendimento de segunda a sexta, das 9h às 18h.",
        "latitude": "-23.5613",
        "live": false,
        "longitude": "-46.6565",
        "name": "Loja Centro",
        "thumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD…",
        "url": "https://exemplo.com.br/arquivos/pedido.jpg"
      },
      "media": {
        "error": {},
        "filename": "example.pdf",
        "mimetype": "audio/jpeg",
        "url": "https://app.onzap.io/v1/files/i01jabcdefghjkmnpqrstvwxyz/false_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAA.oga?exp=1767229200&sig=…"
      },
      "mediaUrl": "https://app.onzap.io/v1/files/i01jabcdefghjkmnpqrstvwxyz/false_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAA.oga?exp=1767229200&sig=…",
      "participant": "5521988887777@c.us",
      "replyTo": {
        "_data": {},
        "body": "Hello!",
        "hasMedia": false,
        "id": "AAAAAAAAAAAAAAAAAAAA",
        "media": {},
        "participant": "5511999999999@c.us"
      },
      "source": "api",
      "timestamp": 1666943582,
      "to": "5511999999999@c.us",
      "vCards": [
        "texto"
      ]
    },
    "reactions": {
      "❤️": 5,
      "👍": 10
    },
    "viewCount": 0
  }
]

Seguir canal

POST/v1/instances/{instanceId}/channels/{channelId}/follow
API OnZap

Parâmetros do caminho

channelIdanyobrigatório
WhatsApp Channel ID
Requisição
curl -X POST "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/120363000000000000@newsletter/follow" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta

Sucesso

Deixar de seguir canal

POST/v1/instances/{instanceId}/channels/{channelId}/unfollow
API OnZap

Parâmetros do caminho

channelIdanyobrigatório
WhatsApp Channel ID
Requisição
curl -X POST "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/120363000000000000@newsletter/unfollow" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta

Sucesso

Silenciar canal

POST/v1/instances/{instanceId}/channels/{channelId}/mute
API OnZap

Parâmetros do caminho

channelIdanyobrigatório
WhatsApp Channel ID
Requisição
curl -X POST "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/120363000000000000@newsletter/mute" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta

Sucesso

Reativar notificações do canal

POST/v1/instances/{instanceId}/channels/{channelId}/unmute
API OnZap

Parâmetros do caminho

channelIdanyobrigatório
WhatsApp Channel ID
Requisição
curl -X POST "https://app.onzap.io/v1/instances/SUA_INSTANCIA/channels/120363000000000000@newsletter/unmute" \
  -H "X-Instance-Token: $ONZAP_TOKEN"
Resposta

Sucesso