Skip to main content
Glama
refgrow
by refgrow

create_conversion

Manually create affiliate conversions for signups or purchases, automatically calculating commissions from project settings when values are not provided.

Instructions

Manually create a conversion (signup or purchase). For purchases, the commission is auto-calculated from project settings if value is not provided. You can identify the affiliate by ID or referral code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesConversion type: signup or purchase
valueNoCommission value (auto-calculated from project settings if omitted)
base_valueNoOriginal transaction amount before commission
affiliate_idNoID of the referring affiliate
referral_codeNoReferral code to look up the affiliate (used if affiliate_id is not provided)
referred_user_idNoID of the referred user
emailNoEmail of the customer (for webhook payloads)
paidNoWhether the commission has been paid out (default false)
referenceNoExternal reference ID (e.g. invoice number)
coupon_code_usedNoCoupon code used in this conversion
base_value_currencyNoCurrency of the base value (e.g. USD, EUR)

Implementation Reference

  • Handler function for 'create_conversion' tool - processes parameters, builds request body with optional fields, and makes POST request to /conversions API endpoint
    async (params) => {
      try {
        const body: Record<string, unknown> = { type: params.type };
        const optionalFields = [
          "value",
          "base_value",
          "affiliate_id",
          "referral_code",
          "referred_user_id",
          "email",
          "paid",
          "reference",
          "coupon_code_used",
          "base_value_currency",
        ] as const;
    
        for (const field of optionalFields) {
          if (params[field] !== undefined) {
            body[field] = params[field];
          }
        }
    
        const data = await apiRequest(config, "POST", "/conversions", body);
        return textResult(data);
      } catch (err) {
        return errorResult(err);
      }
    }
  • src/tools.ts:452-535 (registration)
    Registration of 'create_conversion' tool using server.tool() with name, description, zod schema for input validation, and async handler function
    server.tool(
      "create_conversion",
      "Manually create a conversion (signup or purchase). For purchases, the commission is auto-calculated from project settings if value is not provided. You can identify the affiliate by ID or referral code.",
      {
        type: z
          .enum(["signup", "purchase"])
          .describe("Conversion type: signup or purchase"),
        value: z
          .number()
          .optional()
          .describe(
            "Commission value (auto-calculated from project settings if omitted)"
          ),
        base_value: z
          .number()
          .optional()
          .describe("Original transaction amount before commission"),
        affiliate_id: z
          .number()
          .int()
          .optional()
          .describe("ID of the referring affiliate"),
        referral_code: z
          .string()
          .optional()
          .describe(
            "Referral code to look up the affiliate (used if affiliate_id is not provided)"
          ),
        referred_user_id: z
          .number()
          .int()
          .optional()
          .describe("ID of the referred user"),
        email: z
          .string()
          .email()
          .optional()
          .describe("Email of the customer (for webhook payloads)"),
        paid: z
          .boolean()
          .optional()
          .describe("Whether the commission has been paid out (default false)"),
        reference: z
          .string()
          .optional()
          .describe("External reference ID (e.g. invoice number)"),
        coupon_code_used: z
          .string()
          .optional()
          .describe("Coupon code used in this conversion"),
        base_value_currency: z
          .string()
          .optional()
          .describe("Currency of the base value (e.g. USD, EUR)"),
      },
      async (params) => {
        try {
          const body: Record<string, unknown> = { type: params.type };
          const optionalFields = [
            "value",
            "base_value",
            "affiliate_id",
            "referral_code",
            "referred_user_id",
            "email",
            "paid",
            "reference",
            "coupon_code_used",
            "base_value_currency",
          ] as const;
    
          for (const field of optionalFields) {
            if (params[field] !== undefined) {
              body[field] = params[field];
            }
          }
    
          const data = await apiRequest(config, "POST", "/conversions", body);
          return textResult(data);
        } catch (err) {
          return errorResult(err);
        }
      }
    );
  • Zod schema definition for create_conversion input parameters including type (signup/purchase), value, base_value, affiliate_id, referral_code, referred_user_id, email, paid, reference, coupon_code_used, and base_value_currency
      type: z
        .enum(["signup", "purchase"])
        .describe("Conversion type: signup or purchase"),
      value: z
        .number()
        .optional()
        .describe(
          "Commission value (auto-calculated from project settings if omitted)"
        ),
      base_value: z
        .number()
        .optional()
        .describe("Original transaction amount before commission"),
      affiliate_id: z
        .number()
        .int()
        .optional()
        .describe("ID of the referring affiliate"),
      referral_code: z
        .string()
        .optional()
        .describe(
          "Referral code to look up the affiliate (used if affiliate_id is not provided)"
        ),
      referred_user_id: z
        .number()
        .int()
        .optional()
        .describe("ID of the referred user"),
      email: z
        .string()
        .email()
        .optional()
        .describe("Email of the customer (for webhook payloads)"),
      paid: z
        .boolean()
        .optional()
        .describe("Whether the commission has been paid out (default false)"),
      reference: z
        .string()
        .optional()
        .describe("External reference ID (e.g. invoice number)"),
      coupon_code_used: z
        .string()
        .optional()
        .describe("Coupon code used in this conversion"),
      base_value_currency: z
        .string()
        .optional()
        .describe("Currency of the base value (e.g. USD, EUR)"),
    },
  • TypeScript interface CreateConversionInput defining the type structure for conversion creation with all optional fields
    export interface CreateConversionInput {
      type: "signup" | "purchase";
      value?: number;
      base_value?: number;
      affiliate_id?: number;
      referred_user_id?: number;
      referral_code?: string;
      paid?: boolean;
      reference?: string;
      coupon_code_used?: string;
      base_value_currency?: string;
      email?: string;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/refgrow/refgrow-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server