### 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: '

Welcome to Our Service!

' }, { name: 'main', 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 Received

" } ### Response #### Success Response (200) - **slug** (string) - The unique identifier for the template. ``` -------------------------------- ### List All IP Pools - JavaScript Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Retrieves a list of all IP pools configured for your account. Each pool entry includes its name and the dedicated IPs assigned to it. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function listPools() { const response = await mailchimp.ips.listPools({}); console.log(response); // [{ name: "Main Pool", ips: ["123.45.67.89"], ... }] } listPools(); ``` -------------------------------- ### Create IP Pool - JavaScript Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Creates a new IP pool, which allows you to group dedicated IPs for better sending control. Requires a unique pool name. Returns the pool details. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function createPool() { const response = await mailchimp.ips.createPool({ pool: 'Transactional Pool' }); console.log(response); // { name: "Transactional Pool", created_at: "2024-01-15", ips: [] } } createPool(); ``` -------------------------------- ### IP Pools API - List All IP Pools Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Retrieves a list of all IP pools configured for your account. ```APIDOC ## List All IP Pools ### Description Retrieves a list of all IP pools configured for your account, including the IPs assigned to each pool. ### Method GET ### Endpoint /ips/pools ### Parameters (No specific parameters mentioned for listing pools.) ### Request Example ```javascript const response = await mailchimp.ips.listPools({}); console.log(response); ``` ### Response #### Success Response (200) - **name** (string) - The name of the IP pool. - **ips** (array) - An array of IP addresses within the pool. #### Response Example ```json [ { "name": "Main Pool", "ips": ["123.45.67.89"], ... } ] ``` ``` -------------------------------- ### Configure Response Formats and Timeouts (Node.js) Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt This snippet demonstrates how to configure response formats (JSON, XML, PHP, YAML) globally or per-request, set custom timeouts for API operations, and add custom headers using the Mailchimp Transactional API client. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); // Set default output format for all requests mailchimp.setDefaultOutputFormat('json'); // Options: json, xml, php, yaml // Override format for a single request async function getInfoAsXml() { const response = await mailchimp.users.info({ outputFormat: 'xml' }); console.log(response); // Returns XML formatted response } async function getInfoAsYaml() { const response = await mailchimp.users.info({ outputFormat: 'yaml' }); console.log(response); // Returns YAML formatted response } // Set custom timeout for long-running operations mailchimp.setDefaultTimeoutMs(600000); // 10 minutes // Set custom headers mailchimp.setRequestHeaders({ 'X-Request-ID': 'unique-request-id-123' }); getInfoAsXml(); ``` -------------------------------- ### Search and Retrieve Message Information Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates how to search for sent messages using specific criteria, retrieve aggregated time-series data, fetch detailed info for a specific message, and extract full content or parse raw MIME documents. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function searchMessages() { const response = await mailchimp.messages.search({ query: 'email:user@example.com', date_from: '2024-01-01', date_to: '2024-01-31', tags: ['order-confirmation'], senders: ['orders@yourdomain.com'], limit: 100 }); console.log(response); } async function searchTimeSeries() { const response = await mailchimp.messages.searchTimeSeries({ query: 'email:user@example.com', date_from: '2024-01-01', date_to: '2024-01-07' }); console.log(response); } async function getMessageInfo() { const response = await mailchimp.messages.info({ id: 'abc123def456...' }); console.log(response); } async function getMessageContent() { const response = await mailchimp.messages.content({ id: 'abc123def456...' }); console.log(response); } async function parseMimeDocument() { const response = await mailchimp.messages.parse({ raw_message: 'From: sender@example.com\nTo: recipient@example.com\n...' }); console.log(response); } ``` -------------------------------- ### Manage Senders and Domains with Mailchimp Transactional API Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates how to list senders, retrieve sender info, manage domain verification (SPF/DKIM), and track sender time series statistics. These functions require an initialized Mailchimp Transactional client. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function listSenders() { const response = await mailchimp.senders.list({}); console.log(response); } async function getSenderInfo(address) { const response = await mailchimp.senders.info({ address }); console.log(response); } async function addSenderDomain(domain) { const response = await mailchimp.senders.addDomain({ domain }); console.log(response); } async function checkDomainSettings(domain) { const response = await mailchimp.senders.checkDomain({ domain }); console.log(response); } async function verifyDomain(domain, mailbox) { const response = await mailchimp.senders.verifyDomain({ domain, mailbox }); console.log(response); } async function getSenderTimeSeries(address) { const response = await mailchimp.senders.timeSeries({ address }); console.log(response); } async function deleteSenderDomain(domain) { const response = await mailchimp.senders.deleteDomain({ domain }); console.log(response); } ``` -------------------------------- ### Send Transactional Emails Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates how to send emails with advanced options including attachments, metadata, tracking, and template variables. The method returns the status of the delivery request. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function sendEmail() { const response = await mailchimp.messages.send({ message: { from_email: 'sender@yourdomain.com', subject: 'Order Confirmation #12345', html: '

