Skip to main content

Publish

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

Parameters

identifier
string
required
The template ID or alias.

Returns

Returns a *PublishTemplateResponse containing the published template ID.

Example

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

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

PublishWithContext

Publish a template by ID or alias with a custom context.
func (s *TemplatesSvcImpl) PublishWithContext(ctx context.Context, identifier string) (*PublishTemplateResponse, 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 *PublishTemplateResponse containing the published template ID.

Example

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

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

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

Types

PublishTemplateResponse

Response from publishing a template.
type PublishTemplateResponse struct {
  Id     string `json:"id"`
  Object string `json:"object"`
}
Id
string
The unique identifier of the published template.
Object
string
The object type, always “template”.

Build docs developers (and LLMs) love