Documentation Index
Fetch the complete documentation index at: https://mintlify.com/resend/resend-go/llms.txt
Use this file to discover all available pages before exploring further.
List
Retrieves a list of emails.
func (s *EmailsSvcImpl) List() (ListEmailsResponse, error)
Returns
Show ListEmailsResponse fields
The object type (“list”).
Indicates whether there are more emails available beyond this page.
Array of email objects. See Get Email for Email field details.
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
Returns
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
Pagination options for the list request.
Maximum number of emails to return. Must be a pointer to an integer.
Cursor for forward pagination. Returns emails after this email ID. Must be a pointer to a string.
Cursor for backward pagination. Returns emails before this email ID. Must be a pointer to a string.
Returns
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))
}
}