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 { createAction } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { resendAuth } from '../..';
import { resendClient } from '../common/client';
import { resendProps } from '../common/props';
import { deleteContactOutputSchema } from '../output-schemas';

export const deleteContact = createAction({
  name: 'delete_contact',
  classification: 'DESTRUCTIVE',
  auth: resendAuth,
  displayName: 'Delete Contact',
  outputSchema: deleteContactOutputSchema,
  description: 'Remove a contact from an audience',
  audience: 'both',
  aiMetadata: { description: 'Permanently removes a contact from a Resend audience, identified by audience ID and contact ID. Use this to delete a subscriber from a list. Effectively idempotent — once removed, repeating the call has no further effect.', idempotent: true },
  propertyGroups: [
    {
      key: 'contact',
      display: 'section',
      label: 'Contact to Delete',
      icon: 'user',
      props: ['audience_id', 'contact_id'],
    },
  ],
  props: {
    audience_id: resendProps.audienceId,
    contact_id: resendProps.contactId,
  },
  async run({ auth, propsValue }) {
    const response = await resendClient.sendRequest<{
      object: string;
      contact: string;
      deleted: boolean;
    }>({ auth: auth.secret_text, method: HttpMethod.DELETE, path: `/audiences/${propsValue.audience_id}/contacts/${propsValue.contact_id}` });
    return response;
  },
});