{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/email-api/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Mailjet Node.js SDK","siteUrl":"https://dev.mailjet.com/","projectTitle":"Mailjet Developer Documentation","description":"Install and use the official Mailjet Node.js SDK: authentication, sending with Send API v3.1, batch sending, TypeScript types, configuration and SMS.","image":"https://dev.mailjet.com/og-image.png","lang":"en-US","keywords":["Mailjet API","Email API","Content API","SMTP Relay","transactional email","email delivery","Send API","email templates","developer documentation"],"meta":[{"name":"og:type","content":"website"},{"name":"og:site_name","content":"Mailjet Developer Documentation"},{"name":"twitter:card","content":"summary_large_image"},{"name":"robots","content":"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"},{"name":"googlebot","content":"index, follow, max-snippet:-1, max-image-preview:large"}],"jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://dev.mailjet.com/#organization","name":"Mailjet","alternateName":"Sinch Mailjet","url":"https://www.mailjet.com","logo":"https://assets.mailjet.com/lib/images/mailjetLogo/mj_logo_with_text_color.png","parentOrganization":{"@type":"Organization","name":"Sinch","url":"https://www.sinch.com"}},{"@type":"WebSite","@id":"https://dev.mailjet.com/#website","name":"Mailjet Developer Documentation","description":"Official developer documentation for the Mailjet Email API, Content API and SMTP Relay.","url":"https://dev.mailjet.com/","inLanguage":"en-US","publisher":{"@id":"https://dev.mailjet.com/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://dev.mailjet.com/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]},"llmstxt":{"hide":false,"title":"Mailjet Developer Documentation","description":"Developer documentation for the Mailjet Email API, Content API and SMTP Relay - guides, API references and code samples for sending, templating and tracking email at scale.","details":{"content":"Mailjet (part of Sinch) provides APIs for sending and managing email.\n\nThis documentation covers four main areas:\n\n- **Email API** - the Send API (v3 and v3.1) for transactional and marketing email,\n  plus contact management, segmentation, campaigns, statistics, webhooks, the Parse API\n  and the Mailjet Templating Language.\n- **Content API** - programmatic management of email templates, template contents,\n  images, labels and authentication tokens (v1).\n- **SMTP Relay** - sending through Mailjet's SMTP servers, including custom headers.\n- **API Reference** - the complete, generated reference for every endpoint, built directly\n  from the OpenAPI specifications.\n\nBase URL for all REST APIs: `https://api.mailjet.com`.\nAuthentication uses HTTP Basic auth with an API key and secret key.\n\n## Machine-readable entry points\n\nPrefer these when you need the API surface in as few requests as possible:\n\n- `/openapi/openapi-mailjet.md` - the **complete** Email API reference (every endpoint,\n  grouped by resource) as a single Markdown document.\n- `/openapi/openapi-passport.md` - the **complete** Content API reference as a single\n  Markdown document.\n- `/_bundle/openapi/openapi-mailjet.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Email API.\n- `/_bundle/openapi/openapi-passport.yaml` - the raw, fully bundled OpenAPI 3 description\n  of the Content API.\n- `/sitemap.xml` - every indexable URL on this site.\n\nEvery page on this site is also available as clean Markdown by appending `.md` to its URL."},"sections":[{"title":"Email API","description":"Sending, contacts, campaigns, statistics, webhooks and templating.","includeFiles":["docs/email-api/**/*.md"],"excludeFiles":[]},{"title":"Content API","description":"Manage templates, template contents, images, labels and tokens.","includeFiles":["docs/content-api/**/*.md","docs/content-api.md"],"excludeFiles":[]},{"title":"SMTP Relay","description":"Send email through Mailjet's SMTP servers.","includeFiles":["docs/smtp-relay/**/*.md"],"excludeFiles":[]},{"title":"API Reference","description":"Complete generated reference for every Mailjet API endpoint.","includeFiles":["openapi/openapi-mailjet.yaml","openapi/openapi-passport.yaml","docs/api-reference/**/*.md"],"excludeFiles":[]},{"title":"Migrating from Mandrill","description":"Guides for switching from Mandrill to Mailjet.","includeFiles":["docs/mandrill/**/*.md"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"nodejs-sdk","__idx":0},"children":["Node.js SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The official JavaScript SDK is published on npm as ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["node-mailjet"]}]}," and developed at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs"},"children":["mailjet/mailjet-apiv3-nodejs"]},". It is written in TypeScript and ships full type coverage."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK runs in ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js"]}," and in the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["browser"]},". In the browser a proxy is currently required because of CORS restrictions — and your private API key must never be shipped in frontend code."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"compatibility","__idx":1},"children":["Compatibility"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Officially supported Node.js versions: ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[">= 12.x"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"upgrading-to-v7","__idx":2},"children":["Upgrading to v7"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Version ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["7.0.0"]}," contains breaking changes. In short:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Entry points are restricted."]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["package.json"]}," now declares an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["exports"]}," map, so only ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["require('node-mailjet')"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["import ... from 'node-mailjet'"]}," resolve. Deep imports such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["require('node-mailjet/dist/mailjet.node.js')"]}," no longer work."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".id()"]}," must come before ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".action()"]},"."]}," Calling ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".id()"]}," after ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".action()"]}," now throws instead of silently building an incorrect URL."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["contactdata"]}," PUT is validated locally."]}," A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["contactdata"]}," throws synchronously if ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Data"]}," is missing, is not an array, or contains entries without ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Name"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Value"]}," keys — instead of failing later with a server-side ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["400"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Requests time out after 30s by default"]}," instead of hanging indefinitely. Pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["options.timeout"]}," to change it."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The full list is in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs/blob/master/CHANGELOG.md"},"children":["CHANGELOG"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"installation","__idx":3},"children":["Installation"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm install node-mailjet\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"set-up-the-client","__idx":4},"children":["Set up the client"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"authentication","__idx":5},"children":["Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Email API and Send API authenticate with your API key and secret. The SMS API uses a bearer token generated in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://app.mailjet.com/sms"},"children":["SMS section"]}," of your account."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"export MJ_APIKEY_PUBLIC='your API key'\nexport MJ_APIKEY_PRIVATE='your API secret'\nexport MJ_API_TOKEN='your API token'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["CommonJS and native ESM (including named imports) are both supported:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const Mailjet = require('node-mailjet');\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"import Mailjet, { Client } from 'node-mailjet';\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"email-api-and-send-api","__idx":6},"children":["Email API and Send API"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const mailjet = new Mailjet({\n  apiKey: process.env.MJ_APIKEY_PUBLIC,\n  apiSecret: process.env.MJ_APIKEY_PRIVATE\n});\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Or with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["apiConnect"]}," helper:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const mailjet = Mailjet.apiConnect(\n  process.env.MJ_APIKEY_PUBLIC,\n  process.env.MJ_APIKEY_PRIVATE,\n  {\n    config: {},\n    options: {}\n  }\n);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"sms-api","__idx":7},"children":["SMS API"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const mailjet = Mailjet.smsConnect(process.env.MJ_API_TOKEN);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"send-your-first-email","__idx":8},"children":["Send your first email"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const Mailjet = require('node-mailjet');\n\nconst mailjet = Mailjet.apiConnect(\n  process.env.MJ_APIKEY_PUBLIC,\n  process.env.MJ_APIKEY_PRIVATE,\n);\n\nmailjet\n  .post('send', { version: 'v3.1' })\n  .request({\n    Messages: [\n      {\n        From: {\n          Email: 'pilot@example.com',\n          Name: 'Mailjet Pilot'\n        },\n        To: [\n          {\n            Email: 'passenger1@example.com',\n            Name: 'Passenger 1'\n          }\n        ],\n        Subject: 'Your email flight plan!',\n        TextPart: 'Dear passenger 1, welcome to Mailjet!',\n        HTMLPart: '<h3>Dear passenger 1, welcome to Mailjet!</h3>'\n      }\n    ]\n  })\n  .then((result) => console.log(result.body))\n  .catch((err) => console.log(err.statusCode));\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"configuration","__idx":9},"children":["Configuration"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Requests are composed from a method, a resource, a config object and the request data:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const mailjet = new Mailjet({\n  apiKey: process.env.MJ_APIKEY_PUBLIC,\n  apiSecret: process.env.MJ_APIKEY_PRIVATE,\n  config: CONFIG,\n  options: OPTIONS\n});\n\nconst request = mailjet\n  .METHOD(RESOURCE, CONFIG)\n  .request(DATA, PARAMS, PERFORM_API_CALL);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Argument"},"children":["Argument"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Meaning"},"children":["Meaning"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["METHOD"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["post"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["put"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["get"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["delete"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RESOURCE"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["the API endpoint to call"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CONFIG"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["connection config — see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#config"},"children":["Config"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["OPTIONS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["connection options — see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#options"},"children":["Options"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DATA"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["request body (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["post"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["put"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["delete"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PARAMS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["URL query parameters"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PERFORM_API_CALL"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["boolean; set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," to build the request without sending it"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Config and options can be set once on the client and reused for every request, or passed per request — a per-request config takes precedence."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"options","__idx":10},"children":["Options"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Option"},"children":["Option"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Effect"},"children":["Effect"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["headers"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["additional request headers"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["timeout"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["milliseconds before the request is aborted (default ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["30000"]}," since v7)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["proxy"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["proxy host, port, protocol and auth ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["(Node only)"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["maxBodyLength"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["maximum request content size in bytes ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["(Node only)"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["maxContentLength"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["maximum response content size in bytes ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["(Node only)"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const mailjet = new Mailjet({\n  apiKey: process.env.MJ_APIKEY_PUBLIC,\n  apiSecret: process.env.MJ_APIKEY_PRIVATE,\n  options: {\n    timeout: 1000,\n    maxBodyLength: 1500,\n    maxContentLength: 100,\n    headers: {\n      'X-API-Key': 'foobar',\n    },\n    proxy: {\n      protocol: 'http',\n      host: 'www.test-proxy.com',\n      port: 3100,\n    }\n  }\n});\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Options are passed through to the underlying HTTP client — see the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/axios/axios#request-config"},"children":["axios request config"]}," for details."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"config","__idx":11},"children":["Config"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Key"},"children":["Key"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Effect"},"children":["Effect"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["host"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["base host name (default ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["api.mailjet.com"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["version"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["API version — ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3.1"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v4"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["output"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["response data type"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"api-versioning","__idx":12},"children":["API versioning"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Version"},"children":["Version"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Scope"},"children":["Scope"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Email API"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3.1"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Send API v3.1 (latest send version)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v4"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SMS API, contact delete API"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Most Email API endpoints sit under ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v3"]},", which is the default and does not need to be specified. For anything else, set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["version"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const request = mailjet.post('send', { version: 'v3.1' });\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"host-url","__idx":13},"children":["Host URL"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const request = mailjet.post('send', { version: 'v3.1', host: 'api.us.mailjet.com' });\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Accounts on Mailjet's ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["US architecture"]}," must set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["api.us.mailjet.com"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"response-output","__idx":14},"children":["Response output"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The default output is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["json"]},". Supported values: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["arraybuffer"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["document"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["json"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["text"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stream"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["blob"]}," (browser only)."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const request = mailjet.post('send', { version: 'v3.1', output: 'arraybuffer' });\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"disable-the-api-call","__idx":15},"children":["Disable the API call"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Useful in tests, to build and inspect a request without reaching Mailjet:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const request = mailjet\n  .post('send', { version: 'v3.1' })\n  .request({}, {}, false);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"typescript","__idx":16},"children":["TypeScript"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["All Mailjet types are exported from the package entry point:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import {\n  Contact,\n  SendEmailV3,\n  SendEmailV3_1,\n  Message,\n  Segmentation,\n  Template,\n  SendMessage,\n  Webhook\n} from 'node-mailjet';\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Request.request<TResult>(data, params, performAPICall)"]}," is generic, so responses are typed:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { Client, SendEmailV3_1, LibraryResponse } from 'node-mailjet';\n\nconst mailjet = new Client({\n  apiKey: process.env.MJ_APIKEY_PUBLIC,\n  apiSecret: process.env.MJ_APIKEY_PRIVATE\n});\n\nconst data: SendEmailV3_1.Body = {\n  Messages: [\n    {\n      From: { Email: 'pilot@example.com' },\n      To: [{ Email: 'passenger@example.com' }],\n      Subject: 'Your email flight plan!',\n      HTMLPart: '<h3>Dear passenger, welcome to Mailjet!</h3>',\n      TextPart: 'Dear passenger, welcome to Mailjet!',\n    },\n  ],\n};\n\nconst result: LibraryResponse<SendEmailV3_1.Response> = await mailjet\n  .post('send', { version: 'v3.1' })\n  .request(data);\n\nconst { Status } = result.body.Messages[0];\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For library versions ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["3.*.*"]}," and below, use the community-maintained ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.npmjs.com/package/@types/node-mailjet"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@types/node-mailjet"]}]}," package instead."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"batch-sending-and-partial-failures","__idx":17},"children":["Batch sending and partial failures"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Send API v3.1 accepts multiple emails in one request through the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Messages"]}," array. ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["This is not an atomic operation."]}," Each entry is validated and processed independently, so a single request can return a mix of successes and failures. A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2xx"]}," response only means Mailjet accepted the request for processing — it does not mean every message was sent, and one failing message does not stop the others."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Always inspect the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Status"]}," of each entry in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["result.body.Messages"]},":"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["success"]}," — the message was accepted and is being delivered."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error"]}," — the message failed; details are in that entry's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Errors"]}," array (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ErrorCode"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ErrorMessage"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ErrorIdentifier"]},")."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AdvanceErrorHandling: true"]}," to get one ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Errors"]}," entry per validation problem, with machine-readable codes."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"const data: SendEmailV3_1.Body = {\n  Messages: [\n    {\n      From: { Email: 'pilot@example.com' },\n      To: [{ Email: 'passenger1@example.com' }],\n      Subject: 'Your flight plan (1)',\n      TextPart: 'This message is expected to succeed.',\n      CustomID: 'order-1001',\n    },\n    {\n      From: { Email: 'pilot@example.com' },\n      To: [{ Email: 'not-a-valid-address' }],\n      Subject: 'Your flight plan (2)',\n      TextPart: 'This message is expected to fail.',\n      CustomID: 'order-1002',\n    },\n  ],\n  AdvanceErrorHandling: true,\n};\n\nconst result: LibraryResponse<SendEmailV3_1.Response> = await mailjet\n  .post('send', { version: 'v3.1' })\n  .request(data);\n\nconst succeeded = result.body.Messages.filter((message) => message.Status === 'success');\nconst failed = result.body.Messages.filter((message) => message.Status !== 'success');\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Note that ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["failed"]}," being non-empty does ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["not"]}," mean the promise rejected — the request itself succeeded."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"retrying-without-duplicating-sends","__idx":18},"children":["Retrying without duplicating sends"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Blindly retrying a whole batch resends messages that already succeeded. To retry safely:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Give every message a unique ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CustomID"]}," before you send it, and record it against your own order or notification ID."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Collect only the messages whose ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Status"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error"]}," — never re-include successes."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use the failed entry's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Errors[].StatusCode"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ErrorCode"]}," to decide whether a retry makes sense. Validation errors (invalid recipient, malformed address, blocked domain) will fail again unless the message itself changes; transient errors (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["StatusCode >= 500"]},") may succeed."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Resubmit only the failed messages, reusing the same ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CustomID"]},", so retries stay correlated in your logs and in Mailjet's."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treat a request-level rejection (network failure, auth failure, malformed payload) differently: Mailjet never processed the batch, so the entire ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Messages"]}," array is safe to retry as-is."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A runnable example lives in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs/tree/master/examples/node/src/batchSend.js"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["examples/node/src/batchSend.js"]}]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"request-examples","__idx":19},"children":["Request examples"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"post--create-an-object","__idx":20},"children":["POST — create an object"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet\n  .post('contact')\n  .request({\n    Email: 'passenger@example.com',\n    IsExcludedFromCampaigns: true,\n    Name: 'New Contact'\n  })\n  .then((result) => console.log(result.body))\n  .catch((err) => console.log(err.statusCode));\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"post--endpoints-with-an-action","__idx":21},"children":["POST — endpoints with an action"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Call ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".id()"]}," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["before"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".action()"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet\n  .post('contact')\n  .id(contactID)\n  .action('managecontactslists')\n  .request({\n    ContactsLists: [\n      {\n        ListID: listID,\n        Action: 'addnoforce'\n      }\n    ]\n  })\n  .then((result) => console.log(result.body))\n  .catch((err) => console.log(err.statusCode));\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--all-objects","__idx":22},"children":["GET — all objects"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet.get('contact').request();\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--with-filters","__idx":23},"children":["GET — with filters"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Query parameters go in the second ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".request()"]}," argument:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet.get('contact').request({}, { IsExcludedFromCampaigns: false });\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"get--a-single-object","__idx":24},"children":["GET — a single object"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet.get('contact').id(contactID).request();\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["contact"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["contactdata"]}," resources, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".id()"]}," also accepts a contact's ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["email address"]}," instead of the numeric ID (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".id('user@example.com')"]},"). Pass it as-is — the SDK does not URL-encode it, which matches what the REST API expects."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"put--update-an-object","__idx":25},"children":["PUT — update an object"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," in the Mailjet API behaves like a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PATCH"]},": only the properties you send are updated, and non-mandatory properties can be omitted."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each entry in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Data"]}," must be an object with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Name"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Value"]}," keys, where ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Name"]}," matches a property already defined via ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dev.mailjet.com/email/reference/contacts/contact-properties/#v3_post_contactmetadata"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/contactmetadata"]}]},". Sending the property directly (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{ first_name: 'John' }"]},") instead of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{ Name: 'first_name', Value: 'John' }"]}," returns an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Invalid key name"]}," error."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet\n  .put('contactdata')\n  .id(contactID)\n  .request({\n    Data: [\n      { Name: 'first_name', Value: 'John' },\n      { Name: 'last_name', Value: 'Smith' }\n    ]\n  });\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"updating-template-content","__idx":26},"children":["Updating template content"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST"]}," on the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["template"]}," resource only updates metadata (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Name"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Categories"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Purposes"]},", …). It does ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["not"]}," touch the template body, so changes made that way appear in a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET template"]}," response but never in the Mailjet App editor. To update the actual content, target the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["template/{id}/detailcontent"]}," sub-resource:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet\n  .put('template')\n  .id(templateID)\n  .action('detailcontent')\n  .request({\n    'Html-part': '<html><body><p>Hello {{var:name}}</p></body></html>',\n    'Text-part': 'Hello {{var:name}}'\n  });\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"delete--remove-an-object","__idx":27},"children":["DELETE — remove an object"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A successful ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DELETE"]}," returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["204 No Content"]}," with no response body."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"mailjet.delete('template').id(templateID).request();\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["204"]}," here — and a subsequent ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["404"]}," on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET template/{id}"]}," — confirms the template was removed API-side."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"deleting-a-contact-gdpr","__idx":28},"children":["Deleting a contact (GDPR)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Contact deletion uses a dedicated ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v4"]}," endpoint, so the resource name is the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["plural"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["contacts"]}," and the version must be set explicitly:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"await mailjet\n  .delete('contacts', { version: 'v4' })\n  .id(contactID)\n  .request();\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dev.mailjet.com/email/reference/contacts/contact/#v4_delete_contact_contact_ID"},"children":["Delete a contact"]}," for details."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sms-api-1","__idx":29},"children":["SMS API"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const Mailjet = require('node-mailjet');\n\nconst mailjet = Mailjet.smsConnect(process.env.MJ_API_TOKEN, {\n  config: { version: 'v4' }\n});\n\nmailjet\n  .post('sms-send')\n  .request({\n    Text: 'Have a nice SMS flight with Mailjet!',\n    To: '+33600000000',\n    From: 'MJPilot'\n  })\n  .then((result) => console.log(result.body))\n  .catch((err) => console.log(err.statusCode));\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-applications","__idx":30},"children":["Example applications"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The repository includes runnable examples for several environments:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs/tree/master/examples/browser"},"children":["Browser"]}," — RequireJS-based request playground"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs/tree/master/examples/node"},"children":["Node"]}," — simple request scripts"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs/tree/master/examples/sendmail"},"children":["Sendmail"]}," — Express app that lists contacts and sends email"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs/tree/master/examples/react"},"children":["React"]}," — React request playground"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs/tree/master/examples/firebase"},"children":["Firebase"]}," — Firebase Functions for static and query-driven sends"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Browser-side examples still require a proxy because of CORS."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"contribute","__idx":31},"children":["Contribute"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK is open source. Fork the repository, branch, implement your fix or feature, document it, and open a pull request at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/mailjet-apiv3-nodejs"},"children":["mailjet/mailjet-apiv3-nodejs"]},". Documentation improvements belong in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/mailjet/api-documentation"},"children":["API documentation repo"]},"."]}]},"headings":[{"value":"Node.js SDK","id":"nodejs-sdk","depth":1},{"value":"Compatibility","id":"compatibility","depth":2},{"value":"Upgrading to v7","id":"upgrading-to-v7","depth":2},{"value":"Installation","id":"installation","depth":2},{"value":"Set up the client","id":"set-up-the-client","depth":2},{"value":"Authentication","id":"authentication","depth":3},{"value":"Email API and Send API","id":"email-api-and-send-api","depth":3},{"value":"SMS API","id":"sms-api","depth":3},{"value":"Send your first email","id":"send-your-first-email","depth":2},{"value":"Configuration","id":"configuration","depth":2},{"value":"Options","id":"options","depth":3},{"value":"Config","id":"config","depth":3},{"value":"API versioning","id":"api-versioning","depth":4},{"value":"Host URL","id":"host-url","depth":4},{"value":"Response output","id":"response-output","depth":4},{"value":"Disable the API call","id":"disable-the-api-call","depth":3},{"value":"TypeScript","id":"typescript","depth":2},{"value":"Batch sending and partial failures","id":"batch-sending-and-partial-failures","depth":2},{"value":"Retrying without duplicating sends","id":"retrying-without-duplicating-sends","depth":3},{"value":"Request examples","id":"request-examples","depth":2},{"value":"POST — create an object","id":"post--create-an-object","depth":3},{"value":"POST — endpoints with an action","id":"post--endpoints-with-an-action","depth":3},{"value":"GET — all objects","id":"get--all-objects","depth":3},{"value":"GET — with filters","id":"get--with-filters","depth":3},{"value":"GET — a single object","id":"get--a-single-object","depth":3},{"value":"PUT — update an object","id":"put--update-an-object","depth":3},{"value":"Updating template content","id":"updating-template-content","depth":4},{"value":"DELETE — remove an object","id":"delete--remove-an-object","depth":3},{"value":"Deleting a contact (GDPR)","id":"deleting-a-contact-gdpr","depth":4},{"value":"SMS API","id":"sms-api-1","depth":2},{"value":"Example applications","id":"example-applications","depth":2},{"value":"Contribute","id":"contribute","depth":2}],"frontmatter":{"title":"Mailjet Node.js SDK","seo":{"title":"Mailjet Node.js SDK","description":"Install and use the official Mailjet Node.js SDK: authentication, sending with Send API v3.1, batch sending, TypeScript types, configuration and SMS."}},"lastModified":"2026-08-26T16:26:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/email-api/developer-tools/nodejs","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}