The process for registering, activating and authorizing an API key with Sendgrid has recently changed and is a bit more complex.

1. Signup for Sendgrid account

Go to https://signup.sendgrid.com/ to register an account.
Note: If you are behind a VPN, or public / untrusted IP address your account may immediately get banned. There is typically no resolving this with Sendgrid customer support. You may need to create a new email and attempt the account creation from a more trusted IP address.

2. Fill out the info form

Fill out the personal and company info. If you are doing this for testing purposes you can put your own name as the company name and any domain address you wish. Otherwise, if you will be using this for a real marketing campaign, be sure to put accurate and real info.

3. Verify account

After you have created an account an email confirmation will be sent. Make sure to open this in the same browser you are currently logged into.

4. Configure a Single Sender

After your email has been confirmed, you will be redirected back to the Sendgrid account dashboard. You will have two options, Domain Authentication and Single Sender Verification. Select Single Sender Verification.

5. Fill out Single Sender Form

Fill out the form to create a new "sender". You can add your own name as a company name if you do not have one. If you are using this sender for a real marketing campaign, make sure to provide accurate info.

6. Verify Sender

After creating your sender, you will get a verification email from Sendgrid. Make sure you are clicking the button in the verification email in the same browser your are logged into. If you don't, the verification will fail.

7. Sender Verified

After clicking the verification button in the email, you should get the following success message. Make sure you have a green checkmark in the "verified" column, otherwise you will not be able to generate an API key.

8. Start API Key generation

In the Sendgrid dashboard, there should be a green callout that says "Send your first email.." with a button. Click this "Create An API key" button. You should see two options, Web API and SMTP Relay. Select Web API.

9.  Select Node as the Language

10. Get API Key for testing

In the next screen, you will be prompted to generate a key and name it. Then, you will be presented with a number of steps to complete. Copy the API key that Sendgrid is showing you, this will be the API key that you will need to use for testing. After you have copied the API key somewhere (you will not be able to access this again), click the "Next Verify Integration" button.

11. Download zip file

Attached to this lecture is a zip file. Download and extract the contents somewhere outside of your project directory.

12. Install dependencies in the test project

Open up your terminal and change into the sengrid-test directory you extracted in the previous step. Run npm install in this directory.

13. Add your API key to the test script

In your code editor, open the test.js file and change the following lines, making sure to use your own personal info:

line 4:

sgMail.setApiKey(process.env.SENDGRID_API_KEY);

change to

sgMail.setApiKey("SG.key_redacted_add_your_key");

line 6 and 7

  to: 'test@example.com',
  from: 'test@example.com',

change to

  to: 'bob@test.com',
  from: 'bob@sender.com',

Make sure the to address is a real email that you can check - Gmail addresses work the best.

Make sure that the from address matches the "Sender" address that we confirmed a little bit ago.

14. Run the test script

In the sendgrid-test directory, run node test.js in the terminal. You should not be seeing any errors in the terminal. If you get a "Forbidden" error message, it likely means that the from address still shows the test@example.com address. The email that was specified in the to address should receive the test email. Make sure this occurs before moving to the next step.

15. Verify the test

Head back to the Sendgrid dashboard and click the "Verify Integration" button

16. Success?

If the verification was successful, you should see this message:

17. Finishing Up

If the verification was successful you can continue on with the course. It might be a good idea to keep the sendgrid-test directory and script for when you need to refer to your API key later. To be clear, if you do not complete this verification step (only occurs once per sender), you will not be able to use an API key in the project we are building in the course.