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
},
"instanceId": "instance-uuid",
"connectedNumber": "5511999999999",
"timestamp": "2024-12-14T12:00:00.000Z"
}
}

Data Fields​

FieldTypeDescription
contactobjectUpdated contact information
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) - primary identifier
namestring | nullContact name
profilePictureUrlstring | nullProfile picture URL
isBusinessboolean | undefinedWhether this is a WhatsApp Business account

Common Update Scenarios​

Name Change​

User changed their WhatsApp display name.

Profile Picture Update​

User changed their profile picture.

LID to JID Mapping Discovery​

WhatsApp revealed the phone number for a LID-only contact. This is a common scenario when:

  1. A contact initially only had a LID (privacy-preserving identifier)
  2. WhatsApp later maps the LID to a phone number (JID)
  3. The contact is updated with both identifiers
{
"contact": {
"lid": "LID123@lid",
"jid": "[email protected]",
"name": "Contact Name"
}
}

Understanding JID and LID​

WhatsApp uses two types of identifiers:

  • LID (Local ID): The newer, primary identifier used by WhatsApp. LID is prioritized in ZapyAPI.
  • JID (Jabber ID): The traditional identifier based on phone number (e.g., [email protected]).
LID Priority

LID is the primary identifier in ZapyAPI. When WhatsApp reveals a phone number for a LID-only contact, both identifiers will be available in the updated contact.

Example: Handling Updates​

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

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

// Update in your database using the stable contact ID
await db.contacts.update(
{ externalId: contact.id },
{
name: contact.name,
profilePicture: contact.profilePictureUrl,
phoneNumber: contact.jid?.replace('@s.whatsapp.net', ''),
lid: contact.lid,
isBusiness: contact.isBusiness
}
);

console.log(`Contact ${contact.id} updated: ${contact.name}`);
}

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