Interface: TemplatesResource
Defined in: packages/sdk/src/resources/templates.ts:39
The template registry: which templates the project has enabled, their variable contract, and their draft/published content versions.
Example
await mailroom.templates.setEnabled("welcome", { enabled: true, defaultSubject: "Welcome!" });
const { dataSchema } = await mailroom.templates.schema("welcome");
await mailroom.templates.publish("welcome", { content: { hero: "Hi there" } });
Methods
getContent()
getContent(
key: string,
query?: {
brand?: string;
},
opts?: CallOptions): Promise<TemplateContent>;
Defined in: packages/sdk/src/resources/templates.ts:57
Read draft + published content and the registry defaults.
Parameters
| Parameter | Type |
|---|---|
key | string |
query? | { brand?: string; } |
query.brand? | string |
opts? | CallOptions |
Returns
Promise<TemplateContent>
list()
list(query?: {
brand?: string;
}, opts?: CallOptions): Promise<Template[]>;
Defined in: packages/sdk/src/resources/templates.ts:41
Registry templates with their per-project state (enabled, subject, sender).
Parameters
| Parameter | Type |
|---|---|
query? | { brand?: string; } |
query.brand? | string |
opts? | CallOptions |
Returns
Promise<Template[]>
publish()
publish(
key: string,
input: {
brand?: string;
content: Record<string, unknown>;
},
opts?: CallOptions): Promise<WriteTemplateContentResult>;
Defined in: packages/sdk/src/resources/templates.ts:67
Convenience: write and publish in one call.
Parameters
| Parameter | Type |
|---|---|
key | string |
input | { brand?: string; content: Record<string, unknown>; } |
input.brand? | string |
input.content? | Record<string, unknown> |
opts? | CallOptions |
Returns
Promise<WriteTemplateContentResult>
putContent()
putContent(
key: string,
input: TemplateContentInput,
opts?: CallOptions): Promise<WriteTemplateContentResult>;
Defined in: packages/sdk/src/resources/templates.ts:60
Write a content version (draft by default, or publish).
Parameters
| Parameter | Type |
|---|---|
key | string |
input | TemplateContentInput |
opts? | CallOptions |
Returns
Promise<WriteTemplateContentResult>
schema()
schema(
key: string,
query?: {
brand?: string;
},
opts?: CallOptions): Promise<TemplateSchema>;
Defined in: packages/sdk/src/resources/templates.ts:44
The variable contract for a template — what to pass in send({ template, data }).
Parameters
| Parameter | Type |
|---|---|
key | string |
query? | { brand?: string; } |
query.brand? | string |
opts? | CallOptions |
Returns
Promise<TemplateSchema>
setEnabled()
setEnabled(
key: string,
input: TemplateSettingsInput,
opts?: CallOptions): Promise<{
enabled: boolean;
key: string;
}>;
Defined in: packages/sdk/src/resources/templates.ts:50
Enable/disable a registry template for the project/brand (+ default subject, template-level from — omit to keep, null to clear).
Parameters
| Parameter | Type |
|---|---|
key | string |
input | TemplateSettingsInput |
opts? | CallOptions |
Returns
Promise<{
enabled: boolean;
key: string;
}>