Docs Get key
All server guides
Email Providers

Send one application message with SendGrid's SDK

Use the official SendGrid mail client with a restricted key and track provider acceptance separately from recipient delivery.

Reviewed

Install @sendgrid/mail and provide SENDGRID_API_KEY, APP_FROM, and TEST_TO from secure runtime configuration. Complete sender verification first. Before running this example, approve the sender, recipient, and copy: it sends a real message.

Submit through the official mail client

import sgMail from "@sendgrid/mail";
for (const key of ["SENDGRID_API_KEY", "APP_FROM", "TEST_TO"]) {
  if (!process.env[key]) throw new Error(`Missing ${key}`);
}
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const [response] = await sgMail.send({
  from: process.env.APP_FROM,
  to: process.env.TEST_TO,
  subject: "SendGrid controlled test",
  text: "A message from the approved sending identity.",
});
console.log({ acceptedStatus: response.statusCode });

Use the current quickstart for supported client versions. Keep any application correlation metadata non-sensitive; do not attach customer secrets as tracking arguments.

Check the asynchronous outcome

A 202 acceptance is not a delivery or inbox guarantee. Persist the application send intent, retain available provider correlation identifiers, and connect delivery/bounce evidence before production.

For a permission, sender, or quota rejection, fix that boundary rather than resubmitting repeatedly. A network timeout can hide a successful acceptance; inspect activity/events before an operator decides to retry.

The longer main-guide walkthrough covers the application flow. MailKite is a separate sending contract, not a drop-in replacement for a SendGrid key or event identifier.