---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v2-nodejs-code-example#article
headline: v2 API Node.js Code Example
description: Explore the v3 SendGrid Node.js client library on GitHub, fully documented yet lacking V2 API support. Utilize older version if needed.
url: https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v2-nodejs-code-example
inLanguage: en
dateModified: 2026-07-23T16:57:51.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# v2 API Node.js Code Example

> \[!WARNING]
>
> To access all the latest features and upcoming developments, please see our [v3 API](/docs/sendgrid/api-reference). For assistance with transitioning, refer to our [migration guide](/docs/sendgrid/for-developers/migration-guides/v2-to-v3-api).

> \[!NOTE]
>
> We recommend using [v3](/docs/sendgrid/for-developers/sending-email/quickstart-nodejs) SendGrid Node.js, our client library, [available on GitHub](https://github.com/sendgrid/sendgrid-nodejs), with full documentation.

> \[!NOTE]
>
> 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](https://github.com/sendgrid/sendgrid-nodejs/blob/main/TROUBLESHOOTING.md#v2).

## Using SendGrid's Node.js Library

The following example sends an email with the Twilio SendGrid Node.js library:

```javascript title="Send email with the Twilio SendGrid 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.addTo("test@sendgrid.com");
email.setFrom("you@example.com");
email.setSubject("Sending an email with SendGrid is Fun");
email.setHtml("and easy to do anywhere, even with Node.js");

sendgrid.send(email);
```
