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.2 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { freshsalesAuth } from '../auth';
import { freshsalesClient } from '../common/client';
import { deleteOutputSchema } from '../output-schemas';

export const deleteTask = createAction({
  auth: freshsalesAuth,
  name: 'delete_task',
  displayName: 'Delete Task',
  description: 'Delete a task by its ID',
  audience: 'both',
  classification: 'DESTRUCTIVE',
  aiMetadata: {
    description:
      'Permanently deletes a Freshsales task by numeric ID. A second call for the same ID fails with a not-found error. Confirm the ID with Get Task first.',
    idempotent: true,
  },
  outputSchema: deleteOutputSchema,
  props: {
    task_id: Property.ShortText({
      displayName: 'Task ID',
      description: 'ID of the task to delete',
      placeholder: '16000123456',
      required: true,
    }),
  },
  async run(context) {
    const id = freshsalesClient.requireId({
      value: context.propsValue.task_id,
      field: 'Task ID',
    });
    await freshsalesClient.request<unknown>({
      auth: context.auth,
      method: HttpMethod.DELETE,
      path: `/api/tasks/${id}`,
    });
    return { id, deleted: true };
  },
});