Skip to main content

Duplicate

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

Parameters

identifier
string
required
The template ID or alias to duplicate.

Returns

Returns a *DuplicateTemplateResponse containing the new template ID.

Example

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

fmt.Println("New template ID:", response.Id)

DuplicateWithContext

Duplicate a template by ID or alias with a custom context.
func (s *TemplatesSvcImpl) DuplicateWithContext(ctx context.Context, identifier string) (*DuplicateTemplateResponse, error)

Parameters

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

Returns

Returns a *DuplicateTemplateResponse containing the new template ID.

Example

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

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

fmt.Println("Duplicated template:", response.Id)

Types

DuplicateTemplateResponse

Response from duplicating a template.
type DuplicateTemplateResponse struct {
  Id     string `json:"id"`
  Object string `json:"object"`
}
Id
string
The unique identifier of the newly created duplicate template.
Object
string
The object type, always “template”.

Build docs developers (and LLMs) love