---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v2-go-code-example#article
headline: v2 API Go Code Example
description: Explore SendGrid Go, our client library available on GitHub. Despite not supporting V2 API, older versions can be utilized effectively.
url: https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v2-go-code-example
inLanguage: en
dateModified: 2026-07-23T16:57:51.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# v2 API Go Code Example

> \[!WARNING]
>
> To access all the latest features and upcoming developments, please see our [v3 API](/docs/sendgrid/api-reference). For assistance with transitioning, refer to our [migration guide](/docs/sendgrid/for-developers/migration-guides/v2-to-v3-api).

> \[!NOTE]
>
> We recommend using SendGrid Go, our client library, [available on GitHub](https://github.com/sendgrid/sendgrid-go), with full documentation.

> \[!NOTE]
>
> The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see [Continue Using V2 in Go](https://github.com/sendgrid/sendgrid-go/blob/main/TROUBLESHOOTING.md#v2).

## Using SendGrid's Go Library

The following example sends an email with the Twilio SendGrid Go library:

```go title="Send email with the Twilio SendGrid Go library"
// using SendGrid's Go Library
// https://github.com/sendgrid/sendgrid-go
package main

import (
    "github.com/sendgrid/sendgrid-go"
)

func main() {
    sg := sendgrid.NewSendGridClientWithApiKey("SENDGRID_APIKEY")

    message := sendgrid.NewMail()
    message.AddTo("test@sendgrid.com")
    message.SetFrom("you@example.com")
    message.SetSubject("Sending with SendGrid is Fun")
    message.SetHTML("and easy to do anywhere, even with Go")

    sg.Send(message)
}
```
