Skip to main content
This page documents all chat-related methods available in the Baileys WhatsApp API.

Chat Modification

chatModify

Modify chat settings such as archive, pin, mute, mark read, etc.
mod
ChatModification
required
The modification to apply (see examples below)
jid
string
required
The chat JID (use empty string for global settings)
return
Promise<void>
Applies the modification via app state patch

Archive/Unarchive Chat

// Archive chat
await sock.chatModify(
  {
    archive: true,
    lastMessages: [lastMessage]
  },
  '[email protected]'
)

// Unarchive chat
await sock.chatModify(
  {
    archive: false,
    lastMessages: [lastMessage]
  },
  '[email protected]'
)

Pin/Unpin Chat

// Pin chat
await sock.chatModify({ pin: true }, '[email protected]')

// Unpin chat
await sock.chatModify({ pin: false }, '[email protected]')

Mute/Unmute Chat

// Mute for 8 hours
await sock.chatModify(
  { mute: 8 * 60 * 60 * 1000 },
  '[email protected]'
)

// Unmute
await sock.chatModify(
  { mute: null },
  '[email protected]'
)

Mark Read/Unread

// Mark as read
await sock.chatModify(
  {
    markRead: true,
    lastMessages: [lastMessage]
  },
  '[email protected]'
)

// Mark as unread
await sock.chatModify(
  {
    markRead: false,
    lastMessages: [lastMessage]
  },
  '[email protected]'
)

Clear Chat

await sock.chatModify(
  {
    clear: true,
    lastMessages: [lastMessage]
  },
  '[email protected]'
)

Delete Chat

await sock.chatModify(
  {
    delete: true,
    lastMessages: [lastMessage]
  },
  '[email protected]'
)

Message Operations

readMessages

Mark messages as read.
keys
WAMessageKey[]
required
Array of message keys to mark as read
await sock.readMessages([{
  remoteJid: '[email protected]',
  id: 'MESSAGE_ID',
  fromMe: false
}])

star

Star or unstar messages.
jid
string
required
The chat JID
messages
Array<{ id: string, fromMe?: boolean }>
required
Array of message identifiers
star
boolean
required
Whether to star (true) or unstar (false)
// Star messages
await sock.star(
  '[email protected]',
  [{ id: 'MESSAGE_ID', fromMe: false }],
  true
)

// Unstar messages
await sock.star(
  '[email protected]',
  [{ id: 'MESSAGE_ID', fromMe: false }],
  false
)

Presence Management

sendPresenceUpdate

Update your presence status in a chat.
type
WAPresence
required
Presence type: 'unavailable', 'available', 'composing', 'recording', or 'paused'
toJid
string
The chat JID (required for composing/recording/paused states)
// Set as available (online)
await sock.sendPresenceUpdate('available')

// Set as unavailable (offline)
await sock.sendPresenceUpdate('unavailable')

// Show typing indicator
await sock.sendPresenceUpdate('composing', '[email protected]')

// Show recording indicator
await sock.sendPresenceUpdate('recording', '[email protected]')

// Stop typing/recording
await sock.sendPresenceUpdate('paused', '[email protected]')

presenceSubscribe

Subscribe to presence updates for a user.
toJid
string
required
The user JID to subscribe to
await sock.presenceSubscribe('[email protected]')

// Listen for presence updates
sock.ev.on('presence.update', ({ id, presences }) => {
  console.log('Presence update for', id)
  for (const [participant, presence] of Object.entries(presences)) {
    console.log(participant, 'is', presence.lastKnownPresence)
  }
})

Profile Management

updateProfilePicture

Update your profile picture or a group’s picture.
jid
string
required
Your JID or the group JID
content
WAMediaUpload
required
The image file (Buffer, path, or URL)
dimensions
{ width: number, height: number }
Optional dimensions for the image
import { readFileSync } from 'fs'

// Update your profile picture
await sock.updateProfilePicture(
  sock.user.id,
  readFileSync('./profile.jpg')
)

// Update group picture
await sock.updateProfilePicture(
  '[email protected]',
  readFileSync('./group.jpg')
)

removeProfilePicture

Remove your profile picture or a group’s picture.
jid
string
required
Your JID or the group JID
await sock.removeProfilePicture(sock.user.id)

updateProfileStatus

Update your profile status/about.
status
string
required
The new status text
await sock.updateProfileStatus('Hey there! I am using WhatsApp.')

updateProfileName

Update your profile name.
name
string
required
The new profile name
await sock.updateProfileName('John Doe')

profilePictureUrl

Fetch the profile picture URL for a user or group.
jid
string
required
The user or group JID
type
'preview' | 'image'
default:"preview"
  • preview: Low resolution picture
  • image: High resolution picture
timeoutMs
number
Optional timeout in milliseconds
return
Promise<string | undefined>
Returns the profile picture URL
// Get preview (low-res)
const previewUrl = await sock.profilePictureUrl('[email protected]')

// Get full image (high-res)
const imageUrl = await sock.profilePictureUrl(
  '[email protected]',
  'image'
)

Status & Business

fetchStatus

Fetch the status/about of one or more users.
jids
string[]
required
Array of user JIDs
return
Promise<Array>
Returns array of status information
const statuses = await sock.fetchStatus(
  '[email protected]',
  '[email protected]'
)

getBusinessProfile

Get the business profile for a WhatsApp Business account.
jid
string
required
The business account JID
return
Promise<WABusinessProfile | void>
Returns the business profile with:
  • wid: WhatsApp ID
  • description: Business description
  • website: Website URLs
  • email: Contact email
  • category: Business category
  • address: Business address
  • business_hours: Operating hours
const profile = await sock.getBusinessProfile('[email protected]')
if (profile) {
  console.log('Business:', profile.description)
  console.log('Website:', profile.website)
}

Contacts

addOrEditContact

Add or update a contact.
jid
string
required
The contact JID
contact
proto.SyncActionValue.IContactAction
required
The contact information
await sock.addOrEditContact(
  '[email protected]',
  {
    fullName: 'John Doe',
    firstName: 'John'
  }
)

removeContact

Remove a contact.
jid
string
required
The contact JID
await sock.removeContact('[email protected]')

Labels

addLabel

Create a new label.
jid
string
required
Empty string for creating labels
labels
LabelActionBody
required
The label information
await sock.addLabel('', {
  name: 'Important',
  color: 0,
  predefinedId: '1'
})

addChatLabel

Add a label to a chat.
jid
string
required
The chat JID
labelId
string
required
The label ID to add
await sock.addChatLabel('[email protected]', 'LABEL_ID')

removeChatLabel

Remove a label from a chat.
jid
string
required
The chat JID
labelId
string
required
The label ID to remove
await sock.removeChatLabel('[email protected]', 'LABEL_ID')

addMessageLabel

Add a label to a message.
jid
string
required
The chat JID
messageId
string
required
The message ID
labelId
string
required
The label ID to add
await sock.addMessageLabel(
  '[email protected]',
  'MESSAGE_ID',
  'LABEL_ID'
)

removeMessageLabel

Remove a label from a message.
jid
string
required
The chat JID
messageId
string
required
The message ID
labelId
string
required
The label ID to remove
await sock.removeMessageLabel(
  '[email protected]',
  'MESSAGE_ID',
  'LABEL_ID'
)

Quick Replies

addOrEditQuickReply

Add or edit a quick reply message.
quickReply
QuickReplyAction
required
The quick reply data
await sock.addOrEditQuickReply({
  shortcut: '/hello',
  message: 'Hello! How can I help you?',
  timestamp: Date.now().toString()
})

removeQuickReply

Remove a quick reply.
timestamp
string
required
The timestamp of the quick reply to remove
await sock.removeQuickReply('1234567890')

Utilities

fetchDisappearingDuration

Fetch the default disappearing message duration for users.
jids
string[]
required
Array of user JIDs
return
Promise<Array>
Returns array of disappearing message settings
const durations = await sock.fetchDisappearingDuration(
  '[email protected]'
)

updateDefaultDisappearingMode

Update your default disappearing message duration.
duration
number
required
Duration in seconds (0 to disable)
// Enable 7-day disappearing messages by default
await sock.updateDefaultDisappearingMode(604800)

// Disable
await sock.updateDefaultDisappearingMode(0)

updateDisableLinkPreviewsPrivacy

Enable or disable link previews.
isPreviewsDisabled
boolean
required
Whether to disable link previews
// Disable link previews
await sock.updateDisableLinkPreviewsPrivacy(true)

// Enable link previews
await sock.updateDisableLinkPreviewsPrivacy(false)

cleanDirtyBits

Clean dirty bits for account sync or groups.
type
'account_sync' | 'groups'
required
The type of dirty bits to clean
fromTimestamp
number | string
Optional timestamp to clean from
await sock.cleanDirtyBits('account_sync')

Build docs developers (and LLMs) love