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

1.4 KB
Raw Blame
import { getHubspotAccessToken, hubspotAuth } from '../auth';
import { createAction, Property } from '@activepieces/pieces-framework';
import { Client } from '@hubspot/api-client';
import { pageType } from '../common/props';

export const deletePageAction = createAction({
	auth: hubspotAuth,
	name: 'delete-page',
	classification: 'DESTRUCTIVE',
	displayName: 'Delete Page',
	description: 'Deletes a landing page or site page.',
	audience: 'both',
	aiMetadata: { description: 'Archive (delete) a HubSpot CMS landing page or site page by its ID; select the matching Page Type. Deleting an already-deleted page is harmless, so the operation is effectively idempotent on the end state. This is destructive and cannot be undone here.', idempotent: true },
	propertyGroups: [
		{
			key: 'page',
			display: 'section',
			label: 'Page to Delete',
			icon: 'trash',
			props: ['pageType', 'pageId'],
		},
	],
	props: {
		pageType: pageType,
		pageId: Property.ShortText({
			displayName: 'Page ID',
			description: 'Map it from an earlier step like Create Page.',
			required: true,
		}),
	},
	async run(context) {
		const { pageId, pageType } = context.propsValue;
		const client = new Client({ accessToken: getHubspotAccessToken(context.auth) });

		if (pageType === 'site_page') {
			return await client.cms.pages.sitePagesApi.archive(pageId);
		} else {
			return await client.cms.pages.landingPagesApi.archive(pageId);
		}
	},
});