X Enterprises
fastify-xrcs

getTemplate

Fetch a registered Twilio Content API template by its SID.

getTemplate

Fetches a registered Twilio Content API template by its SID. Useful for verifying a template exists before sending or for displaying template details in an admin UI.

Signature

fastify.xrcs.getTemplate(contentSid: string): Promise<RegisteredTemplate>

Params

NameTypeRequiredDescription
contentSidstringYesThe Twilio Content API template SID (e.g. "HXabc123...")

Returns

{
  sid: string,
  friendlyName: string,
  language: string,
  types: object,
  dateCreated: Date
}

Throws

  • [xRCS] Twilio credentials required — no credentials at registration
  • [xRCS] 'contentSid' must be a non-empty string — missing or invalid SID
  • [xRCS] Failed to get template '{contentSid}': {message} — Twilio API error (e.g. 404 not found)

Examples

Fetch template details in a route

fastify.get("/templates/:sid", async (request, reply) => {
  const template = await fastify.xrcs.getTemplate(request.params.sid);
  return template;
});

Verify a template before bulk send

async function sendBulkNotification(phones, templateSid) {
  // Verify template exists first
  await fastify.xrcs.getTemplate(templateSid);

  return Promise.all(
    phones.map((phone) => fastify.xrcs.sendMessage(phone, templateSid))
  );
}

See Also

AI Context

package: "@xenterprises/fastify-xrcs"
method: fastify.xrcs.getTemplate(contentSid)
use-when: Fetch a Twilio Content API template by SID
returns: template object with friendly name, content type, and variables
requires: Twilio credentials
Copyright © 2026