Skip to main content
Use getTemplates() to retrieve all document templates available to the authenticated user.
Applies to Web Component, Window API, and PostMessage. Examples on this page use the Web Component API shape.
Use this method before setInteractionOptions() when you need to verify the template id and language combination you want to use as the default.

Usage

const response = await api.getTemplates();
console.log(response.templates);

Prerequisites

  • User must be authenticated.

Input validation

  • None

Possible errors

  • UNAUTHORIZED: User not authenticated.
  • INTERNAL_ERROR: Failed to fetch templates from the server.

Returns

{
  templates: Array<{
    id: string;
    name: string;
    description?: string;
    language: {
      code: string;
      name: string;
      locale?: string;
    };
    sections: Array<{
      id: string;
      title: string;
    }>;
    isCustom: boolean;
  }>;
}

Use cases

  • Display a template picker.
  • Filter templates by language.
  • Distinguish between built-in and custom templates.
  • Pre-populate template selection based on user preferences or defaults.