Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(apitemplate-io): add AI actions and output schemas (#15862)

Kishan Parmarfe073b325038
diff --git a/packages/pieces/community/apitemplate-io/package.json b/packages/pieces/community/apitemplate-io/package.json
index a8e7f6cefd3..c93f2584e15 100644
--- a/packages/pieces/community/apitemplate-io/package.json
+++ b/packages/pieces/community/apitemplate-io/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-apitemplate-io",
- "version": "0.2.0",
+ "version": "0.3.0",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/apitemplate-io/src/index.ts b/packages/pieces/community/apitemplate-io/src/index.ts
index 15b28c8894b..cb4f756a4fc 100644
--- a/packages/pieces/community/apitemplate-io/src/index.ts
+++ b/packages/pieces/community/apitemplate-io/src/index.ts
@@ -7,6 +7,11 @@ import { deleteObject } from './lib/actions/delete-object';
import { listObjects } from './lib/actions/list-objects';
import { createPdfFromHtml } from './lib/actions/create-pdf-from-html';
import { createPdfFromUrl } from './lib/actions/create-pdf-from-url';
+import { createPdfFromMarkdown } from './lib/actions/create-pdf-from-markdown';
+import { listTemplates } from './lib/actions/list-templates';
+import { getTemplate } from './lib/actions/get-template';
+import { updateTemplate } from './lib/actions/update-template';
+import { mergePdfs } from './lib/actions/merge-pdfs';
import { PieceCategory } from '@activepieces/pieces-framework';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import { ApitemplateAuthConfig, ApitemplateRegion, getRegionalBaseUrl } from './lib/common/client';
@@ -14,7 +19,7 @@ import { ApitemplateAuthConfig, ApitemplateRegion, getRegionalBaseUrl } from './
export const apitemplateIo = createPiece({
displayName: 'APITemplate.io',
auth: ApitemplateAuth,
- minimumSupportedRelease: '0.36.1',
+ minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/apitemplate-io.png',
categories: [PieceCategory.CONTENT_AND_FILES, PieceCategory.PRODUCTIVITY],
authors: ['Sanket6652'],
@@ -26,6 +31,11 @@ export const apitemplateIo = createPiece({
deleteObject,
getAccountInformation,
listObjects,
+ createPdfFromMarkdown,
+ listTemplates,
+ getTemplate,
+ updateTemplate,
+ mergePdfs,
createCustomApiCallAction({
auth: ApitemplateAuth,
baseUrl: (auth) => {
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/create-image.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/create-image.ts
index 8f78018ea67..2a83508f482 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/actions/create-image.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/create-image.ts
@@ -3,10 +3,12 @@ import { ApitemplateAuth } from '../common/auth';
import { ApitemplateAuthConfig, ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { templateIdDropdown } from '../common/props';
+import { createImageOutputSchema } from '../output-schemas';
export const createImage = createAction({
auth: ApitemplateAuth,
name: 'createImage',
+ outputSchema: createImageOutputSchema,
classification: 'WRITE',
displayName: 'Create Image',
description: 'Creates an image from a template with provided data.',
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-html.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-html.ts
index ce1b39988e0..3289e63a8d7 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-html.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-html.ts
@@ -2,10 +2,12 @@ import { createAction, Property } from '@activepieces/pieces-framework';
import { ApitemplateAuth } from '../common/auth';
import { ApitemplateAuthConfig, ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
+import { createPdfFromHtmlOutputSchema } from '../output-schemas';
export const createPdfFromHtml = createAction({
auth: ApitemplateAuth,
name: 'createPdfFromHtml',
+ outputSchema: createPdfFromHtmlOutputSchema,
classification: 'WRITE',
displayName: 'Create PDF From HTML',
description: 'Creates a PDF from HTML.',
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-markdown.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-markdown.ts
new file mode 100644
index 00000000000..3f00abbbf45
--- /dev/null
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-markdown.ts
@@ -0,0 +1,98 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { ApitemplateAuth } from '../common/auth';
+import { ApitemplateRegion, makeRequest } from '../common/client';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { apitemplateIoCreatePdfFromMarkdownOutputSchema } from '../output-schemas';
+
+export const createPdfFromMarkdown = createAction({
+ auth: ApitemplateAuth,
+ name: 'apitemplate_io_create_pdf_from_markdown',
+ outputSchema: apitemplateIoCreatePdfFromMarkdownOutputSchema,
+ classification: 'WRITE',
+ displayName: 'Create PDF From Markdown',
+ description: 'Creates a PDF from Markdown content.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Renders a new PDF from raw Markdown text (with optional CSS and templating data). Use when the source is Markdown rather than a saved template, raw HTML, or a live URL. Requires the Markdown body. Not idempotent: each call generates and stores a new PDF.',
+ idempotent: false,
+ },
+ props: {
+ body: Property.LongText({
+ displayName: 'Markdown Content',
+ description: 'The Markdown content to convert to PDF.',
+ required: true,
+ }),
+ css: Property.LongText({
+ displayName: 'CSS Styles',
+ description: 'Optional CSS styles to apply to the rendered Markdown.',
+ required: false,
+ }),
+ data: Property.Json({
+ displayName: 'Template Data',
+ description: 'Optional JSON data to use for templating the Markdown content.',
+ required: false,
+ }),
+ expiration: Property.Number({
+ displayName: 'Expiration (minutes)',
+ description:
+ 'Expiration of the generated PDF in minutes. Use 0 to store permanently, or 1-10080 minutes (7 days) to specify expiration.',
+ required: false,
+ defaultValue: 0,
+ }),
+ meta: Property.ShortText({
+ displayName: 'External Reference ID',
+ description: 'Specify an external reference ID for your own reference. It appears in the list-objects response.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const authConfig = auth.props;
+ const { body, css, data, expiration, meta } = propsValue;
+
+ const queryParams = new URLSearchParams();
+
+ if (expiration !== undefined && expiration !== 0) {
+ queryParams.append('expiration', expiration.toString());
+ }
+
+ if (meta) {
+ queryParams.append('meta', meta);
+ }
+
+ const endpoint = `/create-pdf-from-markdown${
+ queryParams.toString() ? `?${queryParams.toString()}` : ''
+ }`;
+
+ const requestBody: Record<string, unknown> = { body };
+
+ if (css) {
+ requestBody['css'] = css;
+ }
+
+ if (data) {
+ requestBody['data'] = data;
+ }
+
+ try {
+ const response = await makeRequest(
+ authConfig.apiKey,
+ HttpMethod.POST,
+ endpoint,
+ requestBody,
+ undefined,
+ authConfig.region as ApitemplateRegion
+ );
+
+ return response;
+ } catch (error: any) {
+ if (error.message.includes('502') && authConfig.region !== 'default') {
+ throw new Error(
+ `${error.message}\n\nThe ${authConfig.region} region appears to be experiencing issues. ` +
+ `Consider switching to the 'default' region in your authentication settings or try again later.`
+ );
+ }
+ throw error;
+ }
+ },
+});
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-url.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-url.ts
index 8e58e04fba0..58e4da3f449 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-url.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf-from-url.ts
@@ -2,10 +2,12 @@ import { createAction, Property } from '@activepieces/pieces-framework';
import { ApitemplateAuth } from '../common/auth';
import { ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
+import { createPdfFromHtmlOutputSchema } from '../output-schemas';
export const createPdfFromUrl = createAction({
auth: ApitemplateAuth,
name: 'createPdfFromUrl',
+ outputSchema: createPdfFromHtmlOutputSchema,
classification: 'WRITE',
displayName: 'Create PDF From URL',
description: 'Creates a PDF from a webpage URL.',
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf.ts
index 5b19f6e0169..e9271fe4d53 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/create-pdf.ts
@@ -3,10 +3,12 @@ import { ApitemplateAuth } from '../common/auth';
import { ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { templateIdDropdown } from '../common/props';
+import { createImageOutputSchema } from '../output-schemas';
export const createPdf = createAction({
auth: ApitemplateAuth,
name: 'createPdf',
+ outputSchema: createImageOutputSchema,
classification: 'WRITE',
displayName: 'Create PDF',
description: 'Creates a PDF from a template with provided data.',
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/delete-object.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/delete-object.ts
index 5a0989e4fad..8a3fb931551 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/actions/delete-object.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/delete-object.ts
@@ -3,10 +3,12 @@ import { ApitemplateAuth } from '../common/auth';
import { ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { transactionRefDropdown } from '../common/props';
+import { deleteObjectOutputSchema } from '../output-schemas';
export const deleteObject = createAction({
auth: ApitemplateAuth,
name: 'deleteObject',
+ outputSchema: deleteObjectOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Delete Object',
description: 'Deletes a generated PDF or image by its transaction reference or object ID.',
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/get-account-information.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/get-account-information.ts
index bd8b5aa8a3a..440845eb891 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/actions/get-account-information.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/get-account-information.ts
@@ -2,10 +2,12 @@ import { createAction } from '@activepieces/pieces-framework';
import { ApitemplateAuth } from '../common/auth';
import { ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
+import { getAccountInformationOutputSchema } from '../output-schemas';
export const getAccountInformation = createAction({
auth: ApitemplateAuth,
name: 'getAccountInformation',
+ outputSchema: getAccountInformationOutputSchema,
classification: 'READ',
displayName: 'Get Account Information',
description: 'Retrieves account information including usage statistics and account details.',
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/get-template.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/get-template.ts
new file mode 100644
index 00000000000..80e6e345070
--- /dev/null
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/get-template.ts
@@ -0,0 +1,54 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { ApitemplateAuth } from '../common/auth';
+import { ApitemplateRegion, makeRequest } from '../common/client';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { pdfTemplateIdDropdown } from '../common/props';
+import { apitemplateIoGetTemplateOutputSchema } from '../output-schemas';
+
+export const getTemplate = createAction({
+ auth: ApitemplateAuth,
+ name: 'apitemplate_io_get_template',
+ outputSchema: apitemplateIoGetTemplateOutputSchema,
+ classification: 'READ',
+ displayName: 'Get Template',
+ description: 'Retrieves the body, CSS, and settings of a PDF template.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Fetches the HTML body, CSS, and print settings of a single PDF template, identified by its template ID (get one from list-templates). This is an experimental vendor endpoint limited to PDF templates and may not be available on every account. Read-only and idempotent.',
+ idempotent: true,
+ },
+ props: {
+ templateId: pdfTemplateIdDropdown,
+ },
+ async run({ auth, propsValue }) {
+ const authConfig = auth.props;
+ const { templateId } = propsValue;
+
+ const queryParams = new URLSearchParams();
+ queryParams.append('template_id', templateId);
+
+ const endpoint = `/get-template?${queryParams.toString()}`;
+
+ try {
+ const response = await makeRequest(
+ authConfig.apiKey,
+ HttpMethod.GET,
+ endpoint,
+ undefined,
+ undefined,
+ authConfig.region as ApitemplateRegion
+ );
+
+ return response;
+ } catch (error: any) {
+ if (error.message.includes('502') && authConfig.region !== 'default') {
+ throw new Error(
+ `${error.message}\n\nThe ${authConfig.region} region appears to be experiencing issues. ` +
+ `Consider switching to the 'default' region in your authentication settings or try again later.`
+ );
+ }
+ throw error;
+ }
+ },
+});
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/list-objects.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/list-objects.ts
index 02e76793233..819b5181821 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/actions/list-objects.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/list-objects.ts
@@ -2,10 +2,12 @@ import { createAction, Property } from '@activepieces/pieces-framework';
import { ApitemplateAuth } from '../common/auth';
import { ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
+import { listObjectsOutputSchema } from '../output-schemas';
export const listObjects = createAction({
auth: ApitemplateAuth,
name: 'listObjects',
+ outputSchema: listObjectsOutputSchema,
classification: 'SEARCH',
displayName: 'List Objects',
description:
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/list-templates.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/list-templates.ts
new file mode 100644
index 00000000000..e275cb14148
--- /dev/null
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/list-templates.ts
@@ -0,0 +1,116 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { ApitemplateAuth } from '../common/auth';
+import { ApitemplateRegion, makeRequest } from '../common/client';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { apitemplateIoListTemplatesOutputSchema } from '../output-schemas';
+
+export const listTemplates = createAction({
+ auth: ApitemplateAuth,
+ name: 'apitemplate_io_list_templates',
+ outputSchema: apitemplateIoListTemplatesOutputSchema,
+ classification: 'SEARCH',
+ displayName: 'List Templates',
+ description: 'Retrieves a list of the account templates and their information.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the PDF and image templates saved in the account, optionally narrowed by format, template ID, or group name. Use to discover a template ID before calling create-pdf/create-image, get-template, or update-template. Supports limit/offset pagination (default 300 per call). Read-only and idempotent.',
+ idempotent: true,
+ },
+ props: {
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Maximum number of templates to return (default: 300).',
+ required: false,
+ defaultValue: 300,
+ }),
+ offset: Property.Number({
+ displayName: 'Offset',
+ description: 'Number of templates to skip for pagination (default: 0).',
+ required: false,
+ defaultValue: 0,
+ }),
+ format: Property.StaticDropdown({
+ displayName: 'Format',
+ description: 'Filter templates by format.',
+ required: false,
+ options: {
+ options: [
+ { label: 'PDF', value: 'PDF' },
+ { label: 'JPEG', value: 'JPEG' },
+ ],
+ },
+ }),
+ templateId: Property.ShortText({
+ displayName: 'Template ID',
+ description: 'Filter templates by template ID.',
+ required: false,
+ }),
+ groupName: Property.ShortText({
+ displayName: 'Group Name',
+ description: 'Filter templates by group name.',
+ required: false,
+ }),
+ withLayerInfo: Property.Checkbox({
+ displayName: 'With Layer Info',
+ description: 'Return layer information for image templates.',
+ required: false,
+ defaultValue: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const authConfig = auth.props;
+ const { limit, offset, format, templateId, groupName, withLayerInfo } = propsValue;
+
+ const queryParams = new URLSearchParams();
+
+ if (limit !== undefined && limit !== 300) {
+ queryParams.append('limit', limit.toString());
+ }
+
+ if (offset !== undefined && offset !== 0) {
+ queryParams.append('offset', offset.toString());
+ }
+
+ if (format) {
+ queryParams.append('format', format);
+ }
+
+ if (templateId) {
+ queryParams.append('template_id', templateId);
+ }
+
+ if (groupName) {
+ queryParams.append('group_name', groupName);
+ }
+
+ if (withLayerInfo) {
+ queryParams.append('with_layer_info', '1');
+ }
+
+ const endpoint = `/list-templates${
+ queryParams.toString() ? `?${queryParams.toString()}` : ''
+ }`;
+
+ try {
+ const response = await makeRequest(
+ authConfig.apiKey,
+ HttpMethod.GET,
+ endpoint,
+ undefined,
+ undefined,
+ authConfig.region as ApitemplateRegion
+ );
+
+ return response;
+ } catch (error: any) {
+ if (error.message.includes('502') && authConfig.region !== 'default') {
+ throw new Error(
+ `${error.message}\n\nThe ${authConfig.region} region appears to be experiencing issues. ` +
+ `Consider switching to the 'default' region in your authentication settings or try again later.`
+ );
+ }
+ throw error;
+ }
+ },
+});
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/merge-pdfs.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/merge-pdfs.ts
new file mode 100644
index 00000000000..e3472e4ecd8
--- /dev/null
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/merge-pdfs.ts
@@ -0,0 +1,80 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { ApitemplateAuth } from '../common/auth';
+import { ApitemplateRegion, makeRequest } from '../common/client';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { apitemplateIoMergePdfsOutputSchema } from '../output-schemas';
+
+export const mergePdfs = createAction({
+ auth: ApitemplateAuth,
+ name: 'apitemplate_io_merge_pdfs',
+ outputSchema: apitemplateIoMergePdfsOutputSchema,
+ classification: 'WRITE',
+ displayName: 'Merge PDFs',
+ description: 'Merges multiple PDFs into a single PDF file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Joins an ordered list of PDF URLs (normal http/https URLs or base64 data: URIs) into a single PDF, in the order given. Use after generating individual PDFs to combine them into one document. Requires at least one URL. Not idempotent: each call generates and stores a new merged PDF.',
+ idempotent: false,
+ },
+ props: {
+ urls: Property.Array({
+ displayName: 'PDF URLs',
+ description: 'URLs of the PDFs to merge, in order. Supports http/https URLs and data: URIs.',
+ required: true,
+ }),
+ expiration: Property.Number({
+ displayName: 'Expiration (minutes)',
+ description:
+ 'Expiration of the generated PDF in minutes. Use 0 to store permanently, or 1-43200 minutes (30 days) to specify expiration.',
+ required: false,
+ defaultValue: 0,
+ }),
+ meta: Property.ShortText({
+ displayName: 'External Reference ID',
+ description: 'Specify an external reference ID for your own reference. It appears in the list-objects response.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const authConfig = auth.props;
+ const { urls, expiration, meta } = propsValue;
+
+ const queryParams = new URLSearchParams();
+
+ if (meta) {
+ queryParams.append('meta', meta);
+ }
+
+ const endpoint = `/merge-pdfs${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
+
+ const requestBody: Record<string, unknown> = {
+ urls: urls as string[],
+ };
+
+ if (expiration !== undefined && expiration !== 0) {
+ requestBody['expiration'] = expiration;
+ }
+
+ try {
+ const response = await makeRequest(
+ authConfig.apiKey,
+ HttpMethod.POST,
+ endpoint,
+ requestBody,
+ undefined,
+ authConfig.region as ApitemplateRegion
+ );
+
+ return response;
+ } catch (error: any) {
+ if (error.message.includes('502') && authConfig.region !== 'default') {
+ throw new Error(
+ `${error.message}\n\nThe ${authConfig.region} region appears to be experiencing issues. ` +
+ `Consider switching to the 'default' region in your authentication settings or try again later.`
+ );
+ }
+ throw error;
+ }
+ },
+});
diff --git a/packages/pieces/community/apitemplate-io/src/lib/actions/update-template.ts b/packages/pieces/community/apitemplate-io/src/lib/actions/update-template.ts
new file mode 100644
index 00000000000..1ae2f5ce337
--- /dev/null
+++ b/packages/pieces/community/apitemplate-io/src/lib/actions/update-template.ts
@@ -0,0 +1,78 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { ApitemplateAuth } from '../common/auth';
+import { ApitemplateRegion, makeRequest } from '../common/client';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { pdfTemplateIdDropdown } from '../common/props';
+import { apitemplateIoUpdateTemplateOutputSchema } from '../output-schemas';
+
+export const updateTemplate = createAction({
+ auth: ApitemplateAuth,
+ name: 'apitemplate_io_update_template',
+ outputSchema: apitemplateIoUpdateTemplateOutputSchema,
+ classification: 'WRITE',
+ displayName: 'Update Template',
+ description: 'Updates the HTML body, CSS, or settings of a PDF template.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Updates the HTML body, CSS, and/or print settings of an existing PDF template, identified by its template ID (get one from list-templates). Any field left empty leaves the current value unchanged. This is an experimental vendor endpoint limited to PDF templates and may not be available on every account. Update-to-state, idempotent.',
+ idempotent: true,
+ },
+ props: {
+ templateId: pdfTemplateIdDropdown,
+ body: Property.LongText({
+ displayName: 'HTML Body',
+ description: 'New HTML body for the template. Leave empty to keep the current body.',
+ required: false,
+ }),
+ css: Property.LongText({
+ displayName: 'CSS',
+ description: 'New CSS for the template. Leave empty to keep the current CSS.',
+ required: false,
+ }),
+ settings: Property.Json({
+ displayName: 'Settings',
+ description: 'New print settings for the template. Leave empty to keep the current settings.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const authConfig = auth.props;
+ const { templateId, body, css, settings } = propsValue;
+
+ const requestBody: Record<string, unknown> = { template_id: templateId };
+
+ if (body !== undefined) {
+ requestBody['body'] = body;
+ }
+
+ if (css !== undefined) {
+ requestBody['css'] = css;
+ }
+
+ if (settings !== undefined) {
+ requestBody['settings'] = settings;
+ }
+
+ try {
+ const response = await makeRequest(
+ authConfig.apiKey,
+ HttpMethod.POST,
+ '/update-template',
+ requestBody,
+ undefined,
+ authConfig.region as ApitemplateRegion
+ );
+
+ return response;
+ } catch (error: any) {
+ if (error.message.includes('502') && authConfig.region !== 'default') {
+ throw new Error(
+ `${error.message}\n\nThe ${authConfig.region} region appears to be experiencing issues. ` +
+ `Consider switching to the 'default' region in your authentication settings or try again later.`
+ );
+ }
+ throw error;
+ }
+ },
+});
diff --git a/packages/pieces/community/apitemplate-io/src/lib/common/props.ts b/packages/pieces/community/apitemplate-io/src/lib/common/props.ts
index 785f54126f7..32b2bb974b2 100644
--- a/packages/pieces/community/apitemplate-io/src/lib/common/props.ts
+++ b/packages/pieces/community/apitemplate-io/src/lib/common/props.ts
@@ -109,6 +109,69 @@ export const templateIdDropdown = Property.Dropdown({
},
});
+export const pdfTemplateIdDropdown = Property.Dropdown({
+ auth: ApitemplateAuth,
+ displayName: 'Template ID',
+ description: 'Only PDF templates are shown; this endpoint does not support image templates.',
+ required: true,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return {
+ disabled: true,
+ options: [],
+ placeholder: 'Please connect your account first',
+ };
+ }
+
+ const authConfig = auth.props;
+
+ if (!authConfig.apiKey || !authConfig.region) {
+ return {
+ disabled: true,
+ options: [],
+ placeholder: 'Please complete authentication setup.',
+ };
+ }
+
+ try {
+ const response = await makeRequest(
+ authConfig.apiKey,
+ HttpMethod.GET,
+ '/list-templates?format=PDF',
+ undefined,
+ undefined,
+ authConfig.region as ApitemplateRegion
+ );
+
+ const templates = response?.templates || [];
+
+ if (!Array.isArray(templates) || templates.length === 0) {
+ return {
+ disabled: false,
+ options: [],
+ placeholder: 'No PDF templates found',
+ };
+ }
+
+ return {
+ disabled: false,
+ options: templates.map((template: any) => ({
+ label: `${template.name} - ${template.status}`,
+ value: template.template_id,
+ })),
+ };
+ } catch (error) {
+ console.error('Error loading templates:', error);
+ return {
+ disabled: true,
+ options: [],
+ placeholder: 'Error loading templates',
+ };
+ }
+ },
+});
+
export const transactionRefDropdown = Property.Dropdown({
auth: ApitemplateAuth,
displayName: 'Transaction Reference',
diff --git a/packages/pieces/community/apitemplate-io/src/lib/output-schemas.ts b/packages/pieces/community/apitemplate-io/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..d24f0a05b47
--- /dev/null
+++ b/packages/pieces/community/apitemplate-io/src/lib/output-schemas.ts
@@ -0,0 +1,133 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const postActionFields: OutputSchema['fields'] = [
+ { key: 'action', label: 'Action' },
+ { key: 'name', label: 'Name' },
+ { key: 'bucket', label: 'Bucket' },
+ { key: 'status', label: 'Status' },
+ { key: 'file', label: 'File' },
+ { key: 'message', label: 'Message' },
+];
+
+export const getAccountInformationOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'Status' },
+ { key: 'subscription_product', label: 'Subscription Product' },
+ { key: 'subscription_current_period_start', label: 'Subscription Current Period Start', format: 'datetime' },
+ { key: 'subscription_current_period_end', label: 'Subscription Current Period End', format: 'datetime' },
+ { key: 'subscription_status', label: 'Subscription Status' },
+ { key: 'subscription_interval', label: 'Subscription Interval' },
+ { key: 'api_quota', label: 'API Quota', format: 'number' },
+ { key: 'api_remaining', label: 'API Remaining', format: 'number' },
+ { key: 'api_used', label: 'API Used', format: 'number' },
+ { key: 'template_remaining', label: 'Template Remaining', format: 'number' },
+ { key: 'template_count', label: 'Template Count', format: 'number' },
+ { key: 'template_quota', label: 'Template Quota', format: 'number' },
+ { key: 'message', label: 'Message' },
+ ],
+};
+
+export const deleteObjectOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'Status' },
+ { key: 'transaction_ref', label: 'Transaction Ref' },
+ ],
+};
+
+export const createImageOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'download_url', label: 'Download URL', format: 'url' },
+ { key: 'transaction_ref', label: 'Transaction Ref' },
+ { key: 'total_pages', label: 'Total Pages', format: 'number' },
+ { key: 'status', label: 'Status' },
+ { key: 'template_id', label: 'Template ID' },
+ ],
+};
+
+export const createPdfFromHtmlOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'download_url', label: 'Download URL', format: 'url' },
+ { key: 'transaction_ref', label: 'Transaction Ref' },
+ { key: 'total_pages', label: 'Total Pages', format: 'number' },
+ { key: 'status', label: 'Status' },
+ ],
+};
+
+export const apitemplateIoCreatePdfFromMarkdownOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'download_url', label: 'Download URL', format: 'url' },
+ { key: 'transaction_ref', label: 'Transaction Ref' },
+ { key: 'total_pages', label: 'Total Pages', format: 'number' },
+ { key: 'status', label: 'Status' },
+ { key: 'post_actions', label: 'Post Actions', labelKey: 'name', listItems: postActionFields },
+ { key: 'template_id', label: 'Template ID' },
+ ],
+};
+
+export const apitemplateIoGetTemplateOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'Status' },
+ { key: 'template_id', label: 'Template ID' },
+ { key: 'body', label: 'Body', format: 'html' },
+ { key: 'css', label: 'CSS' },
+ { key: 'sample_json', label: 'Sample JSON' },
+ { key: 'settings', label: 'Settings' },
+ ],
+};
+
+export const listObjectsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'Status' },
+ {
+ key: 'objects',
+ label: 'Objects',
+ labelKey: 'transaction_ref',
+ listItems: [
+ { key: 'transaction_ref', label: 'Transaction Ref' },
+ { key: 'template_id', label: 'Template ID' },
+ { key: 'description', label: 'Description' },
+ { key: 'meta', label: 'Meta' },
+ { key: 'source', label: 'Source' },
+ { key: 'transaction_type', label: 'Transaction Type' },
+ { key: 'primary_url', label: 'Primary URL', format: 'url' },
+ { key: 'secondary_url', label: 'Secondary URL', format: 'url' },
+ { key: 'deleted_at', label: 'Deleted At', format: 'datetime' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ ],
+ },
+ ],
+};
+
+export const apitemplateIoListTemplatesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'status', label: 'Status' },
+ {
+ key: 'templates',
+ label: 'Templates',
+ labelKey: 'name',
+ listItems: [
+ { key: 'template_id', label: 'Template ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'status', label: 'Status' },
+ { key: 'format', label: 'Format' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+ { key: 'group_name', label: 'Group Name' },
+ ],
+ },
+ ],
+};
+
+export const apitemplateIoMergePdfsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'primary_url', label: 'Primary URL', format: 'url' },
+ { key: 'status', label: 'Status' },
+ { key: 'transaction_ref', label: 'Transaction Ref' },
+ { key: 'total_pages', label: 'Total Pages', format: 'number' },
+ { key: 'post_actions', label: 'Post Actions', labelKey: 'name', listItems: postActionFields },
+ ],
+};
+
+export const apitemplateIoUpdateTemplateOutputSchema: OutputSchema = {
+ fields: [{ key: 'status', label: 'Status' }],
+};