Skip to content
Advertisement

API Key does not start with “SG.” SendGrid

I am trying to set up SendGrid add-on in my Heroku NodeJS app. I created the API Key and set it as an environment variable.

The whole API key looks something like: SG.actualValue.bbb_cccccc

The first setup I did I set the whole key as as my SENDGRID_API_KEY and I got this error:

API key does not start with SG.

So, I realized the mistake and unset the environment variable and set it again only to the actualValue part of the whole key.

However, I still get the same error. I tried doing the same thing again or restarting the terminal(actually, whole laptop).

This is the test code I am trying to run from the SendGrid setup page:

JavaScript

I tried creating a new key and setting it, but I get the same error. I tried setting it to the whole key, but without “.SG” or just the bbb_ccccc part. Thank you in advance.

Advertisement

Answer

API key does not start with SG.

means the API key of SendGrid SHOULD start with SG. So you didn’t set the environment variables correctly. You need to check it. Just use console.log print the environment variables. Or, use

JavaScript

to start a console for your app, and use printenv to print the environment variables.

JavaScript

TIMES: 5 environment variable is set via heroku config vars:

enter image description here

E.g.

JavaScript
JavaScript

Received the email as expected:

enter image description here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement