Skip to main content

Contact Created Event

Triggered when a new contact is discovered on your WhatsApp instance. This happens when you receive a message from a new number or when WhatsApp syncs contact information.

Event Type

contact-created

Payload Structure

{
"event": "contact-created",
"instanceId": "instance-uuid",
"data": {
"contact": {
"id": "contact-uuid",
"jid": "[email protected]",
"lid": null,
"name": "John Doe",
"profilePictureUrl": "https://...",
"isBusiness": false
},
"instanceId": "instance-uuid",
"connectedNumber": "5511999999999",
"timestamp": "2024-12-14T12:00:00.000Z"
}
}

Data Fields

FieldTypeDescription
contactobjectContact 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)
namestring | nullContact name (from WhatsApp or address book)
profilePictureUrlstring | nullProfile picture URL
isBusinessboolean | undefinedWhether this is a WhatsApp Business account

Understanding JID and LID

  • JID (Jabber ID): The traditional WhatsApp identifier based on phone number (e.g., [email protected])
  • LID (Local ID): A newer identifier used by WhatsApp for privacy. Some contacts may only have a LID initially.
info

When a contact has only a LID, the phone number may be revealed later when WhatsApp maps the LID to a phone number. This triggers a contact-updated event.

Example: Syncing Contacts

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

if (event === 'contact-created') {
const { contact, instanceId } = data;

// Save to your database
await db.contacts.create({
externalId: contact.id,
instanceId,
phoneNumber: contact.jid?.replace('@s.whatsapp.net', ''),
name: contact.name,
profilePicture: contact.profilePictureUrl,
isBusiness: contact.isBusiness || false
});

console.log(`New contact: ${contact.name || contact.jid}`);
}

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