API Keys work for v3 API calls and for sending email. API endpoints prior to v3 do not support API keys at this time.

What are API Keys?

API Keys allow you to generate an authentication credential that is separate from your username and password. They are independent from one another and are easily disposable. You should create unique API keys for each of your applications or servers so that you can easily revoke them without disrupting other systems if needed.

You can use API Key Permissions to define what actions an API Key can be used to authenticate.

Managing API Keys

You can manage your API Keys from the SendGrid UI. Additionally, you can manage your API keys via the API itself.

There is a limit of 100 API Keys per account.

Using API Keys

Via SMTP

For sending via SMTP, provide the string apikey as the SMTP username, and use your API Key as the password.

Via HTTP

For sending via HTTP using the v2 mail send or the v3 mail send endpoint, add an Authorization header to your message. Then provide your API key as a bearer token in that header. For example,

1
Authorization: Bearer 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

Sending an email via a cURL request to the v3 mail send endpoint using an API Key would look like:

$

1
2
3
4
5
curl -i --request POST 
--url https://api.sendgrid.com/v3/mail/send 
--header 'Authorization: Bearer YOUR_API_KEY_HERE' 
--header 'Content-Type: application/json' 
--data '{"personalizations": [{"to": [{"email": "recipient@example.com"}]}],"from": {"email": "sender@example.com"},"subject": "Hello, World!","content": [{"type": "text/plain", "value": "Howdy!"}]}'

Look for a 202 Accepted in the HTTP response headers.

Via a SendGrid Open Source Library

If you’re using one of our Open Source Libraries, see the documentation for that specific library on how to send using an API Key.