Skip to main content
Baileys provides comprehensive TypeScript types for working with WhatsApp messages.

Core Message Types

WAMessage

Extends proto.IWebMessageInfo with additional Baileys-specific fields.
key
WAMessageKey
required
Unique identifier for the message
message
WAMessageContent
The actual message content (proto.IMessage)
messageTimestamp
number | Long
Unix timestamp when message was sent
messageStubParameters
any
Parameters for stub messages (system messages)
category
string
Message category classification
retryCount
number
Number of times message delivery has been retried

WAMessageKey

Extends proto.IMessageKey with additional routing information.
remoteJid
string
JID of the chat (group or individual)
fromMe
boolean
Whether the message was sent by you
id
string
Unique message ID
participant
string
Sender’s JID in group chats
remoteJidAlt
string
Alternative JID format (Baileys extension)
participantAlt
string
Alternative participant format (Baileys extension)
server_id
string
Server-assigned ID (Baileys extension)
addressingMode
string
Addressing mode: ‘pn’ or ‘lid’ (Baileys extension)
isViewOnce
boolean
Whether this is a view-once message (Baileys extension)

Message Content Types

AnyMessageContent

Union type for all possible message content:
type AnyMessageContent =
  | AnyRegularMessageContent
  | { forward: WAMessage; force?: boolean }
  | { delete: WAMessageKey }
  | { disappearingMessagesInChat: boolean | number }
  | { limitSharing: boolean }

AnyRegularMessageContent

Union of all regular message types you can send:
{
  text: string
  linkPreview?: WAUrlInfo | null
} & Mentionable & Contextable & Editable
text
string
required
The message text
Link preview metadata
mentions
string[]
Array of mentioned JIDs
contextInfo
proto.IContextInfo
Context info (quoted message, etc.)
edit
WAMessageKey
Key of message to edit
{
  poll: PollMessageOptions
} & Mentionable & Contextable & Editable
{
  contacts: {
    displayName?: string
    contacts: proto.Message.IContactMessage[]
  }
}
{
  location: WALocationMessage
}
{
  react: proto.Message.IReactionMessage
}
{
  buttonReply: ButtonReplyInfo
  type: 'template' | 'plain'
}
{
  pin: WAMessageKey
  type: proto.PinInChat.Type
  time?: 86400 | 604800 | 2592000 // 24h, 7d, or 30d
}

AnyMediaMessageContent

Union type for all media message types:
{
  image: WAMediaUpload
  caption?: string
  jpegThumbnail?: string
  width?: number
  height?: number
  mentions?: string[]
  contextInfo?: proto.IContextInfo
}

WAMediaUpload

Union type for media upload sources:
type WAMediaUpload = 
  | Buffer 
  | { stream: Readable } 
  | { url: URL | string }

Special Message Types

PollMessageOptions

name
string
required
Poll question
values
string[]
required
Array of poll options
selectableCount
number
Number of options users can select (default: 1)
messageSecret
Uint8Array
32-byte secret to encrypt poll selections
toAnnouncementGroup
boolean
Whether poll is for announcement group

EventMessageOptions

name
string
required
Event title
startDate
Date
required
Event start date/time
description
string
Event description
endDate
Date
Event end date/time
location
WALocationMessage
Event location
call
'audio' | 'video'
Type of call event
isCancelled
boolean
Whether event is cancelled
isScheduleCall
boolean
Whether this is a scheduled call
extraGuestsAllowed
boolean
Whether guests can bring +1

Message Generation Options

MessageGenerationOptions

timestamp
Date
Manual message timestamp
quoted
WAMessage
Message to quote/reply to
ephemeralExpiration
number | string
Disappearing message timer
messageId
string
Custom message ID override
mediaUploadTimeoutMs
number
Timeout for media uploads
statusJidList
string[]
JID list for status broadcasts
backgroundColor
string
Background color for status
font
number
Font type for status

Message Updates and Events

MessageUpsertType

type MessageUpsertType = 'append' | 'notify'
  • notify: New message that should trigger a notification
  • append: Historical message being synced, no notification needed

WAMessageUpdate

key
WAMessageKey
required
Key identifying the message to update
update
Partial<WAMessage>
required
Partial message data with updates to apply

MessageUserReceipt

Alias for proto.IUserReceipt containing:
userJid
string
User who sent the receipt
receiptTimestamp
number | Long
When the receipt was sent
readTimestamp
number | Long
When the message was read
playedTimestamp
number | Long
When media was played

Utility Types

DownloadableMessage

Messages that contain downloadable media:
mediaKey
Uint8Array | null
Encryption key for media
directPath
string | null
Direct download path
url
string | null
Download URL

MessageReceiptType

type MessageReceiptType =
  | 'read'
  | 'read-self'
  | 'hist_sync'
  | 'peer_msg'
  | 'sender'
  | 'inactive'
  | 'played'
  | undefined

MinimalMessage

Minimal message data for references:
type MinimalMessage = Pick<WAMessage, 'key' | 'messageTimestamp'>

Example Usage

import { AnyMessageContent } from '@whiskeysockets/baileys'

// Send a text message
const textMsg: AnyMessageContent = {
  text: 'Hello @1234567890',
  mentions: ['[email protected]']
}

// Send an image
const imageMsg: AnyMessageContent = {
  image: { url: 'https://example.com/image.jpg' },
  caption: 'Check this out!',
  mentions: ['[email protected]']
}

// Send a poll
const pollMsg: AnyMessageContent = {
  poll: {
    name: 'What\'s your favorite color?',
    values: ['Red', 'Blue', 'Green'],
    selectableCount: 1
  }
}

// Delete a message
const deleteMsg: AnyMessageContent = {
  delete: messageKey
}

// Forward a message
const forwardMsg: AnyMessageContent = {
  forward: originalMessage,
  force: true
}

Build docs developers (and LLMs) love