### Quick Start: Ping Mailchimp Transactional API Source: https://github.com/mailchimp/mailchimp-transactional-node/blob/master/README.md A basic example demonstrating how to initialize the Mailchimp Transactional client with an API key and make a 'ping' request to verify connectivity. It logs the response to the console. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function callPing() { const response = await mailchimp.users.ping(); console.log(response); } callPing(); ``` -------------------------------- ### Install Mailchimp Transactional Node.js Client Source: https://github.com/mailchimp/mailchimp-transactional-node/blob/master/README.md Installs the Mailchimp Transactional Node.js client library using npm. This is the first step to integrating Mailchimp's transactional email services into your Node.js application. ```bash npm install @mailchimp/mailchimp_transactional ``` -------------------------------- ### Initialize Mailchimp Transactional Client Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates how to install the package and initialize the client with an API key. Includes optional configuration for response formats, timeouts, and custom headers. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); mailchimp.setDefaultOutputFormat('json'); mailchimp.setDefaultTimeoutMs(60000); mailchimp.setRequestHeaders({ 'X-Custom-Header': 'custom-value' }); ``` -------------------------------- ### IPs API - Start IP Warmup Process Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Initiates the warmup process for a specific dedicated IP address. ```APIDOC ## Start IP Warmup Process ### Description Initiates the warmup process for a specific dedicated IP address. This helps gradually increase sending volume to improve deliverability. ### Method POST ### Endpoint /ips/{ip}/warmup ### Parameters #### Path Parameters - **ip** (string) - Required - The dedicated IP address to start the warmup process for. ### Request Example ```javascript const response = await mailchimp.ips.startWarmup({ ip: '123.45.67.89' }); console.log(response); ``` ### Response #### Success Response (200) - **ip** (string) - The dedicated IP address. - **warmup** (object) - Details about the warmup process, including start and end times. #### Response Example ```json { "ip": "123.45.67.89", "warmup": { "warming_up": true, "start_at": "...", "end_at": "..." } } ``` ``` -------------------------------- ### GET /tags Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt List all tags used to organize and track email performance. ```APIDOC ## GET /tags ### Description List all tags currently in use. ### Method GET ### Endpoint /tags/list ### Response #### Success Response (200) - **tag** (string) - The tag name - **sent** (integer) - Total sent count for this tag #### Response Example [ { "tag": "order-confirmation", "sent": 5000 } ] ``` -------------------------------- ### Start IP Warmup Process - JavaScript Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Initiates the warmup process for a specific dedicated IP address. This is crucial for gradually increasing sending volume to improve deliverability. Returns the IP and its warmup status. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function startWarmup() { const response = await mailchimp.ips.startWarmup({ ip: '123.45.67.89' }); console.log(response); // { ip: "123.45.67.89", warmup: { warming_up: true, start_at: "...", end_at: "..." } } } startWarmup(); ``` -------------------------------- ### GET /mctemplates/list Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Retrieves a list of all Mailchimp-synced transactional templates. ```APIDOC ## GET /mctemplates/list ### Description Lists all templates synced from the connected Mailchimp account. ### Method GET ### Endpoint /mctemplates/list ### Response #### Success Response (200) - **templates** (array) - A list of template objects including name, slug, and creation date. ``` -------------------------------- ### Get Dedicated IP Info - JavaScript Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Fetches detailed information for a specific dedicated IP address. This includes its pool assignment, domain, and warmup status. Requires the IP address as input. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function getIpInfo() { const response = await mailchimp.ips.info({ ip: '123.45.67.89' }); console.log(response); // { ip: "123.45.67.89", pool: "Main Pool", domain: "...", warmup: { ... } } } getIpInfo(); ``` -------------------------------- ### Get IP Pool Information - JavaScript Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Fetches detailed information about a specific IP pool, including its name, creation date, and a list of associated dedicated IP addresses. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function getPoolInfo() { const response = await mailchimp.ips.poolInfo({ pool: 'Main Pool' }); console.log(response); // { name: "Main Pool", created_at: "...", ips: [{ ip: "...", ... }] } } getPoolInfo(); ``` -------------------------------- ### Manage Mailchimp Account Templates with Node.js Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Provides methods to interact with templates synced from a Mailchimp account. Includes listing, retrieving info, rendering, and getting time-series statistics for these templates. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function listMcTemplates() { const response = await mailchimp.mctemplates.mcTemplatesList({}); console.log(response); } async function renderMcTemplate() { const response = await mailchimp.mctemplates.mcTemplatesRender({ name: 'mc-template-1', merge_vars: [{ name: 'FNAME', content: 'John' }, { name: 'LNAME', content: 'Doe' }] }); console.log(response); } ``` -------------------------------- ### GET /senders Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Retrieve a list of all senders that have used the account. ```APIDOC ## GET /senders ### Description List all senders that have used this account. ### Method GET ### Endpoint /senders/list ### Response #### Success Response (200) - **address** (string) - The email address of the sender - **sent** (integer) - Total number of emails sent #### Response Example [ { "address": "sender@yourdomain.com", "sent": 5000 } ] ``` -------------------------------- ### IP Pools API - Get Pool Information Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Retrieves detailed information about a specific IP pool. ```APIDOC ## Get Pool Information ### Description Retrieves detailed information about a specific IP pool, including its name, creation date, and the IP addresses assigned to it. ### Method GET ### Endpoint /ips/pools/{pool_name} ### Parameters #### Path Parameters - **pool_name** (string) - Required - The name of the IP pool to retrieve information for. ### Request Example ```javascript const response = await mailchimp.ips.poolInfo({ pool: 'Main Pool' }); console.log(response); ``` ### Response #### Success Response (200) - **name** (string) - The name of the IP pool. - **created_at** (string) - The timestamp when the pool was created. - **ips** (array) - An array of IP address objects within the pool. #### Response Example ```json { "name": "Main Pool", "created_at": "...", "ips": [ { "ip": "...", ... } ] } ``` ``` -------------------------------- ### IPs API - Get Info for a Specific IP Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Retrieves detailed information about a specific dedicated IP address. ```APIDOC ## Get Info for a Specific IP ### Description Retrieves detailed information about a specific dedicated IP address, including its pool, domain, and warmup status. ### Method GET ### Endpoint /ips/{ip} ### Parameters #### Path Parameters - **ip** (string) - Required - The dedicated IP address to retrieve information for. ### Request Example ```javascript const response = await mailchimp.ips.info({ ip: '123.45.67.89' }); console.log(response); ``` ### Response #### Success Response (200) - **ip** (string) - The dedicated IP address. - **pool** (string) - The name of the IP pool the IP belongs to. - **domain** (string) - The domain associated with the IP (if any). - **warmup** (object) - Information about the IP's warmup status. #### Response Example ```json { "ip": "123.45.67.89", "pool": "Main Pool", "domain": "...", "warmup": { ... } } ``` ``` -------------------------------- ### Provision New Dedicated IP - JavaScript Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Requests a new dedicated IP address from Mailchimp. You can specify whether to start the warmup process immediately and assign it to an existing IP pool. Returns the request timestamp. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function provisionIp() { const response = await mailchimp.ips.provision({ warmup: true, // Start warmup process pool: 'Main Pool' }); console.log(response); // { requested_at: "2024-01-15" } } provisionIp(); ``` -------------------------------- ### Manage Inbound Email Domains and Routes with Node.js Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates how to configure inbound email domains, verify MX settings, and manage routing patterns to webhooks. It also includes a utility for testing inbound processing with raw MIME messages. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function listInboundDomains() { const response = await mailchimp.inbound.domains({}); console.log(response); } async function addInboundDomain() { const response = await mailchimp.inbound.addDomain({ domain: 'inbound.yourdomain.com' }); console.log(response); } async function checkInboundDomain() { const response = await mailchimp.inbound.checkDomain({ domain: 'inbound.yourdomain.com' }); console.log(response); } async function addInboundRoute() { const response = await mailchimp.inbound.addRoute({ domain: 'inbound.yourdomain.com', pattern: 'support-*', url: 'https://yourdomain.com/inbound-webhook' }); console.log(response); } async function listInboundRoutes() { const response = await mailchimp.inbound.routes({ domain: 'inbound.yourdomain.com' }); console.log(response); } async function updateInboundRoute() { const response = await mailchimp.inbound.updateRoute({ id: 'route-123', pattern: 'support-ticket-*', url: 'https://yourdomain.com/new-webhook' }); console.log(response); } async function sendRawInbound() { const response = await mailchimp.inbound.sendRaw({ raw_message: `From: sender@example.com\nTo: support-123@inbound.yourdomain.com\nSubject: Test inbound email\n\nThis is a test inbound email.`, to: ['support-123@inbound.yourdomain.com'], mail_from: 'sender@example.com', helo: 'example.com', client_address: '127.0.0.1' }); console.log(response); } async function deleteInboundRoute() { const response = await mailchimp.inbound.deleteRoute({ id: 'route-123' }); console.log(response); } async function deleteInboundDomain() { const response = await mailchimp.inbound.deleteDomain({ domain: 'inbound.yourdomain.com' }); console.log(response); } ``` -------------------------------- ### Manage Tags and Performance Statistics Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Shows how to list tags, retrieve detailed tag information, and fetch time series performance data for specific tags or all tags combined. Useful for monitoring email campaign performance. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function listTags() { const response = await mailchimp.tags.list({}); console.log(response); } async function getTagInfo(tag) { const response = await mailchimp.tags.info({ tag }); console.log(response); } async function getTagTimeSeries(tag) { const response = await mailchimp.tags.timeSeries({ tag }); console.log(response); } async function getAllTagsTimeSeries() { const response = await mailchimp.tags.allTimeSeries({}); console.log(response); } async function deleteTag(tag) { const response = await mailchimp.tags.delete({ tag }); console.log(response); } ``` -------------------------------- ### Export Activity History and Lists with Node.js Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Shows how to trigger asynchronous exports for email activity history, rejection denylists, and allowlists. It also covers listing existing exports and retrieving the status and result URLs for completed tasks. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function exportActivity() { const response = await mailchimp.exports.activity({ notify_email: 'admin@yourdomain.com', date_from: '2024-01-01', date_to: '2024-01-31', tags: ['order-confirmation'], senders: ['orders@yourdomain.com'], states: ['sent', 'bounced', 'rejected'], api_keys: [] }); console.log(response); } async function listExports() { const response = await mailchimp.exports.list({}); console.log(response); } async function getExportInfo() { const response = await mailchimp.exports.info({ id: 'export-123' }); console.log(response); } async function exportRejects() { const response = await mailchimp.exports.rejects({ notify_email: 'admin@yourdomain.com' }); console.log(response); } async function exportAllowlist() { const response = await mailchimp.exports.allowlist({ notify_email: 'admin@yourdomain.com' }); console.log(response); } ``` -------------------------------- ### Messages API - Search and Info Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Search sent messages by various criteria, retrieve message content, and get detailed delivery information for individual messages. ```APIDOC ## POST /messages/search ### Description Searches sent messages based on specified criteria such as email address, date range, tags, and senders. Returns a list of matching messages with summary information. ### Method POST ### Endpoint /messages/search ### Parameters #### Request Body - **query** (string) - Required - The search query. Supports syntax like 'email:user@example.com', 'subject:...', etc. - **date_from** (string) - Optional - The start date for the search (YYYY-MM-DD). - **date_to** (string) - Optional - The end date for the search (YYYY-MM-DD). - **tags** (array of strings) - Optional - An array of tags to filter messages by. - **senders** (array of strings) - Optional - An array of sender email addresses to filter messages by. - **api_keys** (array of strings) - Optional - An array of API keys to filter messages by (useful for multi-account setups). - **limit** (integer) - Optional - The maximum number of results to return. ### Request Example ```json { "query": "email:user@example.com", "date_from": "2024-01-01", "date_to": "2024-01-31", "tags": ["order-confirmation"], "senders": ["orders@yourdomain.com"], "limit": 100 } ``` ### Response #### Success Response (200) - **ts** (integer) - Timestamp of when the message was sent. - **_id** (string) - Unique identifier for the message. - **sender** (string) - The sender's email address. - **subject** (string) - The subject line of the message. - **opens** (integer) - Number of times the message was opened. - **clicks** (integer) - Number of times a link in the message was clicked. #### Response Example ```json [ { "ts": 1705312800, "_id": "abc123", "sender": "orders@yourdomain.com", "subject": "Your Order Confirmation", "opens": 10, "clicks": 2 } ] ``` ## POST /messages/search-time-series ### Description Retrieves aggregated hourly statistics for message search results over a specified date range. ### Method POST ### Endpoint /messages/search-time-series ### Parameters #### Request Body - **query** (string) - Required - The search query. - **date_from** (string) - Required - The start date for the time series (YYYY-MM-DD). - **date_to** (string) - Required - The end date for the time series (YYYY-MM-DD). ### Request Example ```json { "query": "email:user@example.com", "date_from": "2024-01-01", "date_to": "2024-01-07" } ``` ### Response #### Success Response (200) - **time** (string) - The timestamp for the hourly data point (YYYY-MM-DD HH:MM:SS). - **sent** (integer) - Number of messages sent during that hour. - **opens** (integer) - Number of messages opened during that hour. - **clicks** (integer) - Number of links clicked during that hour. #### Response Example ```json [ { "time": "2024-01-01 00:00:00", "sent": 50, "opens": 20, "clicks": 5 } ] ``` ## POST /messages/info ### Description Retrieves detailed information for a single specific message using its unique ID. ### Method POST ### Endpoint /messages/info ### Parameters #### Request Body - **id** (string) - Required - The unique ID of the message to retrieve information for. ### Request Example ```json { "id": "abc123def456..." } ``` ### Response #### Success Response (200) - **ts** (integer) - Timestamp of when the message was sent. - **_id** (string) - Unique identifier for the message. - **state** (string) - The current delivery state of the message (e.g., "sent", "delivered", "hard-bounced"). - **subject** (string) - The subject line of the message. - **opens** (integer) - Number of times the message was opened. - **clicks** (integer) - Number of times a link in the message was clicked. #### Response Example ```json { "ts": 1705312800, "_id": "abc123def456...", "state": "sent", "subject": "Order Update", "opens": 3, "clicks": 1 } ``` ## POST /messages/content ### Description Retrieves the full content (including HTML and text parts) of a sent message using its unique ID. ### Method POST ### Endpoint /messages/content ### Parameters #### Request Body - **id** (string) - Required - The unique ID of the message to retrieve content for. ### Request Example ```json { "id": "abc123def456..." } ``` ### Response #### Success Response (200) - **ts** (integer) - Timestamp of when the message was sent. - **from_email** (string) - The sender's email address. - **subject** (string) - The subject line of the message. - **html** (string) - The HTML content of the message. - **text** (string) - The plain text content of the message. - **attachments** (array) - An array of attachment objects, if any. #### Response Example ```json { "ts": 1705312800, "from_email": "sender@yourdomain.com", "subject": "Your Order Details", "html": "
Your order details here...
", "text": "Your order details here...", "attachments": [] } ``` ## POST /messages/parse ### Description Parses a raw MIME document to extract message components like subject, sender, HTML, and attachments. ### Method POST ### Endpoint /messages/parse ### Parameters #### Request Body - **raw_message** (string) - Required - The raw MIME content of the email message. ### Request Example ```json { "raw_message": "From: sender@example.com\nTo: recipient@example.com\nSubject: Test\n\nThis is the body." } ``` ### Response #### Success Response (200) - **subject** (string) - The extracted subject of the message. - **from_email** (string) - The extracted sender's email address. - **html** (string) - The extracted HTML content. - **attachments** (array) - An array of extracted attachment objects. #### Response Example ```json { "subject": "Test Email", "from_email": "sender@example.com", "html": "This is the body.
", "attachments": [] } ``` ``` -------------------------------- ### POST /templates/render Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Renders a template by injecting merge variables and content blocks into the template structure. ```APIDOC ## POST /templates/render ### Description Injects data into a template to generate the final HTML output. ### Method POST ### Endpoint /templates/render ### Request Body - **template_name** (string) - Required - The name of the template to render. - **template_content** (array) - Optional - Content blocks for mc:edit areas. - **merge_vars** (array) - Optional - Key-value pairs for template variables. ### Request Example { "template_name": "order-receipt", "merge_vars": [{"name": "order_id", "content": "12345"}] } ### Response #### Success Response (200) - **html** (string) - The fully rendered HTML content. ``` -------------------------------- ### Send Emails with Templates using Node.js Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates how to send transactional emails using pre-defined templates. It covers both custom template content injection and syncing with existing Mailchimp Transactional templates, including the use of global and recipient-specific merge variables. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function sendWithTemplate() { const response = await mailchimp.messages.sendTemplate({ template_name: 'welcome-email', template_content: [ { name: 'header', content: 'Thank you for signing up.
' } ], message: { from_email: 'welcome@yourdomain.com', from_name: 'Welcome Team', subject: 'Welcome to Our Platform!', to: [{ email: 'newuser@example.com', name: 'New User', type: 'to' }], global_merge_vars: [ { name: 'FNAME', content: 'John' }, { name: 'COMPANY', content: 'Acme Inc' } ], merge_vars: [ { rcpt: 'newuser@example.com', vars: [ { name: 'ACCOUNT_URL', content: 'https://app.example.com/user/123' } ] } ], tags: ['welcome', 'onboarding'], track_opens: true, track_clicks: true } }); console.log(response); } async function sendWithMcTemplate() { const response = await mailchimp.messages.sendMcTemplate({ template_name: 'mc-transactional-template', template_content: [], message: { from_email: 'sender@yourdomain.com', subject: 'Your Weekly Report', to: [{ email: 'user@example.com', type: 'to' }], global_merge_vars: [ { name: 'REPORT_DATE', content: '2024-01-15' } ] } }); console.log(response); } ``` -------------------------------- ### POST /templates/add Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Creates a new transactional email template with specified HTML content and metadata. ```APIDOC ## POST /templates/add ### Description Creates a new email template for transactional messaging. ### Method POST ### Endpoint /templates/add ### Request Body - **name** (string) - Required - The unique name for the template. - **from_email** (string) - Optional - Default from email address. - **from_name** (string) - Optional - Default from name. - **subject** (string) - Optional - Default subject line. - **code** (string) - Required - The HTML content of the template. - **publish** (boolean) - Optional - Whether to publish the template immediately. ### Request Example { "name": "order-receipt", "from_email": "orders@example.com", "code": "Order ID: {{order_id}}
Total: {{total}}