Event Webhook Go Code Example

We recommend using our official Go SDK, our client library with full documentation, when integrating with SendGrid's Inbound Parse Webhook.

In this example, we want to parse all emails at address@email.sendgrid.biz and post the parsed email to http://sendgrid.biz/upload

Given this scenario, the following are the parameters you would set at the Parse API settings page:

Hostname: email.sendgrid.biz
URL: http://sendgrid.biz/upload

To test this scenario, we sent an email to example@example.com and created the following code:

package main

import (


func Parse (w http.ResponseWriter, req *http.Request) {
        //Get Email Values
        to := req.FormValue("from")
        subject := req.FormValue("subject")
        body:= req.FormValue("text")

        //Get Uploaded File
        file, handler, err := req.FormFile("attachment1")
        if err != nil {
        data, err := ioutil.ReadAll(file)
        if err != nil {
        err = ioutil.WriteFile(handler.Filename, data, 0777)
        if err != nil {

func main() {
        http.HandleFunc("/upload", Parse)
        err := http.ListenAndServe(":3000", nil)
        if err != nil {
                log.Fatal("ListenAndServe: ", err)

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the SendGrid tag on Stack Overflow.

Thank you for your feedback!

We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more