Command Palette

Search for a command to run...

Discord

Last edited April 2, 2026

Contacts

Query contact entities safely, enrich profile context, and validate recipients before messaging.

Contact data model

A contact object provides identity and profile fields used for routing, moderation, and personalization.

Fetch All Contacts

const contacts = await client.getContacts()
console.log(`${contacts.length} contacts found`)

Get a Contact by ID

const contact = await client.getContactById('15551234567@c.us')
console.log(contact.name || contact.pushname || contact.number)

Contact Properties

PropertyDescription
contact.idUnique contact identifier
contact.numberPhone number without formatting
contact.nameName saved in the app's address book
contact.pushnameName the contact set on their own account
contact.isMetrue if this is the app's own contact
contact.isUsertrue for individual (non-group) contacts
contact.isGrouptrue for group contacts
contact.isBusinesstrue for WhatsApp Business accounts
contact.isBlockedtrue if the contact is blocked
contact.isWAContacttrue if the number is registered on WhatsApp

Get Profile Picture

const contact = await client.getContactById('15551234567@c.us')
const url = await contact.getProfilePicUrl()

if (url) {
  console.log('Profile picture:', url)
} else {
  console.log('No profile picture available')
}

Get Status / About

const about = await contact.getAbout()
console.log('Status:', about)

Open the Chat with a Contact

const contact = await client.getContactById('15551234567@c.us')
const chat = await contact.getChat()
await chat.sendMessage('Hello!')

Check if a Number is Registered

Before sending a message, verify the number exists on WhatsApp:

Validation pattern for outbound messaging

async function safeSend(client, id, text) {
  const registered = await client.isRegisteredUser(id)
  if (!registered) return false

  await client.sendMessage(id, text)
  return true
}

Operational recommendations

  1. Validate recipient IDs before sending high volume messages.
  2. Do not rely only on name, use stable IDs for logic.
  3. Treat profile fields as mutable user data.
const isRegistered = await client.isRegisteredUser('15551234567@c.us')

if (isRegistered) {
  await client.sendMessage('15551234567@c.us', 'Hi there!')
} else {
  console.log('This number is not on WhatsApp')
}

Block a Contact

const contact = await client.getContactById('15551234567@c.us')
await contact.block()

Unblock a Contact

await contact.unblock()

Get All Blocked Contacts

const blocked = await client.getBlockedContacts()
blocked.forEach(c => console.log('Blocked:', c.number))