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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'Manually create' and commission calculation behavior, which adds some context beyond basic creation. However, it fails to disclose critical behavioral traits: whether this is a mutating operation (implied but not stated), permission requirements, idempotency, error handling, or what happens on success (e.g., returns a conversion ID). For a creation tool with 11 parameters, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that cover the core purpose and key usage notes. It's front-loaded with the main action. However, the second sentence could be slightly more structured to separate affiliate identification from commission logic, but overall it avoids waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (11 parameters, creation operation) and lack of annotations or output schema, the description is minimally adequate. It covers the basic purpose and hints at some behaviors but misses important context: no output information, no error scenarios, and incomplete behavioral transparency. It relies heavily on the well-documented schema, leaving gaps for agent invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema: it clarifies that 'value' is auto-calculated for purchases if omitted, and that 'affiliate_id' or 'referral_code' can identify affiliates. This provides some high-level context but doesn't significantly enhance parameter understanding beyond the schema's detailed descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Manually create a conversion (signup or purchase).' It specifies the verb ('create') and resource ('conversion') with subtypes. However, it doesn't explicitly differentiate from sibling tools like 'create_affiliate' or 'create_coupon' beyond the resource type, missing an opportunity to clarify domain boundaries.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance by mentioning 'For purchases, the commission is auto-calculated from project settings if value is not provided' and 'You can identify the affiliate by ID or referral code.' This suggests when to omit certain parameters. However, it lacks explicit when-to-use vs. alternatives (e.g., compared to 'update_conversion' or automated conversion tracking), and no prerequisites or exclusions are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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