merge-contacts.js
Uses the Front POST /contacts/merge API endpoint see docs to merge multiple contacts into a single contact record.
Installation
- Save the
merge-contacts.jsfile to your local machine. - Navigate to the directory you saved it.
- Run
npm install axiosto install the Axios HTTP client - Edit the
merge-contacts.jsfile to save your Front API token - Edit the
merge-contacts.jsfile to save your list of contacts to merge. - When setup is complete, run
node merge-contacts.jsto execute the file. Progress will be printed to your terminal in real-time.
You should save the contacts as an array of arrays, with the primary contact listed first in each array.
Using the example provided in the code;
const emailArrays = [
['[email protected]', '[email protected]', '[email protected]'],
['[email protected]', '[email protected]'],
['[email protected]', '[email protected]'],
]
For the first record, handles '[email protected]' and '[email protected]' will be merged into the '[email protected]' contact record.