Skip to main content
Encore is an open-source Go framework that provisions infrastructure directly from your application code, with built-in observability and cloud deployment.

Use this pre-built prompt to get started faster.

CursorOpen in Cursor

Prerequisites

To get the most out of this guide, you’ll need to:

1. Create an Encore app

encore app create --lang=go my-app
Then install the Resend Go SDK:
go get github.com/resend/resend-go/v3

2. Set your API key

Encore has built-in secrets management. Store your Resend API key as a secret - no .env files needed:
encore secret set --type dev,local,pr,production ResendAPIKey

3. Send email using an API endpoint

Create an email service directory and define your endpoint:
email/email.go
package email

import (
    "context"

    "github.com/resend/resend-go/v3"
)

var secrets struct {
    ResendAPIKey string
}

type SendRequest struct {
    To      string `json:"to"`
    Subject string `json:"subject"`
    HTML    string `json:"html"`
}

type SendResponse struct {
    ID string `json:"id"`
}

//encore:api public method=POST path=/email/send
func Send(ctx context.Context, req *SendRequest) (*SendResponse, error) {
    client := resend.NewClient(secrets.ResendAPIKey)

    sent, err := client.Emails.Send(&resend.SendEmailRequest{
        From:    "Acme <onboarding@resend.dev>",
        To:      []string{req.To},
        Subject: req.Subject,
        Html:    req.HTML,
    })
    if err != nil {
        return nil, err
    }

    return &SendResponse{ID: sent.Id}, nil
}

4. Run the app

encore run
Your API is running at http://localhost:4000. Send a test email:
curl -X POST http://localhost:4000/email/send \
  -H "Content-Type: application/json" \
  -d '{"to":"delivered@resend.dev","subject":"Hello World","html":"<strong>It works!</strong>"}'

5. AI skills for Encore Go

If you’re using an AI coding assistant, install the Encore skills for context-aware help with APIs, services, Pub/Sub, databases, auth, and more:
npx skills add encoredev/skills

6. Try it yourself

Encore Go Docs

Encore Go documentation

Resend Go SDK

Resend Go SDK on GitHub