Create Shopify Discount Code
create_shopify_discount_codeCreate a discount code on the connected Shopify store: a percentage or a fixed amount off, on the whole store or on specific Spark items (each must be linked to a Shopify product), from a start day to an optional end day, with an optional total usage limit and once-per-customer rule. The code is open to every customer and does not combine with other discounts. The store must have "Let Spark create discount codes" turned on and Shopify's discount permission granted; the preview says what is missing when either is not. Dates are the account's local days (YYYY-MM-DD); the start defaults to today. Requires an operator (unpinned) credential with Write + storefront.execute and the Admin role. In-app assistants get a confirm card the user applies; nothing is sent to Shopify before that.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>",
"valueType": "<valueType>",
"value": "<value>"
},
"name": "create_shopify_discount_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The code customers type at checkout, e.g. SPRING20. Letters, numbers, dashes or underscores; no spaces. Shopify ignores case. | |
| title | No | The discount's name in Shopify admin; defaults to the code. | |
| value | Yes | The percent off (more than 0, at most 100) or the amount off in the store's currency. | |
| endsOn | No | Last day the code works, YYYY-MM-DD (inclusive); omit for no end. | |
| itemIds | No | Spark item ids (GUIDs) the code applies to; omit for every product in the store. Find them with search_items. | |
| preview | No | Step 1 of the required two-step write: set true to validate and receive a structured preview plus a single-use previewReceipt. Nothing changes until the commit call. | |
| startsOn | No | First day the code works, YYYY-MM-DD; defaults to today. | |
| valueType | Yes | "percentage" for a percent off, or "fixed_amount" for an amount off. | |
| usageLimit | No | How many times the code can be used in total; omit for no limit. | |
| idempotencyKey | No | Caller-generated idempotency key; required with previewReceipt to commit. | |
| previewReceipt | No | Step 2 of the required two-step write: the receipt returned by the preview call. Supply together with a fresh idempotencyKey to commit; calls without it are refused. | |
| oncePerCustomer | No | True to let each customer use the code only once. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | No | ||
| preview | No | ||
| warning | No | ||
| expiresAt | No | ||
| actionItemId | No | ||
| confirmation | No | ||
| discountCode | No | ||
| correlationId | No | ||
| approvalResult | No | ||
| idempotencyKey | No | ||
| previewReceipt | No | ||
| idempotentReplay | No |