📢 Channels

Here’s complete information about WhatsApp Channels (aka Newsletter) and how to use them.

Features

Here’s the list of features that are available by 🏭 Engines:

WEBJSNOWEBGOWS
Search public channels
POST /api/{session}/channels/search/by-view
POST /api/{session}/channels/search/by-text
“Views” for Search
GET /api/{session}/channels/search/views
“Countries” for Search
GET /api/{session}/channels/search/countries
“Categories” for Search
GET /api/{session}/channels/search/categories
Get Messages from Channels (preview)
GET /api/{session}/channels/{invite}/messages/preview
Create Channel
POST /api/{session}/channels
#439✔️✔️
Get channel - by id and invite code
GET /api/{session}/channels/{ChannelID}
✔️✔️✔️
List channels
GET /api/{session}/channels
✔️✔️✔️
Delete channel
DELETE /api/{session}/channels/{ChannelID}
✔️
Get messages
GET /api/{session}/chats/{ChannelID}/messages
✔️✔️
#433
Send messages - Text
POST /api/sendText
✔️✔️✔️
Send messages - Image
POST /api/sendImage
✔️✔️✔️
Send messages - Video
POST /api/sendVideo
✔️✔️✔️
Send messages - Poll
POST /api/sendPoll
Receive messages - Text
message event
✔️✔️✔️
Receive messages - Media
message event
✔️✔️✔️
Receive messages - Polls✔️
Receive messages - Polls Votes (in my channel)
Receive messages - Reactions (in my channel)
Channels - follow, unfollow✔️
Channels - mute, unmute✔️
Admins - Send Invite
Admins - Revoke Invite
Admins - Accept Invite
Admins - Demote Admin

If you see the feature is not available in the above list, please create a feature request or leave “+1” comment on the existing one.


Channels API

💡 Channels have a special @newsletter prefix, so you can distinguish them from regular chats and groups.

  • 123123123@newsletter - channel ID

Get your channels

You can get list of subscribed or owned channels:

  • Get all (your and subscribed) channels GET /api/{session}/channels
  • Filter channels GET /api/{session}/channels?role=OWNER,
    • role can be OWNER, ADMIN, SUBSCRIBER
[
  {
    "id": "111111111111111111@newsletter",
    "name": "Channel - Owner - Picture",
    "description": "Hi there, I'm new here",
    "invite": "https://whatsapp.com/channel/111111111111111111GdZ60l",
    "preview": "https://mmg.whatsapp.net/m1/v/t24/123",
    "picture": "https://mmg.whatsapp.net/m1/v/t24/123",
    "verified": false,
    "role": "OWNER"
  },
  {
    "id": "111111111111111111@newsletter",
    "name": "Channel - Subscriber - No Picture",
    "description": "",
    "invite": "https://whatsapp.com/channel/111111111111111111111111",
    "preview": null,
    "picture": null,
    "verified": false,
    "role": "SUBSCRIBER"
  }
]

Create a new channel

You can create a new channel POST /api/{session}/channels with the payload:

{
  "name": "Channel Name",
  "description": "Channel Description",
  "picture": {
    "mimetype": "image/jpeg",
    "filename": "filename.jpg",
    "url": "https://github.com/devlikeapro/waha/raw/core/examples/dev.likeapro.jpg"
  }
}

Delete a channel

You can delete a channel DELETE /api/{session}/channels/123123%40newsletter (escape @ to %40). Make sure have OWNER role for the channel.

Get channel by Id

You can get a channel by ID GET /api/{session}/channels/123123%40newsletter (escape @ to %40).

{
  "id": "111111111111111111@newsletter",
  "name": "Channel - Owner - Picture",
  "description": "Hi there, I'm new here",
  "invite": "https://whatsapp.com/channel/111111111111111111GdZ60l",
  "preview": "https://mmg.whatsapp.net/m1/v/t24/123",
  "picture": "https://mmg.whatsapp.net/m1/v/t24/123",
  "verified": false,
  "role": "OWNER",
  "subscribersCount": 12323
}

Get channel by Invite Code

You can get a channel by Invite Code GET /api/{session}/channels/{inviteCode}

  • inviteCode here is the last part in invite URL https://whatsapp.com/channel/111111111111111111GdZ60l - 111111111111111111GdZ60l

💡 To get full picture you need to get channel by ID after you get the invite code.

{
  "id": "111111111111111111@newsletter",
  "name": "Channel - Owner - Picture",
  "description": "Hi there, I'm new here",
  "invite": "https://whatsapp.com/channel/111111111111111111GdZ60l",
  "preview": "https://mmg.whatsapp.net/m1/v/t24/123",
  "picture": "https://mmg.whatsapp.net/m1/v/t24/123",
  "verified": false,
  "role": "OWNER"
}

Search API

Search channels by view

You can search public (not subscribed yet) channels by view:

POST /api/{session}/channels/search/by-view

Payload:

{
  "view": "RECOMMENDED",
  "countries": [
    "US"
  ],
  "categories": [],
  "limit": 50,
  "startCursor": ""
}

Response:

