Skip to main content
Glama

Create Shopify Discount Code

create_shopify_discount_code

Create 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

NameRequiredDescriptionDefault
codeYesThe code customers type at checkout, e.g. SPRING20. Letters, numbers, dashes or underscores; no spaces. Shopify ignores case.
titleNoThe discount's name in Shopify admin; defaults to the code.
valueYesThe percent off (more than 0, at most 100) or the amount off in the store's currency.
endsOnNoLast day the code works, YYYY-MM-DD (inclusive); omit for no end.
itemIdsNoSpark item ids (GUIDs) the code applies to; omit for every product in the store. Find them with search_items.
previewNoStep 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.
startsOnNoFirst day the code works, YYYY-MM-DD; defaults to today.
valueTypeYes"percentage" for a percent off, or "fixed_amount" for an amount off.
usageLimitNoHow many times the code can be used in total; omit for no limit.
idempotencyKeyNoCaller-generated idempotency key; required with previewReceipt to commit.
previewReceiptNoStep 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.
oncePerCustomerNoTrue to let each customer use the code only once.

Output Schema

NameRequiredDescriptionDefault
okNo
previewNo
warningNo
expiresAtNo
actionItemIdNo
confirmationNo
discountCodeNo
correlationIdNo
approvalResultNo
idempotencyKeyNo
previewReceiptNo
idempotentReplayNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations (which only say not-read-only, open-world, not idempotent, not destructive). It discloses that the code is open to every customer, does not combine with other discounts, is scoped to local account days with start defaulting to today, and that the write is a required two-step preview-then-commit with nothing sent to Shopify until the user applies the confirm card. The auth and settings prerequisites are exactly the kind of context annotations cannot carry.

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?

Front-loaded with the verb and resource, then layered from offer shape to eligibility rules to prerequisites to the commit flow. It is one dense paragraph with several semicolon-chained clauses, and the credential sentence is heavy, but every clause carries operational information rather than filler.

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

Completeness5/5

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

For a 12-parameter, open-world mutation with an output schema, the description covers what an agent needs: scope of the discount, eligibility limitations, date semantics and defaults, prerequisites that commonly cause failure, and the mandatory preview/commit protocol. Return values are properly left to the output schema, so nothing material is missing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the prose adds meaning the schema does not: the percentage/fixed_amount split maps to value semantics, itemIds must reference Spark items linked to Shopify products, days are the account's local YYYY-MM-DD days with start defaulting to today, and the optionality of end date, usage limit, and once-per-customer is stated as a coherent policy. The two-step preview/commit intent is also summarized, though the mechanical receipt-plus-fresh-idempotency-key pairing is left to the schema.

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

Purpose5/5

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

Opens with a specific verb and resource ("Create a discount code on the connected Shopify store") and immediately bounds the operation: percentage vs fixed amount, whole store vs specific Spark items, date window, usage limit, once-per-customer. The mention of Spark items needing Shopify product linkage and the store-level toggle distinguishes this from a generic local discount tool such as save_discount or delete_discount.

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

Usage Guidelines4/5

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

Gives real preconditions for use: the "Let Spark create discount codes" setting must be on, Shopify's discount permission must be granted, and the preview reports what is missing when they are not. It also states the operator credential, Write + storefront.execute, and Admin role requirements, plus the confirm-card behavior for in-app assistants. The one gap is that it never explicitly contrasts with save_discount, so an agent must infer that this tool targets Shopify rather than a Spark-native discount record.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources