Skip to content

Rule.io SDK


Rule.io SDK / client/src / Template

Interface: Template

Defined in: client/src/resources/templates/templates.types.ts:33

A template entity as returned by the API.

The wire format stores the RCML body in a field called template; the SDK renames it to content to avoid shadowing the outer type name and to match the semantic ("this is the content of the template").

Properties

content?

optional content?: RcmlDocument | SmsDocument

Defined in: client/src/resources/templates/templates.types.ts:58

The template body document.

For email templates this is an RcmlDocument; for SMS templates this is an SmsDocument. Mapped from the wire's template field. Optional because the API may omit the template body in some list responses.

The type is the union RcmlDocument | SmsDocument. messageType is typed as a plain string rather than a discriminator, so TypeScript does not narrow content automatically — callers that need a specific shape should narrow manually:

typescript
if (template.messageType === 'email') {
  const rcml = template.content as RcmlDocument | undefined;
} else if (template.messageType === 'text_message') {
  const sms = template.content as SmsDocument | undefined;
}

createdAt

createdAt: string

Defined in: client/src/resources/templates/templates.types.ts:69

ISO 8601 timestamp of when the template was created.


id

id: number

Defined in: client/src/resources/templates/templates.types.ts:35

Template ID.


messageType

messageType: string

Defined in: client/src/resources/templates/templates.types.ts:67

Message type this template was created for.

'email' for email templates, 'text_message' for SMS templates. Typed as string (not a literal union) so adding a new server-side value does not break consumers; narrow content manually based on the value you care about.


name

name: string

Defined in: client/src/resources/templates/templates.types.ts:37

Human-readable template name shown in the Rule.io UI.


updatedAt

updatedAt: string

Defined in: client/src/resources/templates/templates.types.ts:71

ISO 8601 timestamp of when the template was last updated.