How To Create Api Key In Sendgrid

In this article, we will discover the steps for generating an API key in SendGrid, a widely-used email service hosted in the cloud that allows for email sending and management. Creating an API key is essential as it acts as a distinctive code for verifying your application or user in SendGrid.

The process for creating an API key in SendGrid is simple and straightforward. Here’s a step-by-step guide on how you can create one.

Step 1: Login to your SendGrid account

The first thing you have to do is log in to your SendGrid account. If you don’t have an account, you can sign up for a new one. SendGrid offers a free tier which you can use for testing purposes.

Step 2: Access the API Keys Section

Once you’re logged in, navigate to the dashboard. On the left side, you will see a menu. Click on the Settings tab, and then select API Keys.

Step 3: Create API Key

Click on the Create API Key button on the right side of the page. You’ll be prompted to choose a name for your new API key. Make sure to keep the name relevant for easy identification in the future.

Step 4: Set Permissions

Next, you’ll need to set permissions for your new API key. In SendGrid, there are three levels of access – Full Access, Restricted Access, and Billing Access. Choose the permission level that best suits your needs.

Step 5: Create and Store the API Key

Once you’ve set the permissions, click the Create & View button. You’ll see your newly generated API key displayed only once. Make sure to take note of your API key and store it securely. If you lose it, you can’t recover it and will have to create a new one.

How to Use SendGrid API Key

Now that you’ve created your API key, you can use it to send emails through SendGrid. Here’s a simple way to do that using Python.

Firstly, install the SendGrid library:

    pip install sendgrid

Next, use the following template to send an email:

    import sendgrid
    from sendgrid.helpers.mail import *

    def send_email():
        sg = sendgrid.SendGridAPIClient(api_key='Your API Key Here')
        from_email = Email("[email protected]")
        to_email = To("[email protected]")
        subject = "Sending with SendGrid is Fun"
        content = Content("text/plain", "and easy to do anywhere, even with Python")
        mail = Mail(from_email, to_email, subject, content)
        response =

Remember to replace ‘Your API Key Here’ with your actual SendGrid API key. Also, change the email addresses, subject, and content as per your requirements.


In conclusion, creating an API key in SendGrid is a simple process, and it opens up the powerful functionalities of the SendGrid service. Just remember to handle your keys securely to avoid unauthorized access to your SendGrid account.