Description
A WhatsApp channel publishes messages to its followers. Only the admins of the channel publish. The followers read and react. The channel routes are available only for instances connected by QR Code. An instance of a different type receives422 with the code
UNSUPPORTED_FOR_INSTANCE_TYPE.
Operations
The API supports these operations on channels:- List the channels the number follows or administers.
- Create a channel.
- Get a channel by its id or by its invite link.
- Follow and unfollow a channel.
- Mute and unmute a channel.
- Change the name, the description, and the photo of a channel.
- Delete a channel.
- List the followers of a channel.
- Invite and remove admins, and transfer the channel.
- Send messages, polls, and questions to a channel.
- Pin a message and react to a message of a channel.
- Get the insights of a channel.
- Receive the messages of the channels the number follows.
Channel identification
A channel has an id with the suffix@newsletter, for example
120363012345678901@newsletter. The routes accept the id with or without the
suffix.
A channel also has an invite code, in inviteCode. The invite link is
https://whatsapp.com/channel/<inviteCode>.
Channel data
The routes return the channel with these fields:
The query by invite link does not give
mute, role, or picture.
Create a channel
POST /{instanceId}/newsletters
Give the name in name and, if necessary, the description in description.
The connected number is the owner of the channel. The response contains the
channel data in newsletter.
Get a channel
GET /{instanceId}/newsletters/{newsletterId} gets a channel that the number
follows or administers.
GET /{instanceId}/newsletters/invite-info?invite=<link> gets any channel by
its invite link. Use this route to get the id of a channel that the number does
not follow.
Follow and mute
POST /{instanceId}/newsletters/{newsletterId}/followfollows the channel.POST /{instanceId}/newsletters/{newsletterId}/unfollowunfollows the channel.PUT /{instanceId}/newsletters/{newsletterId}/mutemutes the channel with"mute": trueand unmutes it with"mute": false.
204, with no body.
WhatsApp mutes the channel when the number starts to follow it. To receive the
notifications on the phone, unmute the channel.
Change the name, the description, and the photo
PATCH /{instanceId}/newsletters/{newsletterId} changes name, description,
or the two. A field that you do not send does not change. An empty string in
description removes the description.
PATCH /{instanceId}/newsletters/{newsletterId}/picture changes the photo. Give
in picture the URL or the Base64 of a square JPEG image, 640x640 pixels.
DELETE /{instanceId}/newsletters/{newsletterId}/picture removes the photo.
The three routes respond 204, with no body. The number must be an admin of the
channel.
Delete a channel
DELETE /{instanceId}/newsletters/{newsletterId} deletes the channel. Only the
owner of the channel can delete it. The API responds 204, with no body.
Followers
GET /{instanceId}/newsletters/{newsletterId}/followers lists the followers of
the channel. The number must be the owner or an admin of the channel. Use
limit to set the maximum number of followers, from 1 to 1000. The default is
100.
Each follower has these fields:
Admins
The owner of the channel invites followers to be admins. In the routes below,user is the phone number with the country code, or the LID with the suffix
@lid.
The query returns the number of admins in
adminCount and the invites that are
not accepted in pendingInvites. To know who the admins are, list the followers
and use the role field.
Invite an admin
Give the user inuser and, if necessary, a text in message. The API creates
the invite and sends the invite message in the private chat of the user. The
user accepts the invite on WhatsApp.
The response contains the expiry time of the invite in expiresAt and the
messageSent field.
With
messageSent set to false, the invite exists, but the user did not
receive the message. Send the invite again or revoke the invite.Accept an invite
When the connected number receives an admin invite, it accepts the invite withPOST /{instanceId}/newsletters/{newsletterId}/admins/accept.
Transfer the channel
SendPUT /{instanceId}/newsletters/{newsletterId}/owner with an admin of the
channel in user. The API responds 204, with no body.
Send messages to a channel
Use the message sending routes with the channel id as the recipient. The number must be an admin of the channel.Poll and quiz
POST /{instanceId}/newsletters/{newsletterId}/polls publishes a poll.
optionsaccepts from 2 to 12 options, with no repetition.- With
singleChoiceset totrue, each follower chooses only one option. - With
correctOption, the poll is a quiz.correctOptionis the position of the correct option inoptions, starting at 0. A quiz is always single choice.
id and the serverId of the message.
Question
POST /{instanceId}/newsletters/{newsletterId}/questions publishes a question.
Give the text in text. The followers answer the question on WhatsApp.
The response contains the id and the serverId of the message.
WhatsApp decides in which channels the quiz and the question are available.
When WhatsApp rejects the publication, the API responds
422 with the code
PROVIDER_REJECTED.Pin a message
PUT /{instanceId}/newsletters/{newsletterId}/messages/{serverId}/pinpins the message at the top of the channel.DELETE /{instanceId}/newsletters/{newsletterId}/messages/{serverId}/pinunpins the message.
serverId is the server id of the message. The two routes return in
pinnedMessages the messages that stay pinned after the operation.
Receive messages from a channel
The instance delivers the channel messages only with thereceiveNewsletterMessages option on. The option is off by default.
- Send
POST /{instanceId}/settingswith"receiveNewsletterMessages": truein themessagesblock. - Subscribe to the
messages.upsertevent in the webhook.
messages.upsert event. The channel id is
in key.remoteJid, and the server id of the message is in serverId. A message
that the number itself published on a different device, such as the phone,
arrives with key.fromMe set to true. Refer to
the payload example.
The channel message goes only to the webhook. It does not go to the
message log, to Chatwoot, or to the AI agent.
React to a channel message
SendPOST /{instanceId}/messages/react with the channel id in remoteJid and
the serverId of the message:
text removes the reaction. Without serverId, the API
responds 400.
Events
The webhook receives these channel events, when you subscribe to them:
Refer to the payload examples.
Insights
GET /{instanceId}/newsletters/{newsletterId}/insights returns the audience
metrics of the channel in the last 30 days. The number must be the owner or an
admin of the channel.
A metric that WhatsApp does not give is absent from the response. The lists
come empty.
WhatsApp gives the insights only for channels with a minimum number of
followers. For a channel without the minimum, the API responds
422 with the
code PROVIDER_REJECTED.Rejection by WhatsApp
When WhatsApp rejects the operation, the API responds422 with the code
PROVIDER_REJECTED. The reason is in detail. Examples of rejection:
- The channel does not exist or was deleted.
- The number gets by id a channel that it does not follow.
- The number changes or deletes a channel that it does not administer.
- The photo is not a square JPEG.
- The number invites or removes an admin of a channel that it does not own.