Skip to main content

List

Retrieve a list of templates with pagination options using the default context.
func (s *TemplatesSvcImpl) List(options *ListOptions) (*ListTemplatesResponse, error)

Parameters

options
*ListOptions
Pagination options for the list request.

Returns

Returns a *ListTemplatesResponse containing the list of templates.

Example

options := &resend.ListOptions{
  Limit: 10,
}

response, err := client.Templates.List(options)
if err != nil {
  panic(err)
}

for _, template := range response.Data {
  fmt.Println("Template:", template.Name, "Status:", template.Status)
}

ListWithContext

Retrieve a list of templates with custom context and pagination options.
func (s *TemplatesSvcImpl) ListWithContext(ctx context.Context, options *ListOptions) (*ListTemplatesResponse, error)

Parameters

ctx
context.Context
required
Context for the request, useful for timeouts and cancellation.
options
*ListOptions
Pagination options for the list request.

Returns

Returns a *ListTemplatesResponse containing the list of templates.

Example

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

options := &resend.ListOptions{
  Limit: 20,
}

response, err := client.Templates.ListWithContext(ctx, options)
if err != nil {
  panic(err)
}

fmt.Println("Has more:", response.HasMore)

Types

ListTemplatesResponse

Response from listing templates.
type ListTemplatesResponse struct {
  Object  string              `json:"object"`
  Data    []*TemplateListItem `json:"data"`
  HasMore bool                `json:"has_more"`
}
Object
string
The object type, always “list”.
Data
[]*TemplateListItem
Array of template items.
HasMore
bool
Indicates whether there are more templates available beyond the current page.

TemplateListItem

Represents a template in a list response.
type TemplateListItem struct {
  Id          string  `json:"id"`
  Name        string  `json:"name"`
  Status      string  `json:"status"`
  PublishedAt *string `json:"published_at"`
  CreatedAt   string  `json:"created_at"`
  UpdatedAt   string  `json:"updated_at"`
  Alias       string  `json:"alias"`
}
Id
string
The unique identifier of the template.
Name
string
The name of the template.
Status
string
The status of the template (e.g., “draft”, “published”).
PublishedAt
*string
ISO 8601 timestamp of when the template was published. Null if not published.
CreatedAt
string
ISO 8601 timestamp of when the template was created.
UpdatedAt
string
ISO 8601 timestamp of when the template was last updated.
Alias
string
The unique alias of the template.

Build docs developers (and LLMs) love