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.1 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { veroAuth } from '../common/auth';
import { makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';

export const unsubscribe = createAction({
  auth: veroAuth,
  name: 'unsubscribe',
  displayName: 'Unsubscribe',
  description: 'Globally unsubscribe a user from all communications',
  audience: 'both',
  aiMetadata: {
    description:
      'Globally unsubscribes a Vero user, identified by user ID, withdrawing their consent so they no longer receive any communications. Use to honor an opt-out. Repeating the call leaves the user unsubscribed, so it is idempotent.',
    idempotent: true,
  },
  props: {
    id: Property.ShortText({
      displayName: 'User ID',
      description: 'The unique identifier of the user',
      required: true,
    }),
  },
  async run(context) {
    const { id } = context.propsValue;

    const response = await makeRequest(
      context.auth.secret_text,
      HttpMethod.POST,
      '/users/unsubscribe',
      {
        id,
      }
    );

    return response;
  },
});