Skip to main content

List

Retrieves a list of emails.
func (s *EmailsSvcImpl) List() (ListEmailsResponse, error)

Returns

response
ListEmailsResponse

Example

package main

import (
	"fmt"
	"github.com/resend/resend-go/v3"
)

func main() {
	client := resend.NewClient("re_123456789")

	listResp, err := client.Emails.List()
	if err != nil {
		panic(err)
	}

	fmt.Printf("Found %d emails\n", len(listResp.Data))
	fmt.Printf("Has more emails: %v\n", listResp.HasMore)

	for _, email := range listResp.Data {
		fmt.Printf("- ID: %s, Subject: %s, To: %v\n",
			email.Id, email.Subject, email.To)
	}
}

ListWithContext

Retrieves a list of emails with context.
func (s *EmailsSvcImpl) ListWithContext(ctx context.Context) (ListEmailsResponse, error)

Parameters

ctx
context.Context
required
Context for the request.

Returns

response
ListEmailsResponse
See List for response field details.

Example

package main

import (
	"context"
	"fmt"
	"github.com/resend/resend-go/v3"
)

func main() {
	ctx := context.Background()
	client := resend.NewClient("re_123456789")

	listResp, err := client.Emails.ListWithContext(ctx)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Found %d emails\n", len(listResp.Data))
}

ListWithOptions

Retrieves a list of emails with pagination options.
func (s *EmailsSvcImpl) ListWithOptions(ctx context.Context, options *ListOptions) (ListEmailsResponse, error)

Parameters

ctx
context.Context
required
Context for the request.
options
*ListOptions
Pagination options for the list request.

Returns

response
ListEmailsResponse
See List for response field details.

Example

package main

import (
	"context"
	"fmt"
	"github.com/resend/resend-go/v3"
)

func main() {
	ctx := context.Background()
	client := resend.NewClient("re_123456789")

	// List with limit
	limit := 10
	listResp, err := client.Emails.ListWithOptions(ctx, &resend.ListOptions{
		Limit: &limit,
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Found %d emails (limited to 10)\n", len(listResp.Data))

	// Cursor-based pagination
	if listResp.HasMore && len(listResp.Data) > 0 {
		lastEmailID := listResp.Data[len(listResp.Data)-1].Id
		nextPage, err := client.Emails.ListWithOptions(ctx, &resend.ListOptions{
			Limit: &limit,
			After: &lastEmailID,
		})
		if err != nil {
			panic(err)
		}
		fmt.Printf("Found %d more emails in next page\n", len(nextPage.Data))
	}
}

Build docs developers (and LLMs) love