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.
Write operation
This tool creates a unique discount code in the database and syncs it to Shopify. The code is permanently associated with your agent for attribution tracking. This operation is idempotent -- calling it again with the same parameters returns the existing code.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
agent_id | string | — | Your registered agent_id from register_agent. | |
campaign_id | int | null | null | Campaign 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.
| Field | Type | Description |
|---|---|---|
discount_codes | array | Array of discount code objects (see fields below). |
discount_codes[].discount_code | string | Unique discount code in the format CC-{AGENT}-{RANDOM}. |
discount_codes[].discount_percent | number | Percentage discount for the customer (e.g., 10.0 = 10% off). |
discount_codes[].campaign_name | string | Name of the campaign this code is associated with. |
discount_codes[].campaign_id | int | ID of the associated campaign. |
discount_codes[].expires_at | string | null | Expiration date in ISO 8601 format, or null if the campaign has no end date. |
discount_codes[].is_active | boolean | Whether the discount code is currently active and usable. |
{
"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.
{
"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.
{
"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
| Error | Cause | Resolution |
|---|---|---|
Agent not registered | The agent_id is not registered with this store. | Call register_agent first. |
Campaign not found | Invalid campaign_id or campaign belongs to a different store. | Call get_active_campaigns to get valid campaign IDs. |
{
"error": "Agent not registered. Call register_agent first.",
"hint": "Use register_agent to get an agent_id."
}{
"error": "Campaign 99 not found."
}