Comprehensive Node.js examples for the Transactional API
This repository provides examples for specific Transactional API use cases using Node.js. These examples demonstrate how to implement Transactional API email functionality effectively.
All examples are available as documentation in the /use-cases/
directory. Each use case includes complete code examples you can copy and run.
If you need support using the Transactional API, please check the Transactional API Documentation.
- Node >= 10.0.0
- A Transactional API key
-
Clone this repository
git clone [email protected]:IntuitDeveloper/Transactional-Node-Samples.git cd Transactional-Node-Samples
-
Install dependencies in the scripts folder:
cd scripts npm install
-
Add your API key and email addresses to your .env file
TRANSACTIONAL_API_KEY='your-transactional-api-key-here' DEFAULT_FROM_EMAIL='[email protected]' DEFAULT_FROM_NAME='Your Name' DEFAULT_TO_EMAIL='[email protected]' DEFAULT_TO_NAME='Recipient Name'
-
Run a script from the scripts folder
node email_with_single_recipient.js
Basic Email Sending:
Advanced Features:
- Send Email with Merge Tags
- Send Email with Attachments
- Create Email Template
- Send Email Using Template
- Kitchen Sink - All Features
Feature | Transactional API Implementation |
---|---|
Library | @mailchimp/mailchimp_transactional |
Recipients | to: [{email: '[email protected]', type: 'to'}] |
Sender | from_email: '[email protected]' |
Multiple Recipients | preserve_recipients: false |
Substitutions | `* |
Categories | tags: ['tag'] |
- Install
@mailchimp/mailchimp_transactional
package - Configure API key
- Set up message structure (recipients, sender format)
- Implement error handling with try/catch
- Configure substitution variables syntax
- Test email delivery and tracking
- Set up monitoring and analytics
- Authentication Errors: Verify your Transactional API key is correct and active
- Email Rejections: Check email format and domain reputation
- Rate Limiting: Implement delays between API calls for bulk sending
- Template Errors: Verify template names and merge variable syntax
- Check the Transactional API Documentation
- Contact Transactional API Support
- Error Handling: Always implement proper error handling
- Rate Limiting: Respect API limits to avoid throttling
- Email Validation: Validate email addresses before sending
- Content Quality: Follow email best practices for deliverability
- Monitoring: Track delivery rates and bounces
- Security: Keep API keys secure and use environment variables
- Testing: Test emails in development before production
For Transactional API support, please contact Mailchimp Support.
This project is licensed under the MIT License - see the LICENSE file for details.