Skip to main content

Get

Retrieve a template by ID or alias using the default context.
func (s *TemplatesSvcImpl) Get(identifier string) (*Template, error)

Parameters

identifier
string
required
The template ID or alias.

Returns

Returns a *Template containing the full template details.

Example

template, err := client.Templates.Get("template_id_or_alias")
if err != nil {
  panic(err)
}

fmt.Println("Template Name:", template.Name)
fmt.Println("Status:", template.Status)

GetWithContext

Retrieve a template by ID or alias with a custom context.
func (s *TemplatesSvcImpl) GetWithContext(ctx context.Context, identifier string) (*Template, error)

Parameters

ctx
context.Context
required
Context for the request, useful for timeouts and cancellation.
identifier
string
required
The template ID or alias.

Returns

Returns a *Template containing the full template details.

Example

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

template, err := client.Templates.GetWithContext(ctx, "welcome-email")
if err != nil {
  panic(err)
}

fmt.Println("Template:", template.Name)

Types

Template

Full template object returned by the Get endpoint.
type Template struct {
  Object      string                      `json:"object"`
  Id          string                      `json:"id"`
  Alias       string                      `json:"alias"`
  Name        string                      `json:"name"`
  CreatedAt   string                      `json:"created_at"`
  UpdatedAt   string                      `json:"updated_at"`
  Status      string                      `json:"status"`
  PublishedAt string                      `json:"published_at"`
  From        string                      `json:"from"`
  Subject     string                      `json:"subject"`
  ReplyTo     any                         `json:"reply_to"` // string, []string, or null
  Html        string                      `json:"html"`
  Text        string                      `json:"text"`
  Variables   []*TemplateVariableResponse `json:"variables"`
}
Object
string
The object type, always “template”.
Id
string
The unique identifier of the template.
Alias
string
The unique alias of the template.
Name
string
The name of the template.
CreatedAt
string
ISO 8601 timestamp of when the template was created.
UpdatedAt
string
ISO 8601 timestamp of when the template was last updated.
Status
string
The status of the template (e.g., “draft”, “published”).
PublishedAt
string
ISO 8601 timestamp of when the template was published.
From
string
The sender email address.
Subject
string
The email subject line.
ReplyTo
any
Reply-to email address. Can be a string, array of strings, or null.
Html
string
The HTML content of the email template.
Text
string
The plain text version of the email template.
Variables
[]*TemplateVariableResponse
Array of variables defined in the template with their full details.

TemplateVariableResponse

Represents a variable in a template response with additional metadata.
type TemplateVariableResponse struct {
  Id            string       `json:"id"`
  Key           string       `json:"key"`
  Type          VariableType `json:"type"`
  FallbackValue any          `json:"fallback_value"`
  CreatedAt     string       `json:"created_at"`
  UpdatedAt     string       `json:"updated_at"`
}
Id
string
The unique identifier of the variable.
Key
string
The variable name.
Type
VariableType
The type of the variable (“string” or “number”).
FallbackValue
any
Default value to use if the variable is not provided.
CreatedAt
string
ISO 8601 timestamp of when the variable was created.
UpdatedAt
string
ISO 8601 timestamp of when the variable was last updated.

Build docs developers (and LLMs) love