Skip to contentSkip to navigationSkip to topbar
On this page

v2 API Node.js Code Example


(warning)

This documentation is for the SendGrid Web API v2

We will deprecate this version on February 10, 2025. To access all the latest features and upcoming developments, please see our v3 API. For assistance with transitioning, refer to our migration guide.

(information)
(information)

Info

The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see Continue Using V2 in Node.js(link takes you to an external page).


Using SendGrid's Node.js Library

using-sendgrids-nodejs-library page anchor
1
// using SendGrid's Node.js Library
2
// https://github.com/sendgrid/sendgrid-nodejs
3
const sendgrid = require("sendgrid")("SENDGRID_APIKEY");
4
const email = new sendgrid.Email();
5
6
email.addTo("test@sendgrid.com");
7
email.setFrom("you@youremail.com");
8
email.setSubject("Sending an email with SendGrid is Fun");
9
email.setHtml("and easy to do anywhere, even with Node.js");
10
11
sendgrid.send(email);