Create the function
Add a file under the integration’ssyncs/ folder:
crm/syncs/contacts.ts
index.ts:
index.ts
For agents
For agents
Before generating a sync, collect the integration ID, connection ID for testing, target records, provider pagination style, incremental filter, deletion strategy, required metadata, and expected sync frequency.Prefer incremental syncs when the provider supports them. Save records page by page, checkpoint after successful writes, and keep the record model limited to fields the app actually needs.
Pass parameters with metadata
Use connection metadata for any value the sync needs on scheduled runs:- Customer configuration, such as selected folders, projects, accounts, regions, or custom field mappings.
- Provider context discovered after authorization.
- Feature flags or filters that change what the sync fetches.
autoStart: false, save the required metadata from your app, then start the schedule after configuration is complete.
From your app, call the Node SDK nango.startSync() method:
Test and deploy
Dry run the function against a real connection:Start or trigger runs
IfautoStart: true, Nango starts the schedule for new connections automatically. Otherwise, start it after the connection is ready and required metadata is saved:
nango.startSync() is a Node SDK method. Use the Start sync API if you are starting schedules from another backend language.
Trigger a run immediately:
nango.triggerSync() is a Node SDK method. Use the Trigger sync API for one-off sync runs from another backend language.
Consume records
Configure your app’s Nango webhook URL in Environment Settings > Webhook URLs. After a run, Nango sends a sync webhook with the connection, integration, sync name, model, and change counts. Your app should then read records by cursor:- TypeScript
- cURL
Two-way syncs
You can implement two-way syncs by combining sync functions with action functions:- Use a sync function to replicate external data into your app and keep your local state fresh.
- Use action functions for writes back to the external API, such as creating, updating, or deleting records.
- After a write action succeeds, update your local state optimistically or trigger the relevant sync so the records cache catches up with the external source of truth.