Rate this page:

v2 API Node.js Code Example

We recommend using v3 SendGrid Node.js, our client library, available on GitHub, with full documentation.

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.

Using SendGrid's Node.js Library

// using SendGrid's Node.js Library
// https://github.com/sendgrid/sendgrid-nodejs
const sendgrid = require("sendgrid")("SENDGRID_APIKEY");
const email = new sendgrid.Email();

email.setSubject("Sending an email with SendGrid is Fun");
email.setHtml("and easy to do anywhere, even with Node.js");

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the SendGrid tag on Stack Overflow.


        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more