{
  "page": {
    "startCursor": null,
    "endCursor": "base64encodedstring",
    "hasNextPage": true,
    "hasPreviousPage": false
  },
  "channels": [
    {
      "id": "123123123123@newsletter",
      "name": "Channel Name",
      "invite": "https://www.whatsapp.com/channel/111111111111111111111111",
      "preview": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
      "picture": "https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10",
      "description": "string",
      "verified": true,
      "subscribersCount": 0
    }
  ]
}

Search channels by text

You can search public (not subscribed yet) channels by text:

POST /api/{session}/channels/search/by-text

Payload:

{
  "text": "Donald Trump",
  "categories": [],
  "limit": 50,
  "startCursor": ""
}
  • text - search text
  • categories - use id from get available categories
  • limit - we recommend using default 50 value, it’s the way official clients work
  • startCursor - use endCursor from the previous response (if any data available on the next page)

Get Search Views

List of available views for search:

GET /api/{session}/channels/search/views

Response:

[
  {
    "value": "RECOMMENDED",
    "name": "Explore"
  }
]

Get Search Countries

List of available countries for search (not full one, you can try different code values if you don’t see your country):

GET /api/{session}/channels/search/countries

Response:

[
  {
    "code": "US",
    "name": "United States"
  }
]

Get Search Categories

List of available categories for search:

GET /api/{session}/channels/search/categories

Response:

[
  {
    "value": "BUSINESS",
    "name": "Business"
  },
  {
    "value": "ENTERTAINMENT",
    "name": "Entertainment"
  }
]

Get Messages (Preview) for Channel

You can get latest messages from public channels (not subscribed yet) by invite code (or channel id). Returns only preview messages (one that you’ll see on channel preview).

GET /api/{SESSION}/channels/{INVITE}/messages/preview?downloadMedia=false&limit=100

Query parameters:

  • {SESSION} - your session
  • {INVITE} - invite code (123123123) or channel id (123132123@newsletter). Invite code is recommended.
  • downloadMedia - whether to download media or not
  • limit - limit of messages to return. 100 is recommended.
[
  {
    "reactions": {
      "👍": 10,
      "❤️": 5
    },
    "viewCount": 0,
    "message": {
      "id": "false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA",
      "timestamp": 1666943582,
      "body": "string",
      "media": {
        ...
      }
    }
  }
]
  • reactions - reactions for the message
  • viewCount - views count for the message
  • message - message object - the same as in payload field message event

How-to

Send Text to the channel

You can use regular POST /api/sendText endpoint to send a text message into the channel

👉 Make sure you’re OWNER or ADMIN for the channel

{
  "session": "default",
  "chatId": "12132132130@newsletter",
  "text": "Hi there!"
}

Send Image to the channel

You can use regular POST /api/sendImage endpoint to send an image into the channel

{
  "session": "default",
  "chatId": "11111111111@newsletter",
  "file": {
    "mimetype": "image/jpeg",
    "url": "https://github.com/devlikeapro/waha/raw/core/examples/dev.likeapro.jpg",
    "filename": "filename.jpeg"
  },
  "caption": "string"
}

Send Video to the channel

You can use regular POST /api/sendVideo endpoint to send a video message into the channel

{
  "chatId": "111111111111111111@newsletter",
  "file": {
    "mimetype": "video/mp4",
    "filename": "video.mp4",
    "url": "https://github.com/devlikeapro/waha/raw/core/examples/video.mp4"
  },
  "caption": "Just watch at this!",
  "session": "default"
}

Get messages from the channel

You can use regular GET /api/{session}/chats/{chatId}/messages to fetch messages from the channel

GET /api/default/chats/123%40newsletter/messages?downloadMedia=true&limit=100
[
  {
    "id": "true_111111111111111111@newsletter_1111111111111111111111",
    "timestamp": 1720775833,
    "from": "111111111111111111@newsletter",
    "fromMe": true,
    "body": "Caption",
    "hasMedia": true,
    "media": {
      "mimetype": "image/jpeg",
      "filename": null,
      "url": "http://localhost:3000/api/files/1111111111111111111111.jpeg",
      "error": null // if there was an error during file download
    },
    "mediaUrl": "http://localhost:3000/api/files/1111111111111111111111.jpeg",
    "ack": 0,
    "ackName": "PENDING",
    "_data": {
      ...
    }
  }
]

Receive messages from the channel

For all incoming messages in your own and subscribed channels you’ll receive

  • message event for a message from the channel (send by someone else)
  • message.any event for a message from the channel ( including your messages)
{
  "event": "message",
  "session": "default",
  "me": {
    "id": "111111111111@c.us",
    "pushName": "Slovakia WAHA"
  },
  "payload": {
    "id": "false_123123@newsletter_11111111111111111111111111111111",
    "timestamp": 1720776511,
    "from": "111111111111111111@newsletter",
    "fromMe": false,
    "body": "How are you all?! ❤️",
    "hasMedia": false,
    "ack": null,
    "ackName": "UNKNOWN",
    "_data": {
      ...
    }
  },
  "engine": "NOWEB",
  "environment": {
    "version": "2024.7.4",
    "engine": "NOWEB",
    "tier": "PLUS",
    "browser": "/usr/bin/google-chrome-stable"
  }
}