Skip to content

TemplatesResource

Defined in: src/resources/templates.ts:75

Message-template management API exposed as client.templates.

new TemplatesResource(request, getDefaultBusinessAccountId): TemplatesResource

Defined in: src/resources/templates.ts:79

RequestFn

BusinessAccountIdAccessor

TemplatesResource

create(payload, businessAccountId?): Promise<CreateTemplateResponse>

Defined in: src/resources/templates.ts:144

Creates a message template. Client-side validation of the documented hard limits runs before the request, so an invalid payload never hits the API.

CreateTemplatePayload

string

Promise<CreateTemplateResponse>

Positional body with a footer

await client.templates.create({
name: 'order_confirmation',
language: 'en_US',
category: 'UTILITY',
components: [
{ type: 'BODY', text: 'Hi {{1}}, your order {{2}} is confirmed.', example: { body_text: [['Sam', '12345']] } },
{ type: 'FOOTER', text: 'Reply STOP to opt out.' },
],
});

Named-parameter body with a media header and buttons

await client.templates.create({
name: 'appointment_reminder',
language: 'en_US',
category: 'UTILITY',
parameterFormat: 'NAMED',
components: [
{ type: 'HEADER', format: 'IMAGE', example: { header_handle: ['4::handle'] } },
{
type: 'BODY',
text: 'Hi {{name}}, your appointment is on {{date}}.',
example: { body_text_named_params: [{ param_name: 'name', example: 'Sam' }, { param_name: 'date', example: 'Monday' }] },
},
{ type: 'BUTTONS', buttons: [{ type: 'QUICK_REPLY', text: 'Confirm' }, { type: 'QUICK_REPLY', text: 'Cancel' }] },
],
});

delete(options): Promise<SuccessResponse>

Defined in: src/resources/templates.ts:213

Deletes a template by name. By default all versions are deleted; pass templateId (mapped to hsm_id) to delete a single version. name is always required.

DeleteTemplateOptions

Promise<SuccessResponse>


edit(templateId, payload, businessAccountId?): Promise<SuccessResponse>

Defined in: src/resources/templates.ts:177

Edits an existing template by its id. Only category, components, and messageSendTtlSeconds are editable; name and language are immutable. Editing an APPROVED template resets it to PENDING for re-review.

businessAccountId is accepted for signature parity with the other methods but is unused: the edit endpoint is addressed globally by template id and does not include a WABA segment.

string

EditTemplatePayload

string

Promise<SuccessResponse>


get(templateId, fields?): Promise<MessageTemplate>

Defined in: src/resources/templates.ts:100

Reads a single template by its id. Pass fields to request specific Graph fields; when omitted no field selection is sent.

string

string[]

Promise<MessageTemplate>


list(options?): Promise<TemplateList>

Defined in: src/resources/templates.ts:88

Lists the message templates on a business account. All options are optional; fields is comma-joined and every value is URL-encoded.

ListTemplatesOptions

Promise<TemplateList>

Independent open-source project. Not affiliated with, endorsed by or sponsored by Meta or WhatsApp. Released under the MIT licence. Source on GitHub.