Skip to main content

Contact Updated Event

Triggered when a contact's information is updated. This includes changes to name, profile picture, or identifier mappings (JID/LID).

Event Type

contact-updated

Payload Structure

{
"event": "contact-updated",
"instanceId": "instance-uuid",
"data": {
"contact": {
"id": "contact-uuid",
"jid": "[email protected]",
"lid": "LID123@lid",
"name": "John Doe (Updated)",
"profilePictureUrl": "https://new-picture-url...",
"isBusiness": false
},
"updatedFields": ["name", "profilePictureUrl"],
"instanceId": "instance-uuid",
"connectedNumber": "5511999999999",
"timestamp": "2024-12-14T12:00:00.000Z"
}
}

Data Fields

FieldTypeDescription
contactobjectUpdated contact information
updatedFieldsarrayList of fields that were updated
instanceIdstringInstance ID
connectedNumberstringConnected phone number
timestampstringISO 8601 timestamp of the event

Contact Object

FieldTypeDescription
idstringInternal contact ID
jidstring | nullWhatsApp JID ([email protected])
lidstring | nullWhatsApp LID (local identifier)
namestring | nullContact name
profilePictureUrlstring | nullProfile picture URL
isBusinessboolean | undefinedWhether this is a WhatsApp Business account

Updated Fields

The updatedFields array contains the names of fields that changed:

FieldDescription
nameContact name was updated
profilePictureUrlProfile picture changed
jidJID was added or changed
lidLID was added or changed

Common Update Scenarios

Name Change

User changed their WhatsApp display name:

{
"updatedFields": ["name"],
"contact": {
"name": "New Display Name"
}
}

Profile Picture Update

User changed their profile picture:

{
"updatedFields": ["profilePictureUrl"],
"contact": {
"profilePictureUrl": "https://new-url..."
}
}

LID to JID Mapping

WhatsApp revealed the phone number for a LID-only contact:

{
"updatedFields": ["jid"],
"contact": {
"lid": "LID123@lid",
"jid": "[email protected]"
}
}

Example: Handling Updates

app.post('/webhook', async (req, res) => {
const { event, data } = req.body;

if (event === 'contact-updated') {
const { contact, updatedFields } = data;

// Build update object with only changed fields
const updates = {};

if (updatedFields.includes('name')) {
updates.name = contact.name;
}
if (updatedFields.includes('profilePictureUrl')) {
updates.profilePicture = contact.profilePictureUrl;
}
if (updatedFields.includes('jid')) {
updates.phoneNumber = contact.jid?.replace('@s.whatsapp.net', '');
}

// Update in your database
await db.contacts.update(
{ externalId: contact.id },
updates
);

console.log(`Contact ${contact.id} updated: ${updatedFields.join(', ')}`);
}

res.status(200).send('OK');
});