Pular para o conteúdo

TemplateService

Este conteúdo não está disponível em sua língua ainda.

Manages message templates with append-only versioning. Templates define the content delivered to campaign recipients, and can be translated into multiple locales with a review workflow before use.

Method Description
CreateTemplate Create a new template
UpdateTemplate Update a template (creates new version)
GetTemplate Get a template by ID
ListTemplates List templates for the organization
CreateTemplateTranslation Create a locale-specific translation
UpdateTemplateTranslation Update an existing translation
ListTemplateTranslations List translations for a template version
ApproveTemplateTranslation Approve a translation for use in campaigns

Create a new template (version 1).

Authorization: Requires Manager role or higher

Field Type Description
name string Template name (admin-facing label). Max 200 characters.
body string Template body with {{variable}} placeholders. Max 50,000 characters.
variables TemplateVariable[] Variable definitions.
title string User-facing title shown as the message subject to recipients. Max 200 characters.
type TemplateType Content format. Defaults to MARKDOWN if unspecified.
source_locale string Language of the template body (en, es, pt-BR, zh, ja). Defaults to the organization’s default locale.
Field Type Description
template Template The created template (version 1).

TypeScript (Connect-Web)

const response = await templateClient.createTemplate({
name: "security-update",
title: "Security Update",
body: "# Security Update\n\nHi {{name}},\n\nPlease review...",
type: TemplateType.MARKDOWN,
variables: [
{ name: "name", source: TemplateVariableSource.CUSTOM },
],
});

Go (gRPC)

resp, err := templateClient.CreateTemplate(ctx, &pidgrv1.CreateTemplateRequest{
Name: "security-update",
Title: "Security Update",
Body: "# Security Update\n\nHi {{name}},\n\nPlease review...",
Type: pidgrv1.TemplateType_TEMPLATE_TYPE_MARKDOWN,
Variables: []*pidgrv1.TemplateVariable{
{Name: "name", Source: pidgrv1.TemplateVariableSource_TEMPLATE_VARIABLE_SOURCE_CUSTOM},
},
})

Update a template. Creates a new version — previous versions are preserved.

Authorization: Requires Manager role or higher

Field Type Description
template_id string Template ID.
body string Updated template body with {{variable}} placeholders. Max 50,000 characters.
variables TemplateVariable[] Updated variable definitions.
Field Type Description
template Template The updated template with incremented version.

Authorization: Authenticated user within the organization

Field Type Description
template_id string Template ID.
version int32 Specific version to retrieve. 0 returns latest.
Field Type Description
template Template The template.

Authorization: Authenticated user within the organization

Field Type Description
pagination Pagination Pagination parameters.
type TemplateType Filter by template type. UNSPECIFIED returns all templates.
Field Type Description
templates Template[] List of templates (latest version of each).
pagination_meta PaginationMeta Pagination metadata.

Create a locale-specific translation of a template’s title and body. Translations are created per template version and go through a review workflow before approval.

Authorization: Requires PERMISSION_TEMPLATES_WRITE permission

Field Type Description
template_id string ID of the template to translate.
version int32 Version of the template to translate.
locale string Target locale (e.g. es, pt-BR, zh, ja).
title string Translated title.
body string Translated body content with {{variable}} placeholders preserved.
translated_by string Who created this translation (an AI translator identifier or a user ID).
status TranslationStatus Initial status (typically DRAFT or AI_TRANSLATED).

Response: CreateTemplateTranslationResponse

Section titled “Response: CreateTemplateTranslationResponse”
Field Type Description
translation TemplateTranslation The created translation.

Update an existing template translation.

Authorization: Requires PERMISSION_TEMPLATES_WRITE permission

Field Type Description
translation_id string ID of the translation to update.
title string Updated title. Empty leaves unchanged.
body string Updated body. Empty leaves unchanged.
status TranslationStatus Updated status.

Response: UpdateTemplateTranslationResponse

Section titled “Response: UpdateTemplateTranslationResponse”
Field Type Description
translation TemplateTranslation The updated translation.

List all translations for a template version.

Authorization: Requires PERMISSION_TEMPLATES_READ permission

Field Type Description
template_id string Template ID.
version int32 Template version. 0 returns translations for the latest version.

Response: ListTemplateTranslationsResponse

Section titled “Response: ListTemplateTranslationsResponse”
Field Type Description
translations TemplateTranslation[] Translations for the requested template version.

Approve a template translation for use in campaigns.

Authorization: Requires PERMISSION_TEMPLATES_REVIEW permission

Request: ApproveTemplateTranslationRequest

Section titled “Request: ApproveTemplateTranslationRequest”
Field Type Description
translation_id string ID of the translation to approve.

Response: ApproveTemplateTranslationResponse

Section titled “Response: ApproveTemplateTranslationResponse”
Field Type Description
translation TemplateTranslation The approved translation (status APPROVED, reviewed_by and reviewed_at set).
Field Type Description
id string Unique identifier.
name string Template name (admin-facing label).
body string Template body with {{variable}} placeholders. Max 50,000 characters.
variables TemplateVariable[] Variable definitions.
version int32 Version number (auto-incremented on each update).
created_at Timestamp When this version was created.
updated_at Timestamp Most recent update timestamp.
title string User-facing title shown as the message subject. Campaigns can override it.
type TemplateType Content format. UNSPECIFIED is treated as MARKDOWN.
source_locale string Language of the template body. Translations are created as locale variants of this source.
Field Type Description
id string Unique identifier.
template_id string ID of the source template.
version int32 Version of the source template this translation is for.
locale string Target locale (e.g. es, pt-BR, zh, ja).
title string Translated title. Max 200 characters.
body string Translated body with {{variable}} placeholders preserved. Max 50,000 characters.
status TranslationStatus Current review status.
translated_by string Who created this translation (an AI translator identifier or a user ID).
reviewed_by string User who approved the translation. Empty until approved.
reviewed_at Timestamp When the translation was approved.
created_at Timestamp When the translation was created.
Field Type Description
name string Variable name (used in {{name}} syntax). Max 100 characters.
description string Human-readable description. Max 500 characters.
required bool Whether the variable must be provided during rendering.
source TemplateVariableSource Where the variable value comes from.
default_value string Fallback value used when the source does not provide one. Max 1000 characters.
pii bool When true, the rendered value is masked in session replay and heatmap screenshots.
Value Description
TEMPLATE_TYPE_MARKDOWN Markdown with {{variable}} placeholders
TEMPLATE_TYPE_RICH Rich text format (reserved for future use)
TEMPLATE_TYPE_HTML Raw HTML format (reserved for future use)
Value Description
TEMPLATE_VARIABLE_SOURCE_PROFILE Auto-resolved from the target user’s profile attributes
TEMPLATE_VARIABLE_SOURCE_CUSTOM Provided manually in the campaign or workflow step configuration
Value Description
TRANSLATION_STATUS_DRAFT Translation draft, not yet reviewed
TRANSLATION_STATUS_AI_TRANSLATED Generated by AI, pending human review
TRANSLATION_STATUS_IN_REVIEW Being reviewed by a human
TRANSLATION_STATUS_APPROVED Approved for use