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 { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { promotekitAuth } from '../..';
import { promotekitApiCall, promotekitCommon } from '../common';

export const findReferral = createAction({
  auth: promotekitAuth,
  name: 'find_referral',
  displayName: 'Find Referral',
  description: 'Get details of a specific referral by ID.',
  audience: 'both',
  aiMetadata: {
    description: 'Fetch a single referral by its PromoteKit referral ID. Use when you already have the exact ID and need that referral\'s details; to discover IDs, list referrals first. Read-only and safe to repeat.',
    idempotent: true,
  },
  props: {
    referral_id: Property.ShortText({
      displayName: 'Referral ID',
      description: 'The ID of the referral to retrieve.',
      required: true,
    }),
  },
  async run(context) {
    const response = await promotekitApiCall<{
      data: Record<string, unknown>;
    }>({
      token: context.auth.secret_text,
      method: HttpMethod.GET,
      path: `/referrals/${context.propsValue.referral_id}`,
    });
    return promotekitCommon.flattenReferral(response.body.data);
  },
});