This Node.js application allows you to execute a few scripts to migrate data from one Sendgrid account to another Sendgrid account. Example of Data include: Suppressions and Templates. (as of February 2023) The scripts use Sendgrid APIs to retrieve data from one account (source account) and then recreating those data into another account (destination account).
Each script will execute some GET API Requests to retrieve some records, followed by POST API Requests which create new records with the data retrieved from the source account, into the destination account
You must have access to both Source and Destination Accounts so that you can create API Keys in each account to be used in the API Requests.
- BEWARE THESE CODES ARE NOT PRODUCTION READY; HAVE NOT BEEN FULLY TESTED;
- THEY CAN JUST BE USED AS A GUIDE
- PLEASE READ THE CODE.
- THERE ARE COMMENTED CODE WHICH CREATE RECORD!!
This script gives an example of which APIs could be used to migrate templates from one account to another programmatically.
This is just an example which has not been fully optimised and tested.
- Read the Code to uncomment the lines of code to execute the POST requests to create template and template versions
- run the following in the terminal
export apiKeySrcTemplate=<sgKeySource>
export apiKeyDestTemplate=<sgKeyDestination>
- run following
npm run migrate-templates
This script gives an example of which APIs could be used to migrate suppressions (blocks, bounces, global unsubscribes, invalid, spam reports) from one account to another programmatically.
This is just an example which has not been fully optimised and tested.
- run the following in the terminal
export apiKeySrc=<sgKeySource>
export apiKeyDest=<sgKeyDestination>
- run following in the terminal
npm run migrate-sup
- There is no code for migrating suppressions group. For that we need to:
- Create suppression group
- Get the suppressions from previous group in old account
- Add those suppressions in the new group in new account.
chmod 700 generate-CSV-With-PseudoEmails.sh
./generate-CSV-With-PseudoEmails.sh
_This script gives an example of which APIs could be used to add emails from a csv into the global unsubscribe list using the following endpoint https://www.twilio.com/docs/sendgrid/api-reference/suppressions-global-suppressions/add-recipient-addresses-to-the-global-suppression-group
This is just an example which has not been fully optimised and tested.
- run the following in the terminal
export apiKeyDest=<sgKeyDestination>
export csvFilePath=/<>/<>/pseudo_emails.csv
- run following in the terminal
npm run addemails-csv-to-globalsup