Thank you for your order!

', to: [{ email: 'recipient@example.com', name: 'John Doe', type: 'to' }], tags: ['order-confirmation'] }, async: false }); console.log(response); } ``` -------------------------------- ### Manage Transactional Templates with Node.js Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates core CRUD operations and rendering for transactional templates. These methods allow developers to programmatically handle template lifecycles and inject merge variables for personalized content. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function createTemplate() { const response = await mailchimp.templates.add({ name: 'order-receipt', from_email: 'orders@yourdomain.com', from_name: 'Order System', subject: 'Your Order Receipt - {{order_id}}', code: '

Thank you for your order!

Order ID: {{order_id}}

Total: {{total}}

', text: 'Thank you for your order! Order ID: {{order_id}}', publish: true, labels: ['transactional', 'orders'] }); console.log(response); } async function renderTemplate() { const response = await mailchimp.templates.render({ template_name: 'order-receipt', template_content: [{ name: 'order_details', content: '...
' }], merge_vars: [{ name: 'order_id', content: '12345' }, { name: 'total', content: '$99.99' }] }); console.log(response); } ``` -------------------------------- ### Manage Subaccounts with Mailchimp Transactional API Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Demonstrates how to perform full lifecycle management of subaccounts including creation, listing, retrieval, updating, and status toggling (pause/resume). Requires the @mailchimp/mailchimp_transactional package and a valid API key. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function addSubaccount() { const response = await mailchimp.subaccounts.add({ id: 'client-abc', name: 'ABC Corporation', notes: 'Enterprise client - priority support', custom_quota: 1000 }); console.log(response); } async function listSubaccounts() { const response = await mailchimp.subaccounts.list({ q: 'client' }); console.log(response); } async function getSubaccountInfo() { const response = await mailchimp.subaccounts.info({ id: 'client-abc' }); console.log(response); } async function updateSubaccount() { const response = await mailchimp.subaccounts.update({ id: 'client-abc', name: 'ABC Corporation Updated', notes: 'Enterprise client - VIP', custom_quota: 2000 }); console.log(response); } async function pauseSubaccount() { const response = await mailchimp.subaccounts.pause({ id: 'client-abc' }); console.log(response); } async function resumeSubaccount() { const response = await mailchimp.subaccounts.resume({ id: 'client-abc' }); console.log(response); } async function deleteSubaccount() { const response = await mailchimp.subaccounts.delete({ id: 'client-abc' }); console.log(response); } ``` -------------------------------- ### Set Custom Reverse DNS for IP - JavaScript Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Configures a custom reverse DNS (rDNS) record for a dedicated IP address. This helps in establishing sender identity and can improve deliverability. Requires the IP and the desired domain. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function setCustomDns() { const response = await mailchimp.ips.setCustomDns({ ip: '123.45.67.89', domain: 'mail.yourdomain.com' }); console.log(response); // { ip: "123.45.67.89", domain: "mail.yourdomain.com", valid: false } } setCustomDns(); ``` -------------------------------- ### IPs API - Provision a New Dedicated IP Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Requests a new dedicated IP address to be provisioned for your account. ```APIDOC ## Provision a New Dedicated IP ### Description Requests a new dedicated IP address to be provisioned for your account. You can optionally start the warmup process immediately. ### Method POST ### Endpoint /ips/provision ### Parameters #### Request Body - **warmup** (boolean) - Optional - If true, the warmup process will start immediately after provisioning. - **pool** (string) - Optional - The name of the IP pool to assign the new IP to. If not specified, it will be assigned to the default pool. ### Request Example ```json { "warmup": true, "pool": "Main Pool" } ``` ### Response #### Success Response (200) - **requested_at** (string) - The timestamp when the IP was requested. #### Response Example ```json { "requested_at": "2024-01-15" } ``` ``` -------------------------------- ### POST /users/ping Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Validates the provided API key by sending a ping request to the server. ```APIDOC ## POST /users/ping ### Description Validates the API key and checks connectivity to the Mailchimp Transactional service. ### Method POST ### Endpoint https://mandrillapp.com/api/1.3/users/ping.json ### Request Example { "key": "YOUR_API_KEY" } ### Response #### Success Response (200) - **response** (string) - Returns "PONG!" #### Response Example "PONG!" ``` -------------------------------- ### Manage Mailchimp Rejects (Denylist) with Node.js Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt This snippet demonstrates how to manage email and SMS denylists using the Mailchimp Transactional Node.js library. It covers adding emails/phone numbers to the denylist, listing denylisted entries, and removing them. This prevents delivery to specified addresses or numbers. Requires the '@mailchimp/mailchimp_transactional' package and an API key. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); // Add email to denylist async function addToDenylist() { const response = await mailchimp.rejects.add({ email: 'spam@example.com', comment: 'User requested to stop all emails', subaccount: null // Optional: specific subaccount }); console.log(response); // { email: "spam@example.com", added: true } } // List denylisted emails async function listDenylist() { const response = await mailchimp.rejects.list({ email: 'example.com', // Optional: filter by email/prefix include_expired: false, subaccount: null }); console.log(response); // [{ // email: "spam@example.com", // reason: "manual", // detail: "User requested...", // created_at: "2024-01-15", // expires_at: null // }] } // Remove email from denylist async function removeFromDenylist() { const response = await mailchimp.rejects.delete({ email: 'spam@example.com', subaccount: null }); console.log(response); // { email: "spam@example.com", deleted: true } } // Add phone number to SMS denylist async function addSmsToDenylist() { const response = await mailchimp.rejects.addSms({ phone: '+15551234567', comment: 'User opted out of SMS' }); console.log(response); } // List SMS denylist async function listSmsDenylist() { const response = await mailchimp.rejects.listSms({ include_expired: false }); console.log(response); } // Remove phone from SMS denylist async function removeSmsDenylist() { const response = await mailchimp.rejects.deleteSms({ phone: '+15551234567' }); console.log(response); } listDenylist(); ``` -------------------------------- ### IP Pools API - Create an IP Pool Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Creates a new IP pool to group dedicated IP addresses. ```APIDOC ## Create an IP Pool ### Description Creates a new IP pool, which allows you to group dedicated IP addresses for better sending management and deliverability. ### Method POST ### Endpoint /ips/pools ### Parameters #### Request Body - **pool** (string) - Required - The name for the new IP pool. ### Request Example ```json { "pool": "Transactional Pool" } ``` ### Response #### Success Response (200) - **name** (string) - The name of the created IP pool. - **created_at** (string) - The timestamp when the pool was created. - **ips** (array) - An array of IP addresses currently in the pool (initially empty). #### Response Example ```json { "name": "Transactional Pool", "created_at": "2024-01-15", "ips": [] } ``` ``` -------------------------------- ### POST /senders/domains/add Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Add a new sender domain to the account. ```APIDOC ## POST /senders/domains/add ### Description Add a sender domain to the account for verification. ### Method POST ### Endpoint /senders/add-domain ### Request Body - **domain** (string) - Required - The domain name to add ### Request Example { "domain": "yourdomain.com" } ### Response #### Success Response (200) - **domain** (string) - The domain added - **valid_signing** (boolean) - Status of signing configuration #### Response Example { "domain": "yourdomain.com", "valid_signing": false } ``` -------------------------------- ### Manage Account via Users API Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Provides methods to validate API connectivity, retrieve account statistics, and list authorized senders. These methods are essential for verifying integration status. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); async function validateApiKey() { try { const response = await mailchimp.users.ping(); console.log(response); } catch (error) { console.error('Invalid API key:', error); } } async function getAccountInfo() { const response = await mailchimp.users.info(); console.log(response); } async function listAccountSenders() { const response = await mailchimp.users.senders(); console.log(response); } ``` -------------------------------- ### Manage Mailchimp Webhooks with Node.js Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt This snippet demonstrates how to configure webhooks to receive real-time notifications for email events using the Mailchimp Transactional Node.js library. It covers listing, adding, retrieving, updating, and deleting webhooks. Requires the '@mailchimp/mailchimp_transactional' package and an API key. ```javascript const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); // List all webhooks async function listWebhooks() { const response = await mailchimp.webhooks.list({}); console.log(response); // [{ id: 123, url: "https://yourdomain.com/webhook", events: [...], ... }] } // Add a new webhook async function addWebhook() { const response = await mailchimp.webhooks.add({ url: 'https://yourdomain.com/mailchimp-webhook', description: 'Production email events webhook', events: [ 'send', 'open', 'click', 'hard_bounce', 'soft_bounce', 'spam', 'unsub', 'reject' ] }); console.log(response); // { id: 456, url: "https://yourdomain.com/mailchimp-webhook", auth_key: "webhook_auth_key_abc123", events: ["send", "open", "click", ...], created_at: "2024-01-15" } } // Get webhook information async function getWebhookInfo() { const response = await mailchimp.webhooks.info({ id: 456 }); console.log(response); // { id: 456, url: "...", events: [...], batched_events: [...], ... } } // Update a webhook async function updateWebhook() { const response = await mailchimp.webhooks.update({ id: 456, url: 'https://yourdomain.com/new-webhook-endpoint', events: ['send', 'open', 'click', 'hard_bounce'] }); console.log(response); } // Delete a webhook async function deleteWebhook() { const response = await mailchimp.webhooks.delete({ id: 456 }); console.log(response); // { id: 456 } } addWebhook(); ``` -------------------------------- ### IPs API - List All Dedicated IPs Source: https://context7.com/mailchimp/mailchimp-transactional-node/llms.txt Retrieves a list of all dedicated IP addresses associated with your account. ```APIDOC ## List All Dedicated IPs ### Description Retrieves a list of all dedicated IP addresses associated with your account, including their associated pool and warmup status. ### Method GET ### Endpoint /ips ### Parameters #### Query Parameters - **skip** (integer) - Optional - Number of IPs to skip from the beginning of the list. - **limit** (integer) - Optional - Maximum number of IPs to return. ### Request Example ```javascript const response = await mailchimp.ips.list({}); 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. - **warmup** (boolean) - Indicates if the IP is currently in the warmup process. #### Response Example ```json [ { "ip": "123.45.67.89", "pool": "Main Pool", "warmup": false, ... } ] ``` ``` -------------------------------- ### Send Mailchimp Transactional API Request Source: https://github.com/mailchimp/mailchimp-transactional-node/blob/master/README.md Demonstrates how to send a POST request to the Mailchimp Transactional API, specifically publishing a template. All requests accept a single argument as the request body parameter. ```javascript mailchimp.templates.publish({ name: 'My Template' }); ```