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.6 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { simplirouteAuth } from '../../auth';
import { API_BASE_URL, commonHeaders } from '../../common/constants';

export const bulk_delete_clients = createAction({
    name: 'bulk_delete_clients',
    auth: simplirouteAuth,
    displayName: 'Bulk Delete Clients',
    description: 'Delete multiple clients in a single call.',
    audience: 'both',
    aiMetadata: { description: 'Permanently remove several clients at once by passing a list of their numeric client IDs. Use for batch cleanup rather than deleting one at a time; destructive and irreversible. Re-running with already-deleted IDs has no further effect.', idempotent: false },
    props: {
        ids: Property.Array({
            displayName: 'IDs',
            description: 'List of client IDs to delete.',
            required: true,
            properties: {
                id: Property.Number({ displayName: 'ID', required: true }),
            }
        }),
    },
    async run(context) {
        const theIds = context.propsValue.ids;
        const body = (theIds as Array<{ id: number }>).map(client => client.id);
        const response = await httpClient.sendRequest({
            method: HttpMethod.DELETE,
            url: `${API_BASE_URL}/v1/accounts/clients/`,
            body,
            headers: {
                ...commonHeaders,
                'Authorization': `Token ${context.auth.secret_text}`
            }
        });
        return {
            status: response.status,
            data: response.body
        };
    },
});