---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v3-kotlin-code-example#article
headline: v3 API Kotlin Code Example
description: Integrate Twilio SendGrid using the Java client library with complete documentation. Detailed example with API integration tips and resources.
url: https://www.twilio.com/docs/sendgrid/for-developers/sending-email/v3-kotlin-code-example
inLanguage: en
dateModified: 2026-07-23T16:57:51.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# v3 API Kotlin Code Example

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

> \[!NOTE]
>
> Do you have an [API Key](https://app.sendgrid.com/settings/api_keys) yet? If not, go get one. You're going to need it to integrate!

## Using SendGrid's Java Library

The following Kotlin example sends an email using the Twilio SendGrid Java library. Set your API key, then build and send the message.

```kotlin title="Send an email from Kotlin with the Twilio SendGrid Java library"
// using SendGrid's Java Library
// https://github.com/sendgrid/sendgrid-java
import com.sendgrid.*;
import java.io.IOException;

class Example {
  private fun sendEmail() {

        val sendgrid = SendGrid("SENDGRID_APIKEY")
        val email = SendGrid.Email()

        email.addTo("test@sendgrid.com")
        email.setFrom("you@example.com")
        email.setSubject("Sending with SendGrid is Fun")
        email.setHtml("and easy to do anywhere, even with Kotlin")

        val response = sendgrid.send(email)
  }
}
```
