> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailglyph.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> List templates with the MailGlyph Go SDK.

Use a **secret key** client for template methods.

```go theme={null}
import (
  "context"
  "os"

  mailglyph "github.com/MailGlyph/mailglyph-go"
)

client := mailglyph.New(os.Getenv("MAILGLYPH_SECRET_KEY"))
ctx := context.Background()
```

## List templates (`Templates.List`)

```go theme={null}
limit := 20
templateType := "TRANSACTIONAL"
search := "welcome"

page, err := client.Templates.List(ctx, &mailglyph.ListTemplatesParams{
  Limit: &limit,
  Type: &templateType,
  Search: &search,
})
if err != nil {
  panic(err)
}

println(page.Total, page.TotalPages, len(page.Data))
```

You can paginate with `cursor`:

```go theme={null}
cursor := "next_cursor_value"

nextPage, err := client.Templates.List(ctx, &mailglyph.ListTemplatesParams{
  Limit: &limit,
  Cursor: &cursor,
})
if err != nil {
  panic(err)
}

println(len(nextPage.Data))
```

See full details in the [Templates API reference](https://docs.mailglyph.com/api-reference/templates/listTemplates.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.