- How to send an API email
- Next steps
These instructions describe how to send your first email using cURL calls. This is one of many ways to send email with the SendGrid - we also have PHP, Python, Node.js, Java, C#, Go, and Ruby libraries.
Before you can start using the API, you need to do the following:
Curl comes standard on Mac operating systems.
Your API call must have the following components:
- A Host. The host for Web API v3 requests is always https://sendgrid.com/v3/
- An Authorization Header
- An API Key within the Authorization Header
- A Request. When submitting data to a resource via POST or PUT, you must submit your payload in JSON.
To Send an email using the SendGrid API:
1 2 3 4 5
- Copy the curl example above.
- Paste the curl call into your favorite text editor.
- Copy your API key and paste it in the authorization header.
- In the data section, specify the “to”, “from”, and “reply to” names and email addresses and enter a subject.
- Copy the code and paste it in your terminal.
- Hit Enter.
- Check the inbox of the address you specified as the “to” email and see your message!
If you have not yet set up Sender Authentication in your account, you may need to check your spam folder for the email you just sent.
All responses are returned in JSON format. We specify this by sending the
Content-Type header. The Web API v3 provides a selection of response codes,content-type headers, and pagination options to help you interpret the responses to your API requests.
For more information on SendGrid and where you can go from here, check out these pages: