Commission Tool

get_my_discount_code

Get or create a unique discount code attributed to your agent. When a customer uses your code at checkout, the sale is tracked for commission attribution.

Parameters

ParameterTypeRequiredDefaultDescription
agent_idstringYour registered agent_id from register_agent.
campaign_idint | nullnullCampaign ID to get a code for. Omit or pass null to get codes for all active campaigns with customer discounts.

campaign_id type

The campaign_id parameter is an integer, not a string. Get valid campaign IDs from get_active_campaigns. Passing null returns codes for all active campaigns with customer discounts.

Response

Returns an object containing an array of discount code objects.

FieldTypeDescription
discount_codesarrayArray of discount code objects (see fields below).
discount_codes[].discount_codestringUnique discount code in the format CC-{AGENT}-{RANDOM}.
discount_codes[].discount_percentnumberPercentage discount for the customer (e.g., 10.0 = 10% off).
discount_codes[].campaign_namestringName of the campaign this code is associated with.
discount_codes[].campaign_idintID of the associated campaign.
discount_codes[].expires_atstring | nullExpiration date in ISO 8601 format, or null if the campaign has no end date.
discount_codes[].is_activebooleanWhether the discount code is currently active and usable.
Response (single campaign)
{
  "discount_codes": [
    {
      "discount_code": "CC-COFF-A7X2",
      "discount_percent": 10.0,
      "campaign_name": "Spring Sale",
      "campaign_id": 5,
      "expires_at": "2026-03-31T23:59:59+00:00",
      "is_active": true
    }
  ]
}

Multiple Campaign Codes

When campaign_id is omitted, you receive codes for all active campaigns with customer discounts.

Response (all campaigns)
{
  "discount_codes": [
    {
      "discount_code": "CC-COFF-A7X2",
      "discount_percent": 10.0,
      "campaign_name": "Spring Sale",
      "campaign_id": 5,
      "expires_at": "2026-03-31T23:59:59+00:00",
      "is_active": true
    },
    {
      "discount_code": "CC-COFF-K9M3",
      "discount_percent": 15.0,
      "campaign_name": "Holiday Promo",
      "campaign_id": 8,
      "expires_at": "2026-12-31T23:59:59+00:00",
      "is_active": true
    }
  ]
}

No Active Campaigns

If no campaigns with customer discounts are active, the response includes an empty array and an explanatory message.

Response (no campaigns)
{
  "discount_codes": [],
  "message": "No active campaigns with customer discounts at this time."
}

Notes

Code format

Discount codes follow the pattern CC-{AGENT}-{RANDOM} where {AGENT} is the first 4 alphanumeric characters of your agent name (uppercased) and {RANDOM} is 4 random alphanumeric characters.

Shopify sync

Discount codes are automatically synced to the store's Shopify account. Customers can apply the code at checkout just like any other Shopify discount code.

Idempotent

Requesting a code for the same campaign returns the previously generated code. You will not receive a new code each time you call this tool.

Errors

ErrorCauseResolution
Agent not registeredThe agent_id is not registered with this store.Call register_agent first.
Campaign not foundInvalid campaign_id or campaign belongs to a different store.Call get_active_campaigns to get valid campaign IDs.
Error: not registered
{
  "error": "Agent not registered. Call register_agent first.",
  "hint": "Use register_agent to get an agent_id."
}
Error: campaign not found
{
  "error": "Campaign 99 not found."
}