Nascent Prototype Metaverse
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


6.3.0 • Public • Published

BuildStatus npm version Email Notifications Badge

This package is part of a monorepo, please see this README for details.

Client for the Sendgrid v3 Web API

This client library is used by the other SendGrid service packages to make requests to the Sendgrid v3 Web API. You can also use it independently to make custom requests to the SendGrid v3 Web API and other HTTP APIs.

To be notified when this package is updated, please subscribe to email notifications for releases and breaking changes.



  • Node.js version 6, 7 or 8
  • A SendGrid account, sign up for free to send up to 40,000 emails for the first 30 days or check out our pricing.

Obtain an API Key

Grab your API Key from the SendGrid UI.

Setup Environment Variables

Do not hard code your SendGrid API Key into your code. Instead, use an environment variable or some other secure means of protecting your SendGrid API Key. Following is an example of using an environment variable.

Update the development environment with your SENDGRID_API_KEY, for example:

echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env

Install Package

The following recommended installation requires npm. If you are unfamiliar with npm, see the npm docs. Npm comes installed with Node.js since node version 0.8.x therefore you likely already have it.

npm install --save @sendgrid/client

You may also use yarn to install.

yarn add @sendgrid/client

General v3 Web API Usage Example

Please see for all endpoint examples for the SendGrid v3 Web API.

const client = require('@sendgrid/client');
const request = {
  method: 'GET',
  url: '/v3/api_keys'
.then(([response, body]) => {

Add a Custom Default Header

sgClient.setDefaultHeader('User-Agent', 'Some user agent string');

Change Request Defaults

sgClient.setDefaultRequest('baseUrl', '');

Overwrite Promise Implementation

You can overwrite the promise implementation you want the client to use. Defaults to the ES6 Promise:

global.Promise = require('bluebird');

Instantiate Client Instances Manually

const {Client} = require('@sendgrid/client');
const sgClient1 = new Client();
const sgClient2 = new Client();


All updates to this library are documented in our CHANGELOG and releases. You may also subscribe to email release notifications for releases and breaking changes.


If you are interested in the future direction of this project, please take a look at our open issues and pull requests. We would love to hear your feedback.

How to Contribute

We encourage contribution to our libraries (you might even score some nifty swag), please see our CONTRIBUTING guide for details.


Please see our troubleshooting guide for common library issues.


@sendgrid/client is guided and supported by the SendGrid Developer Experience Team.

@sendgrid/client is maintained and funded by SendGrid, Inc. The names and logos for @sendgrid/client are trademarks of SendGrid, Inc.

SendGrid Logo




npm i @sendgrid/client

Downloadsweekly downloads









last publish


  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar