# Template Variables API - **Base URL:** `https://template-variables-api.sls.epilot.io` - **Full API Docs:** [https://docs.epilot.io/api/template-variables](https://docs.epilot.io/api/template-variables) ## Usage ```ts import { epilot } from '@epilot/sdk' epilot.authorize(() => '') const { data } = await epilot.templateVariables.getCategories(...) ``` ### Tree-shakeable import ```ts import { getClient, authorize } from '@epilot/sdk/template-variables' const templateVariablesClient = getClient() authorize(templateVariablesClient, () => '') const { data } = await templateVariablesClient.getCategories(...) ``` ## Operations **Templates** - [`getCategories`](#getcategories) - [`searchVariables`](#searchvariables) - [`getVariableContext`](#getvariablecontext) - [`replaceTemplates`](#replacetemplates) - [`replaceTemplatesV2`](#replacetemplatesv2) **Custom Variables** - [`getCustomVariables`](#getcustomvariables) - [`createCustomVariable`](#createcustomvariable) - [`searchCustomVariables`](#searchcustomvariables) - [`updateCustomVariable`](#updatecustomvariable) - [`getCustomVariable`](#getcustomvariable) - [`deleteCustomVariable`](#deletecustomvariable) - [`getBluePrintTableConfig`](#getblueprinttableconfig) **Schemas** - [`Language`](#language) - [`VariableParameters`](#variableparameters) - [`ReplacementOutput`](#replacementoutput) - [`ReplacementOutputV2`](#replacementoutputv2) - [`VariableResult`](#variableresult) - [`CustomVariablesSearchParams`](#customvariablessearchparams) - [`VariableContext`](#variablecontext) - [`TemplateType`](#templatetype) - [`CategoryResult`](#categoryresult) - [`ExternalCustomVariable`](#externalcustomvariable) - [`CustomVariable`](#customvariable) ### `getCategories` Get all template variable categories `GET /v1/template-variables/categories` ```ts const { data } = await client.getCategories({ lang: 'example', }) ```
Response ```json [ { "category": "contact", "description": "Contact" } ] ```
--- ### `searchVariables` Search variables `POST /v1/template-variables:search` ```ts const { data } = await client.searchVariables( null, { template_type: 'email', query: 'logo', from: 0, size: 25, lang: 'de', entity_schemas: ['contact'] }, ) ```
Response ```json [ { "type": "simple", "qrdata": "string", "group": "string", "insert": "string", "description": "string" } ] ```
--- ### `getVariableContext` Get full variable context `POST /v1/template-variables:context` ```ts const { data } = await client.getVariableContext( null, { parameters: { template_type: 'email', language: 'de', main_entity_id: '63753437-c9e2-4e83-82bb-b1c666514561', brand_id: 123451, user_id: '50001', user_org_id: '729224', custom_variables: [ { variable: '{{craftsmen.invitation_link}}', value: 'https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19' } ], context_data: {}, template_name: 'string', template_tags: ['string'], template_id: 'string', variables_version: '2' } }, ) ```
Response ```json { "unsubscribe_url": "https://consent.sls.epilot.io/v1/unsubscribe?token=abc123", "main": { "_id": "03be777b-3cf8-4bff-bb0c-253fd1128479", "_title": "Example Customer", "customer_number": 123, "first_name": "Example", "last_name": "Customer", "title": "Prof.", "salutation": "Ms. / Mrs.", "birthdate": "2018-03-03", "email": [ {}, {} ], "phone": [ {}, {} ], "address": [ {}, {} ], "account": [ {} ] }, "contact": { "_id": "03be777b-3cf8-4bff-bb0c-253fd1128479", "_title": "Example Customer", "customer_number": 123, "first_name": "Example", "last_name": "Customer", "title": "Prof.", "salutation": "Ms. / Mrs.", "birthdate": "2018-03-03", "email": [ {}, {} ], "phone": [ {}, {} ], "address": [ {}, {} ], "account": [ {} ] }, "brand": { "id": 123453, "name": "Brand name", "signature": "Signature" } } ```
--- ### `replaceTemplates` Replace variables in handlebars templates `POST /v1/template-variables:replace` ```ts const { data } = await client.replaceTemplates( null, { inputs: ['Hello, {{contact.first_name}}! {{{brand.signature}}} '], parameters: { template_type: 'email', language: 'de', main_entity_id: '63753437-c9e2-4e83-82bb-b1c666514561', brand_id: 123451, user_id: '50001', user_org_id: '729224', custom_variables: [ { variable: '{{craftsmen.invitation_link}}', value: 'https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19' } ], context_data: {}, template_name: 'string', template_tags: ['string'], template_id: 'string', variables_version: '2' } }, ) ```
Response ```json { "outputs": ["[Brand Name GmbH] Order confirmation\nHello Customer Name\n\nBrand Name GmbH\n\"Brand\nimprint\n"] } ```
--- ### `replaceTemplatesV2` Replace variables in templates (V2) `POST /v2/template:replace` ```ts const { data } = await client.replaceTemplatesV2( null, { inputs: ['Hello, {{contact.first_name}}! '], parameters: { template_type: 'email', language: 'de', main_entity_id: '63753437-c9e2-4e83-82bb-b1c666514561', brand_id: 123451, user_id: '50001', user_org_id: '729224', custom_variables: [ { variable: '{{craftsmen.invitation_link}}', value: 'https://partner.epilot.cloud/activate-account?user_name=htny.pct%2Btet%40gmail.com&confirmation_code=EdXPRW19' } ], context_data: {}, template_name: 'string', template_tags: ['string'], template_id: 'string', variables_version: '2' } }, ) ```
Response ```json { "outputs": { "Hello {{first_name}}": "Hello John", "{{first_name}}": "John", "{{product_images[*].public_url}}": ["http://myimage.server.com/img1.png", "http://myimage.server.com/img2.png"] } } ```
--- ### `getCustomVariables` Get custom variables `GET /v1/custom-variables` ```ts const { data } = await client.getCustomVariables() ```
Response ```json [ { "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "_tags": ["string"], "_manifest": ["string"], "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "config": { "header": null, "style": {}, "columns": [], "body": {}, "footer": {} }, "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042" } ] ```
--- ### `createCustomVariable` Create custom variable `POST /v1/custom-variables` ```ts const { data } = await client.createCustomVariable( null, { id: 'rbse777b-3cf8-4bff-bb0c-253fd1123250', type: 'order_table', name: 'My Custom table', key: 'my_custom_table', _tags: ['string'], _manifest: ['string'], helper_params: ['param1', 'param2'], helper_logic: 'return param1 * param2;', config: { header: null, style: { color: '#222', background: '#fff', 'font-size': '16px', 'font-family': '', 'padding-bottom': '4px', 'font-weight': 'bold', border: 'none !important', 'text-align': 'left' }, columns: [ { /* ... */ }, { /* ... */ }, /* ... 4 more */ ], body: { product_name: { /* ... */ }, price_description: { /* ... */ }, product_description: { /* ... */ }, quantity: { /* ... */ }, tax: { /* ... */ }, unit_amount: { /* ... */ }, net_total: { /* ... */ }, gross_total: { /* ... */ } }, footer: { payment_type: { /* ... */ }, net_total: { /* ... */ }, amount_tax: { /* ... */ }, gross_total: { /* ... */ } } }, template: ' {{#each table_config.header.columns as |column|}} {{#if column.enable}} {{/if}} {{/each}} {{#each order.products as |product|}} {{#if @last}} {{else}} {{/if}} {{#each @root.table_config.header.columns as |column|}} {{#if column.enable}} {{#if (eq column.id \'item\')}} {{/if}} {{#if (eq column.id \'quantity\')}} {{/if}} {{#if (eq column.id \'tax\')}} {{/if}} {{#if (eq column.id \'unit_amount\')}} {{/if}} {{#if (eq column.id \'net_total\')}} {{/if}} {{#if (eq column.id \'amount_tax\')}} {{/if}} {{#if (eq column.id \'gross_total\')}} {{/if}} {{/if}} {{/each}} {{/each}} {{#if table_config.footer.gross_total.enable}} {{#each order.total_details.recurrences as |item|}} {{#if @root.table_config.footer.payment_type.enable}} {{/if}} {{#if (isColumnEnabled @root.table_config \'net_total\')}} {{#if @root.table_config.footer.net_total.enable}} {{/if}} {{/if}} {{/each}} {{/if}}
{{column._label}}
{{#if @root.table_config.body.product_name.enable}} {{product.name}} {{/if}} {{#if @root.table_config.body.price_description.enable}}
{{product.price.description}} {{/if}} {{#if @root.table_config.body.product_description.enable}}
{{product.description}} {{/if}}
{{product.price.quantity}} {{product.price.tax_rate}} {{product.price.unit_amount_net}} {{product.price.amount_subtotal}} {{product.price.amount_tax}} {{product.price.amount_total}} {{#if @root.table_config.body.payment_type.enable}} {{#if (eq product.price.type \'recurring\')}}
{{product.price.billing_period}} {{/if}} {{/if}}
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}} {{#if @root.table_config.footer.amount_tax.enable}}
{{item.full_amount_tax}} {{/if}}
', created_at: '2022-04-19T12:41:43.662Z', created_by: '100042', updated_at: '2022-04-20T12:41:43.662Z', updated_by: '100042' }, ) ```
Response ```json { "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "_tags": ["string"], "_manifest": ["string"], "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "config": { "header": null, "style": { "color": "#222", "background": "#fff", "font-size": "16px", "font-family": "", "padding-bottom": "4px", "font-weight": "bold", "border": "none !important", "text-align": "left" }, "columns": [ {}, {} ], "body": { "product_name": {}, "price_description": {}, "product_description": {}, "quantity": {}, "tax": {}, "unit_amount": {}, "net_total": {}, "gross_total": {} }, "footer": { "payment_type": {}, "net_total": {}, "amount_tax": {}, "gross_total": {} } }, "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042" } ```
--- ### `searchCustomVariables` Search custom variables `POST /v1/custom-variables:search` ```ts const { data } = await client.searchCustomVariables( null, { type: 'order_table', tags: ['string'], query: 'logo', from: 0, size: 25, sort_by: 'created_at, name, key', fields: ['string'] }, ) ```
Response ```json { "results": [ { "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "_tags": ["string"], "_manifest": ["string"], "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "config": {}, "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042" } ], "hits": 100 } ```
--- ### `updateCustomVariable` Update custom variable `PUT /v1/custom-variables/{id}` ```ts const { data } = await client.updateCustomVariable( { id: '123e4567-e89b-12d3-a456-426614174000', }, { id: 'rbse777b-3cf8-4bff-bb0c-253fd1123250', type: 'order_table', name: 'My Custom table', key: 'my_custom_table', _tags: ['string'], _manifest: ['string'], helper_params: ['param1', 'param2'], helper_logic: 'return param1 * param2;', config: { header: null, style: { color: '#222', background: '#fff', 'font-size': '16px', 'font-family': '', 'padding-bottom': '4px', 'font-weight': 'bold', border: 'none !important', 'text-align': 'left' }, columns: [ { /* ... */ }, { /* ... */ }, /* ... 4 more */ ], body: { product_name: { /* ... */ }, price_description: { /* ... */ }, product_description: { /* ... */ }, quantity: { /* ... */ }, tax: { /* ... */ }, unit_amount: { /* ... */ }, net_total: { /* ... */ }, gross_total: { /* ... */ } }, footer: { payment_type: { /* ... */ }, net_total: { /* ... */ }, amount_tax: { /* ... */ }, gross_total: { /* ... */ } } }, template: ' {{#each table_config.header.columns as |column|}} {{#if column.enable}} {{/if}} {{/each}} {{#each order.products as |product|}} {{#if @last}} {{else}} {{/if}} {{#each @root.table_config.header.columns as |column|}} {{#if column.enable}} {{#if (eq column.id \'item\')}} {{/if}} {{#if (eq column.id \'quantity\')}} {{/if}} {{#if (eq column.id \'tax\')}} {{/if}} {{#if (eq column.id \'unit_amount\')}} {{/if}} {{#if (eq column.id \'net_total\')}} {{/if}} {{#if (eq column.id \'amount_tax\')}} {{/if}} {{#if (eq column.id \'gross_total\')}} {{/if}} {{/if}} {{/each}} {{/each}} {{#if table_config.footer.gross_total.enable}} {{#each order.total_details.recurrences as |item|}} {{#if @root.table_config.footer.payment_type.enable}} {{/if}} {{#if (isColumnEnabled @root.table_config \'net_total\')}} {{#if @root.table_config.footer.net_total.enable}} {{/if}} {{/if}} {{/each}} {{/if}}
{{column._label}}
{{#if @root.table_config.body.product_name.enable}} {{product.name}} {{/if}} {{#if @root.table_config.body.price_description.enable}}
{{product.price.description}} {{/if}} {{#if @root.table_config.body.product_description.enable}}
{{product.description}} {{/if}}
{{product.price.quantity}} {{product.price.tax_rate}} {{product.price.unit_amount_net}} {{product.price.amount_subtotal}} {{product.price.amount_tax}} {{product.price.amount_total}} {{#if @root.table_config.body.payment_type.enable}} {{#if (eq product.price.type \'recurring\')}}
{{product.price.billing_period}} {{/if}} {{/if}}
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}} {{#if @root.table_config.footer.amount_tax.enable}}
{{item.full_amount_tax}} {{/if}}
', created_at: '2022-04-19T12:41:43.662Z', created_by: '100042', updated_at: '2022-04-20T12:41:43.662Z', updated_by: '100042' }, ) ```
Response ```json { "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "_tags": ["string"], "_manifest": ["string"], "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "config": { "header": null, "style": { "color": "#222", "background": "#fff", "font-size": "16px", "font-family": "", "padding-bottom": "4px", "font-weight": "bold", "border": "none !important", "text-align": "left" }, "columns": [ {}, {} ], "body": { "product_name": {}, "price_description": {}, "product_description": {}, "quantity": {}, "tax": {}, "unit_amount": {}, "net_total": {}, "gross_total": {} }, "footer": { "payment_type": {}, "net_total": {}, "amount_tax": {}, "gross_total": {} } }, "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042" } ```
--- ### `getCustomVariable` Get custom variable `GET /v1/custom-variables/{id}` ```ts const { data } = await client.getCustomVariable({ id: '123e4567-e89b-12d3-a456-426614174000', }) ```
Response ```json { "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "_tags": ["string"], "_manifest": ["string"], "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "config": { "header": null, "style": { "color": "#222", "background": "#fff", "font-size": "16px", "font-family": "", "padding-bottom": "4px", "font-weight": "bold", "border": "none !important", "text-align": "left" }, "columns": [ {}, {} ], "body": { "product_name": {}, "price_description": {}, "product_description": {}, "quantity": {}, "tax": {}, "unit_amount": {}, "net_total": {}, "gross_total": {} }, "footer": { "payment_type": {}, "net_total": {}, "amount_tax": {}, "gross_total": {} } }, "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042" } ```
--- ### `deleteCustomVariable` Delete custom variable `DELETE /v1/custom-variables/{id}` ```ts const { data } = await client.deleteCustomVariable({ id: '123e4567-e89b-12d3-a456-426614174000', }) ``` --- ### `getBluePrintTableConfig` Get default table config `GET /v1/custom-variables/order-table-blueprint` ```ts const { data } = await client.getBluePrintTableConfig() ```
Response ```json { "id": "rbse777b-3cf8-4bff-bb0c-253fd1123250", "type": "order_table", "name": "My Custom table", "key": "my_custom_table", "_tags": ["string"], "_manifest": ["string"], "helper_params": ["param1", "param2"], "helper_logic": "return param1 * param2;", "config": { "header": null, "style": { "color": "#222", "background": "#fff", "font-size": "16px", "font-family": "", "padding-bottom": "4px", "font-weight": "bold", "border": "none !important", "text-align": "left" }, "columns": [ {}, {} ], "body": { "product_name": {}, "price_description": {}, "product_description": {}, "quantity": {}, "tax": {}, "unit_amount": {}, "net_total": {}, "gross_total": {} }, "footer": { "payment_type": {}, "net_total": {}, "amount_tax": {}, "gross_total": {} } }, "template": "\n \n \n {{#each table_config.header.columns as |column|}}\n {{#if column.enable}}\n \n {{/if}}\n {{/each}}\n \n \n \n \n {{#each order.products as |product|}}\n {{#if @last}}\n \n {{else}}\n \n {{/if}}\n {{#each @root.table_config.header.columns as |column|}}\n {{#if column.enable}}\n {{#if (eq column.id 'item')}}\n \n \n {{/if}}\n {{#if (eq column.id 'quantity')}}\n \n \n {{/if}}\n {{#if (eq column.id 'tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'unit_amount')}}\n \n \n {{/if}}\n {{#if (eq column.id 'net_total')}}\n \n \n {{/if}}\n {{#if (eq column.id 'amount_tax')}}\n \n \n {{/if}}\n {{#if (eq column.id 'gross_total')}}\n \n \n {{/if}}\n {{/if}}\n {{/each}}\n \n {{/each}}\n \n {{#if table_config.footer.gross_total.enable}}\n {{#each order.total_details.recurrences as |item|}}\n \n \n {{#if @root.table_config.footer.payment_type.enable}}\n \n {{/if}}\n {{#if (isColumnEnabled @root.table_config 'net_total')}}\n {{#if @root.table_config.footer.net_total.enable}}\n \n {{/if}}\n {{/if}}\n \n \n {{/each}}\n {{/if}}\n \n \n
{{column._label}}
\n {{#if @root.table_config.body.product_name.enable}}\n {{product.name}}\n {{/if}}\n {{#if @root.table_config.body.price_description.enable}}\n
\n {{product.price.description}}\n {{/if}}\n {{#if @root.table_config.body.product_description.enable}}\n
\n {{product.description}}\n {{/if}}\n
{{product.price.quantity}}\n \n {{product.price.tax_rate}}\n \n {{product.price.unit_amount_net}}\n \n {{product.price.amount_subtotal}}\n \n {{product.price.amount_tax}}\n \n {{product.price.amount_total}}\n {{#if @root.table_config.body.payment_type.enable}}\n {{#if (eq product.price.type 'recurring')}}\n
\n {{product.price.billing_period}}\n {{/if}}\n {{/if}}\n
{{item.billing_period}}{{item.amount_subtotal}}{{item.amount_total}}\n {{#if @root.table_config.footer.amount_tax.enable}}\n
\n {{item.full_amount_tax}}\n {{/if}}\n
\n", "created_at": "2022-04-19T12:41:43.662Z", "created_by": "100042", "updated_at": "2022-04-20T12:41:43.662Z", "updated_by": "100042" } ```
--- ## Schemas ### `Language` 2-letter language code (ISO 639-1) ```ts type Language = string ``` ### `VariableParameters` ```ts type VariableParameters = { template_type: "email" | "document" language?: string main_entity_id?: string // uuid brand_id?: number user_id?: string user_org_id?: string custom_variables?: Array<{ variable?: string value?: string }> context_data?: object template_name?: string template_tags?: string[] template_id?: string variables_version?: string } ``` ### `ReplacementOutput` ```ts type ReplacementOutput = { outputs?: string[] } ``` ### `ReplacementOutputV2` ```ts type ReplacementOutputV2 = { outputs?: Record> } ``` ### `VariableResult` ```ts type VariableResult = { type?: "simple" | "partial" qrdata?: string group?: string insert?: string description?: string } ``` ### `CustomVariablesSearchParams` ```ts type CustomVariablesSearchParams = { type?: "order_table" | "custom" | "journey_link" | "snippet" tags?: string[] query?: string from?: number size?: number sort_by?: string fields?: string[] } ``` ### `VariableContext` ```ts type VariableContext = { unsubscribe_url?: string main?: Record contact?: Record brand?: Record } ``` ### `TemplateType` ```ts type TemplateType = "email" | "document" ``` ### `CategoryResult` ```ts type CategoryResult = { category?: string description?: string } ``` ### `ExternalCustomVariable` ```ts type ExternalCustomVariable = { variable?: string value?: string } ``` ### `CustomVariable` ```ts type CustomVariable = { id?: string type?: "order_table" | "custom" | "journey_link" | "snippet" name?: string key: string _tags?: string[] _manifest?: string[] helper_params?: string[] helper_logic?: string config?: object template: string created_at?: string created_by?: string updated_at?: string updated_by?: string } ```