/** * Klaviyo API * The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details. * * Contact: developers@klaviyo.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ const axios = require('axios'); import {AxiosRequestConfig, AxiosResponse} from "axios"; import FormData from 'form-data' /* tslint:disable:no-unused-locals */ import { GetAccounts4XXResponse } from '../model/getAccounts4XXResponse'; import { GetTemplateDndResponse } from '../model/getTemplateDndResponse'; import { GetTemplateDndResponseCollection } from '../model/getTemplateDndResponseCollection'; import { GetUniversalContentResponse } from '../model/getUniversalContentResponse'; import { GetUniversalContentResponseCollection } from '../model/getUniversalContentResponseCollection'; import { PatchTemplateDndResponse } from '../model/patchTemplateDndResponse'; import { PatchUniversalContentResponse } from '../model/patchUniversalContentResponse'; import { PostTemplateDndResponse } from '../model/postTemplateDndResponse'; import { PostTemplateResponse } from '../model/postTemplateResponse'; import { PostUniversalContentResponse } from '../model/postUniversalContentResponse'; import { TemplateCloneQuery } from '../model/templateCloneQuery'; import { TemplateCreateHtmlOrDndQuery } from '../model/templateCreateHtmlOrDndQuery'; import { TemplateRenderQuery } from '../model/templateRenderQuery'; import { TemplateUpdateHtmlOrDndQuery } from '../model/templateUpdateHtmlOrDndQuery'; import { UniversalContentCreateQuery } from '../model/universalContentCreateQuery'; import { UniversalContentPartialUpdateQuery } from '../model/universalContentPartialUpdateQuery'; import { ObjectSerializer } from '../model/models'; import {RequestFile, queryParamPreProcessor, RetryWithExponentialBackoff, Session} from './apis'; let defaultBasePath = 'https://a.klaviyo.com'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export class TemplatesApi { session: Session protected _basePath = defaultBasePath; protected _defaultHeaders : any = {}; protected _useQuerystring : boolean = false; constructor(session: Session){ this.session = session } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } set defaultHeaders(defaultHeaders: any) { this._defaultHeaders = defaultHeaders; } get defaultHeaders() { return this._defaultHeaders; } get basePath() { return this._basePath; } /** * Create a clone of a template with the given template ID. If there are 1,000 or more templates in an account, cloning will fail as there is a limit of 1,000 templates that can be created via the API.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:write` * @summary Clone Template * @param templateCloneQuery */ public async cloneTemplate (templateCloneQuery: TemplateCloneQuery, ): Promise<{ response: AxiosResponse; body: PostTemplateResponse; }> { const localVarPath = this.basePath + '/api/template-clone'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'templateCloneQuery' is not null or undefined if (templateCloneQuery === null || templateCloneQuery === undefined) { throw new Error('Required parameter templateCloneQuery was null or undefined when calling cloneTemplate.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(templateCloneQuery, "TemplateCloneQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostTemplateResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostTemplateResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Create a new HTML or drag-and-drop template. If there are 1,000 or more templates in an account, creation will fail as there is a limit of 1,000 templates that can be created via the API. Request specific fields using [sparse fieldsets](https://developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets).

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:write` * @summary Create Template * @param templateCreateHtmlOrDndQuery * @param additionalFieldsTemplate Request additional fields not included by default in the response. Supported values: \'definition\' */ public async createTemplate (templateCreateHtmlOrDndQuery: TemplateCreateHtmlOrDndQuery, options: { additionalFieldsTemplate?: Array<'definition'>, } = {}): Promise<{ response: AxiosResponse; body: PostTemplateDndResponse; }> { const localVarPath = this.basePath + '/api/templates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'templateCreateHtmlOrDndQuery' is not null or undefined if (templateCreateHtmlOrDndQuery === null || templateCreateHtmlOrDndQuery === undefined) { throw new Error('Required parameter templateCreateHtmlOrDndQuery was null or undefined when calling createTemplate.'); } if (options.additionalFieldsTemplate !== undefined) { localVarQueryParameters['additional-fields[template]'] = ObjectSerializer.serialize(options.additionalFieldsTemplate, "Array<'definition'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(templateCreateHtmlOrDndQuery, "TemplateCreateHtmlOrDndQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostTemplateDndResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostTemplateDndResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Create universal content. Currently supported block types are: `button`, `drop_shadow`, `horizontal_rule`, `html`, `image`, `spacer`, and `text`.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:write` * @summary Create Universal Content * @param universalContentCreateQuery Create a template universal content */ public async createUniversalContent (universalContentCreateQuery: UniversalContentCreateQuery, ): Promise<{ response: AxiosResponse; body: PostUniversalContentResponse; }> { const localVarPath = this.basePath + '/api/template-universal-content'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'universalContentCreateQuery' is not null or undefined if (universalContentCreateQuery === null || universalContentCreateQuery === undefined) { throw new Error('Required parameter universalContentCreateQuery was null or undefined when calling createUniversalContent.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(universalContentCreateQuery, "UniversalContentCreateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostUniversalContentResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostUniversalContentResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Delete a template with the given template ID.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:write` * @summary Delete Template * @param id The ID of template */ public async deleteTemplate (id: string, ): Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/api/templates/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling deleteTemplate.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'DELETE', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body?: any; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Delete the universal content with the given ID.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:write` * @summary Delete Universal Content * @param id The ID of the template universal content */ public async deleteUniversalContent (id: string, ): Promise<{ response: AxiosResponse; body?: any; }> { const localVarPath = this.basePath + '/api/template-universal-content/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling deleteUniversalContent.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'DELETE', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body?: any; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Get all universal content in an account.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:read` * @summary Get All Universal Content * @param fieldsTemplateUniversalContent For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param filter For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`, `equals`<br>`name`: `any`, `equals`<br>`created`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`definition.content_type`: `equals`<br>`definition.type`: `equals`* @param pageCursor For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#pagination* @param pageSize Default: 20. Min: 1. Max: 100.* @param sort For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sorting */ public async getAllUniversalContent (options: { fieldsTemplateUniversalContent?: Array<'created' | 'definition' | 'definition.content_type' | 'definition.data' | 'definition.data.content' | 'definition.data.display_options' | 'definition.data.display_options.content_repeat' | 'definition.data.display_options.content_repeat.item_alias' | 'definition.data.display_options.content_repeat.repeat_for' | 'definition.data.display_options.show_on' | 'definition.data.display_options.visible_check' | 'definition.data.styles' | 'definition.data.styles.background_color' | 'definition.data.styles.block_background_color' | 'definition.data.styles.block_border_color' | 'definition.data.styles.block_border_style' | 'definition.data.styles.block_border_width' | 'definition.data.styles.block_padding_bottom' | 'definition.data.styles.block_padding_left' | 'definition.data.styles.block_padding_right' | 'definition.data.styles.block_padding_top' | 'definition.data.styles.color' | 'definition.data.styles.extra_css_class' | 'definition.data.styles.font_family' | 'definition.data.styles.font_size' | 'definition.data.styles.font_style' | 'definition.data.styles.font_weight' | 'definition.data.styles.inner_padding_bottom' | 'definition.data.styles.inner_padding_left' | 'definition.data.styles.inner_padding_right' | 'definition.data.styles.inner_padding_top' | 'definition.data.styles.letter_spacing' | 'definition.data.styles.line_height' | 'definition.data.styles.mobile_stretch_content' | 'definition.data.styles.text_align' | 'definition.data.styles.text_decoration' | 'definition.data.styles.text_table_layout' | 'definition.type' | 'name' | 'screenshot_status' | 'screenshot_url' | 'updated'>, filter?: string, pageCursor?: string, pageSize?: number, sort?: 'created' | '-created' | 'id' | '-id' | 'name' | '-name' | 'updated' | '-updated', } = {}): Promise<{ response: AxiosResponse; body: GetUniversalContentResponseCollection; }> { const localVarPath = this.basePath + '/api/template-universal-content'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } if (options.fieldsTemplateUniversalContent !== undefined) { localVarQueryParameters['fields[template-universal-content]'] = ObjectSerializer.serialize(options.fieldsTemplateUniversalContent, "Array<'created' | 'definition' | 'definition.content_type' | 'definition.data' | 'definition.data.content' | 'definition.data.display_options' | 'definition.data.display_options.content_repeat' | 'definition.data.display_options.content_repeat.item_alias' | 'definition.data.display_options.content_repeat.repeat_for' | 'definition.data.display_options.show_on' | 'definition.data.display_options.visible_check' | 'definition.data.styles' | 'definition.data.styles.background_color' | 'definition.data.styles.block_background_color' | 'definition.data.styles.block_border_color' | 'definition.data.styles.block_border_style' | 'definition.data.styles.block_border_width' | 'definition.data.styles.block_padding_bottom' | 'definition.data.styles.block_padding_left' | 'definition.data.styles.block_padding_right' | 'definition.data.styles.block_padding_top' | 'definition.data.styles.color' | 'definition.data.styles.extra_css_class' | 'definition.data.styles.font_family' | 'definition.data.styles.font_size' | 'definition.data.styles.font_style' | 'definition.data.styles.font_weight' | 'definition.data.styles.inner_padding_bottom' | 'definition.data.styles.inner_padding_left' | 'definition.data.styles.inner_padding_right' | 'definition.data.styles.inner_padding_top' | 'definition.data.styles.letter_spacing' | 'definition.data.styles.line_height' | 'definition.data.styles.mobile_stretch_content' | 'definition.data.styles.text_align' | 'definition.data.styles.text_decoration' | 'definition.data.styles.text_table_layout' | 'definition.type' | 'name' | 'screenshot_status' | 'screenshot_url' | 'updated'>"); } if (options.filter !== undefined) { localVarQueryParameters['filter'] = ObjectSerializer.serialize(options.filter, "string"); } if (options.pageCursor !== undefined) { localVarQueryParameters['page[cursor]'] = ObjectSerializer.serialize(options.pageCursor, "string"); } if (options.pageSize !== undefined) { localVarQueryParameters['page[size]'] = ObjectSerializer.serialize(options.pageSize, "number"); } if (options.sort !== undefined) { localVarQueryParameters['sort'] = ObjectSerializer.serialize(options.sort, "'created' | '-created' | 'id' | '-id' | 'name' | '-name' | 'updated' | '-updated'"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetUniversalContentResponseCollection; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetUniversalContentResponseCollection"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Get a template with the given template ID.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:read` * @summary Get Template * @param id The ID of template * @param additionalFieldsTemplate Request additional fields not included by default in the response. Supported values: \'definition\'* @param fieldsTemplate For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getTemplate (id: string, options: { additionalFieldsTemplate?: Array<'definition'>, fieldsTemplate?: Array<'amp' | 'created' | 'definition' | 'definition.body' | 'definition.body.id' | 'definition.body.properties' | 'definition.body.properties.css_class' | 'definition.body.properties.id' | 'definition.body.sections' | 'definition.body.styles' | 'definition.body.styles.background_color' | 'definition.body.styles.width' | 'definition.id' | 'definition.styles' | 'definition.template_id' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>, } = {}): Promise<{ response: AxiosResponse; body: GetTemplateDndResponse; }> { const localVarPath = this.basePath + '/api/templates/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getTemplate.'); } if (options.additionalFieldsTemplate !== undefined) { localVarQueryParameters['additional-fields[template]'] = ObjectSerializer.serialize(options.additionalFieldsTemplate, "Array<'definition'>"); } if (options.fieldsTemplate !== undefined) { localVarQueryParameters['fields[template]'] = ObjectSerializer.serialize(options.fieldsTemplate, "Array<'amp' | 'created' | 'definition' | 'definition.body' | 'definition.body.id' | 'definition.body.properties' | 'definition.body.properties.css_class' | 'definition.body.properties.id' | 'definition.body.sections' | 'definition.body.styles' | 'definition.body.styles.background_color' | 'definition.body.styles.width' | 'definition.id' | 'definition.styles' | 'definition.template_id' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetTemplateDndResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetTemplateDndResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Get all templates in an account. Use `additional-fields[template]=definition` to include the full template definition for SYSTEM_DRAGGABLE templates.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:read` * @summary Get Templates * @param additionalFieldsTemplate Request additional fields not included by default in the response. Supported values: \'definition\'* @param fieldsTemplate For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param filter For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`id`: `any`, `equals`<br>`name`: `any`, `contains`, `equals`<br>`created`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `equals`, `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`* @param pageCursor For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#pagination* @param sort For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sorting */ public async getTemplates (options: { additionalFieldsTemplate?: Array<'definition'>, fieldsTemplate?: Array<'amp' | 'created' | 'definition' | 'definition.body' | 'definition.body.id' | 'definition.body.properties' | 'definition.body.properties.css_class' | 'definition.body.properties.id' | 'definition.body.sections' | 'definition.body.styles' | 'definition.body.styles.background_color' | 'definition.body.styles.width' | 'definition.id' | 'definition.styles' | 'definition.template_id' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>, filter?: string, pageCursor?: string, sort?: 'created' | '-created' | 'id' | '-id' | 'name' | '-name' | 'updated' | '-updated', } = {}): Promise<{ response: AxiosResponse; body: GetTemplateDndResponseCollection; }> { const localVarPath = this.basePath + '/api/templates'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } if (options.additionalFieldsTemplate !== undefined) { localVarQueryParameters['additional-fields[template]'] = ObjectSerializer.serialize(options.additionalFieldsTemplate, "Array<'definition'>"); } if (options.fieldsTemplate !== undefined) { localVarQueryParameters['fields[template]'] = ObjectSerializer.serialize(options.fieldsTemplate, "Array<'amp' | 'created' | 'definition' | 'definition.body' | 'definition.body.id' | 'definition.body.properties' | 'definition.body.properties.css_class' | 'definition.body.properties.id' | 'definition.body.sections' | 'definition.body.styles' | 'definition.body.styles.background_color' | 'definition.body.styles.width' | 'definition.id' | 'definition.styles' | 'definition.template_id' | 'editor_type' | 'html' | 'name' | 'text' | 'updated'>"); } if (options.filter !== undefined) { localVarQueryParameters['filter'] = ObjectSerializer.serialize(options.filter, "string"); } if (options.pageCursor !== undefined) { localVarQueryParameters['page[cursor]'] = ObjectSerializer.serialize(options.pageCursor, "string"); } if (options.sort !== undefined) { localVarQueryParameters['sort'] = ObjectSerializer.serialize(options.sort, "'created' | '-created' | 'id' | '-id' | 'name' | '-name' | 'updated' | '-updated'"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetTemplateDndResponseCollection; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetTemplateDndResponseCollection"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Get the universal content with the given ID.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:read` * @summary Get Universal Content * @param id The ID of the universal content * @param fieldsTemplateUniversalContent For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets */ public async getUniversalContent (id: string, options: { fieldsTemplateUniversalContent?: Array<'created' | 'definition' | 'definition.content_type' | 'definition.data' | 'definition.data.content' | 'definition.data.display_options' | 'definition.data.display_options.content_repeat' | 'definition.data.display_options.content_repeat.item_alias' | 'definition.data.display_options.content_repeat.repeat_for' | 'definition.data.display_options.show_on' | 'definition.data.display_options.visible_check' | 'definition.data.styles' | 'definition.data.styles.background_color' | 'definition.data.styles.block_background_color' | 'definition.data.styles.block_border_color' | 'definition.data.styles.block_border_style' | 'definition.data.styles.block_border_width' | 'definition.data.styles.block_padding_bottom' | 'definition.data.styles.block_padding_left' | 'definition.data.styles.block_padding_right' | 'definition.data.styles.block_padding_top' | 'definition.data.styles.color' | 'definition.data.styles.extra_css_class' | 'definition.data.styles.font_family' | 'definition.data.styles.font_size' | 'definition.data.styles.font_style' | 'definition.data.styles.font_weight' | 'definition.data.styles.inner_padding_bottom' | 'definition.data.styles.inner_padding_left' | 'definition.data.styles.inner_padding_right' | 'definition.data.styles.inner_padding_top' | 'definition.data.styles.letter_spacing' | 'definition.data.styles.line_height' | 'definition.data.styles.mobile_stretch_content' | 'definition.data.styles.text_align' | 'definition.data.styles.text_decoration' | 'definition.data.styles.text_table_layout' | 'definition.type' | 'name' | 'screenshot_status' | 'screenshot_url' | 'updated'>, } = {}): Promise<{ response: AxiosResponse; body: GetUniversalContentResponse; }> { const localVarPath = this.basePath + '/api/template-universal-content/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling getUniversalContent.'); } if (options.fieldsTemplateUniversalContent !== undefined) { localVarQueryParameters['fields[template-universal-content]'] = ObjectSerializer.serialize(options.fieldsTemplateUniversalContent, "Array<'created' | 'definition' | 'definition.content_type' | 'definition.data' | 'definition.data.content' | 'definition.data.display_options' | 'definition.data.display_options.content_repeat' | 'definition.data.display_options.content_repeat.item_alias' | 'definition.data.display_options.content_repeat.repeat_for' | 'definition.data.display_options.show_on' | 'definition.data.display_options.visible_check' | 'definition.data.styles' | 'definition.data.styles.background_color' | 'definition.data.styles.block_background_color' | 'definition.data.styles.block_border_color' | 'definition.data.styles.block_border_style' | 'definition.data.styles.block_border_width' | 'definition.data.styles.block_padding_bottom' | 'definition.data.styles.block_padding_left' | 'definition.data.styles.block_padding_right' | 'definition.data.styles.block_padding_top' | 'definition.data.styles.color' | 'definition.data.styles.extra_css_class' | 'definition.data.styles.font_family' | 'definition.data.styles.font_size' | 'definition.data.styles.font_style' | 'definition.data.styles.font_weight' | 'definition.data.styles.inner_padding_bottom' | 'definition.data.styles.inner_padding_left' | 'definition.data.styles.inner_padding_right' | 'definition.data.styles.inner_padding_top' | 'definition.data.styles.letter_spacing' | 'definition.data.styles.line_height' | 'definition.data.styles.mobile_stretch_content' | 'definition.data.styles.text_align' | 'definition.data.styles.text_decoration' | 'definition.data.styles.text_table_layout' | 'definition.type' | 'name' | 'screenshot_status' | 'screenshot_url' | 'updated'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'GET', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetUniversalContentResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetUniversalContentResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Render a template with the given template ID and context attribute. Returns the AMP, HTML, and plain text versions of the email template. **Request body parameters** (nested under `attributes`): * `return_fields`: Request specific fields using [sparse fieldsets](https://developers.klaviyo.com/en/reference/api_overview#sparse-fieldsets). * `context`: This is the context your email template will be rendered with. You must pass in a `context` object as a JSON object. Email templates are rendered with contexts in a similar manner to Django templates. Nested template variables can be referenced via dot notation. Template variables without corresponding `context` values are treated as `FALSE` and output nothing. Ex. `{ \"name\" : \"George Washington\", \"state\" : \"VA\" }`

*Rate limits*:
Burst: `3/s`
Steady: `60/m` **Scopes:** `templates:read` * @summary Render Template * @param templateRenderQuery */ public async renderTemplate (templateRenderQuery: TemplateRenderQuery, ): Promise<{ response: AxiosResponse; body: PostTemplateResponse; }> { const localVarPath = this.basePath + '/api/template-render'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'templateRenderQuery' is not null or undefined if (templateRenderQuery === null || templateRenderQuery === undefined) { throw new Error('Required parameter templateRenderQuery was null or undefined when calling renderTemplate.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'POST', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(templateRenderQuery, "TemplateRenderQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostTemplateResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PostTemplateResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Update a template with the given template ID.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:write` * @summary Update Template * @param id The ID of template* @param templateUpdateHtmlOrDndQuery * @param additionalFieldsTemplate Request additional fields not included by default in the response. Supported values: \'definition\' */ public async updateTemplate (id: string, templateUpdateHtmlOrDndQuery: TemplateUpdateHtmlOrDndQuery, options: { additionalFieldsTemplate?: Array<'definition'>, } = {}): Promise<{ response: AxiosResponse; body: PatchTemplateDndResponse; }> { const localVarPath = this.basePath + '/api/templates/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling updateTemplate.'); } // verify required parameter 'templateUpdateHtmlOrDndQuery' is not null or undefined if (templateUpdateHtmlOrDndQuery === null || templateUpdateHtmlOrDndQuery === undefined) { throw new Error('Required parameter templateUpdateHtmlOrDndQuery was null or undefined when calling updateTemplate.'); } if (options.additionalFieldsTemplate !== undefined) { localVarQueryParameters['additional-fields[template]'] = ObjectSerializer.serialize(options.additionalFieldsTemplate, "Array<'definition'>"); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'PATCH', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(templateUpdateHtmlOrDndQuery, "TemplateUpdateHtmlOrDndQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PatchTemplateDndResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PatchTemplateDndResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } /** * Update universal content. The `definition` field can only be updated on the following block types at this time: `button`, `drop_shadow`, `horizontal_rule`, `html`, `image`, `spacer`, and `text`.

*Rate limits*:
Burst: `75/s`
Steady: `750/m` **Scopes:** `templates:write` * @summary Update Universal Content * @param id The ID of the template universal content* @param universalContentPartialUpdateQuery Update a universal content by ID */ public async updateUniversalContent (id: string, universalContentPartialUpdateQuery: UniversalContentPartialUpdateQuery, ): Promise<{ response: AxiosResponse; body: PatchUniversalContentResponse; }> { const localVarPath = this.basePath + '/api/template-universal-content/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders); const produces = ['application/vnd.api+json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling updateUniversalContent.'); } // verify required parameter 'universalContentPartialUpdateQuery' is not null or undefined if (universalContentPartialUpdateQuery === null || universalContentPartialUpdateQuery === undefined) { throw new Error('Required parameter universalContentPartialUpdateQuery was null or undefined when calling updateUniversalContent.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'PATCH', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(universalContentPartialUpdateQuery, "UniversalContentPartialUpdateQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PatchUniversalContentResponse; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PatchUniversalContentResponse"); return ({response: axiosResponse, body: body}); } catch (error) { if (await this.session.refreshAndRetry(error, retried)) { await this.session.applyToRequest(config) return request(config, true) } throw error } } return request(config) } } export interface TemplatesApi { /** * Alias of {@link TemplatesApi.cloneTemplate} * * @deprecated Use {@link TemplatesApi.cloneTemplate} instead */ createTemplateClone: typeof TemplatesApi.prototype.cloneTemplate; } TemplatesApi.prototype.createTemplateClone = TemplatesApi.prototype.cloneTemplate export interface TemplatesApi { /** * Alias of {@link TemplatesApi.createUniversalContent} * * @deprecated Use {@link TemplatesApi.createUniversalContent} instead */ createTemplateUniversalContent: typeof TemplatesApi.prototype.createUniversalContent; } TemplatesApi.prototype.createTemplateUniversalContent = TemplatesApi.prototype.createUniversalContent export interface TemplatesApi { /** * Alias of {@link TemplatesApi.deleteUniversalContent} * * @deprecated Use {@link TemplatesApi.deleteUniversalContent} instead */ deleteTemplateUniversalContent: typeof TemplatesApi.prototype.deleteUniversalContent; } TemplatesApi.prototype.deleteTemplateUniversalContent = TemplatesApi.prototype.deleteUniversalContent export interface TemplatesApi { /** * Alias of {@link TemplatesApi.getAllUniversalContent} * * @deprecated Use {@link TemplatesApi.getAllUniversalContent} instead */ getTemplateUniversalContent: typeof TemplatesApi.prototype.getAllUniversalContent; } TemplatesApi.prototype.getTemplateUniversalContent = TemplatesApi.prototype.getAllUniversalContent export interface TemplatesApi { /** * Alias of {@link TemplatesApi.renderTemplate} * * @deprecated Use {@link TemplatesApi.renderTemplate} instead */ createTemplateRender: typeof TemplatesApi.prototype.renderTemplate; } TemplatesApi.prototype.createTemplateRender = TemplatesApi.prototype.renderTemplate export interface TemplatesApi { /** * Alias of {@link TemplatesApi.updateUniversalContent} * * @deprecated Use {@link TemplatesApi.updateUniversalContent} instead */ updateTemplateUniversalContent: typeof TemplatesApi.prototype.updateUniversalContent; } TemplatesApi.prototype.updateTemplateUniversalContent = TemplatesApi.prototype.updateUniversalContent