lead object, so any of them can create or update the contact.
1
Create the endpoint
Register the URL of your integration with the four lead events, and store the
secret from the response.2
Accept each delivery once
Verify the signature, skip any
X-Webhook-Delivery you already processed and respond with a 2xx within 10 seconds.3
Find or create the contact
Do this on every event, so that a missed
lead.created does not leave a contact out of the CRM.- Search by
lead.contact_id, stored in a custom field of the contact. - If nothing matches, search by
lead.phoneorlead.email, so you do not duplicate someone who was already in the CRM. - If the contact still does not exist, create it. Save
lead.contact_idin the custom field.
4
Apply each event
Without webhooks: poll for changes
If your integration cannot receive webhooks, ask for the leads with new activity every few minutes. Keep the time of each poll, and start the next one a few minutes earlier, so a lead that changed while you were polling is not missed.last_activity_at changes with every message in the conversation, sent or received, and when a call starts on that lead. A new lead starts with its creation time, so it also matches. Editing a lead does not change it. A voice agent’s phone calls belong to its own leads: poll them with voice_agent_id. Follow next_cursor until has_more is false: results are ordered by creation date, not by activity.
Webhooks are still the better option: they arrive within seconds and include what changed.