1. Back-fill existing records
Page through every list withlimit=100. Stop when offset >= count.
id rather than inserting blindly.
2. Subscribe to changes
In OutReign open Settings → Webhooks, add your HTTPS endpoint and selectlead.created, lead.updated, lead.deleted, deal.created, deal.updated, deal.stage_changed and deal.closed. See webhook events for payloads and security and retries to verify signatures.
upsertIntoCrm, upsertDealIntoCrm, enqueueDurablyOnce, app and express are your integration’s adapter/framework functions, not OutReign SDK exports. A separate worker consumes accepted events: handle deletion by ID and fetch current records when an event contains only partial stage-change data. Do not acknowledge first and then risk losing an in-memory task.
3. Write back from the CRM
Push changes into OutReign withPATCH /leads/{id} or PATCH /deals/{id}. Lead, deal and activity updates normalize the whole record, so read the record first and send back the values you want to keep. Contact updates only change the fields you send.