How to Send a Test Email via SendGrid API using Postman

Objective

Sometimes when you're integrating SendGrid API, you might face issues sending emails. That's a great moment to start debugging using Postman and check if the API call is being correctly processed.

Product

Twilio SendGrid Email API.

 

User Account Permission/Role Required

We recommend using an API with full access to run this test. If that is not feasible, check these articles to find out what permissions are required to use this endpoint:
Types of API keys
Teammate permissions (if you are not an admin).

 

Procedure

To create a test email using SendGrid API in Postman, you'll need to use the API endpoint along with your SendGrid API key. Below is a basic example of how you can structure the request in Postman. How to set up the request:

    • Method: POST
    • URL: https://api.sendgrid.com/v3/mail/send
    • Headers:
    • Authorization: Bearer Token. In the Token field, insert your full SENDGRID_API_KEY:
      Param s 
Type 
Authorization • 
Headers (8) 
Bearer Token 
Body 
Pre-request Script 
Tests Settings 
Heads up! These parameters hold sensitive data. TO keep this data secure While working in a collaborative environmen 
variables 
The authorizati 
header Will be automatically generated when 
you send ther uest. Learn more about authorization 7 
Token 
SG.q-31D! 
-Cdn.
    • Content-Type: application/JSON
    • Body:
      • Select the raw format and choose JSON:
      • Example JSON body for a basic email:
{
"personalizations": [
{
"to": [
{
"email": "recipient@example.com"
}
]
}
],
"from": {
"email": "sender@example.com"
},
"subject": "Test subject",
"content": [
{
"type": "text/plain",
"value": "This is a test email sent via SendGrid API in Postman."
}
]
}
    • Send the request:
      • Click the "Send" button in Postman to execute the request.

According to our documentation only four items are required to do a basic test for this endpoint. The "personalizations" object containing:

  1. A "To" object containing at least one recipient email address
  2. The "From" object containing at least one sender address
  3. A "Subject" object containing a string
  4. The "Content" object containing the "Type" and "Value"

Note: The "from" email address must belong to a domain previously authenticated on your SendGrid account. 

This example demonstrates a basic email structure with a plain text content type. You can modify and expand the JSON body to include more advanced features like HTML content, CC/BCC, attachments, and more as needed.

How to send a test email using curl command

Please make sure to have curl installed and properly configured on your system to execute below-mentioned command.

You can send an email using SendGrid's API with curl by making a POST request to SendGrid's mail sending endpoint.

You'll need to replace "YOUR_API_KEY", "from@example.com", "to@example.com", "Subject", and "Your email content" with your actual API key, sender email, recipient email, email subject, and email content respectively.

Example of a curl command

bash

curl -X "POST" "https://api.sendgrid.com/v3/mail/send" \
     -H 'Authorization: Bearer YOUR_API_KEY' \
     -H 'Content-Type: application/json' \
     -d $'{
  "personalizations": [
    {
      "to": [
        {
          "email": "to@example.com"
        }
      ],
      "subject": "Subject"
    }
  ],
  "from": {
    "email": "from@example.com"
  },
  "content": [
    {
      "type": "text/plain",
      "value": "Your email content"
    }
  ]
}'

 

Have more questions? Submit a request