{"openapi":"3.0.3","info":{"title":"Regios Discounts REST API Reference","description":"Public HTTP API for Regios Discounts (API key via HTTP Basic).\n\n**Rate limits**\n\nThree independent **60 second** sliding windows; the first one you exhaust returns **429**\nwith `error.code` **`rate_limit_exceeded`**:\n\n- **Client IP** — default **600** requests per window. Counts **before** valid HTTP Basic, so\n  anonymous and authenticated traffic share the same IP bucket.\n- **API public key** — default **1200** requests per window. Counts **after** auth, keyed to\n  the Basic **username** (your public key).\n- **Shop** — default **1200** requests per window. Counts **after** auth; **every API key on\n  that store** shares one bucket.\n\nA **`RateLimit`** header may summarize remaining quota. Defaults may change; when throttled,\ntreat **429** and **`RateLimit`** as the live source of truth.\n\n**Logic**\n\n- Offer configuration is a proprietary **LogicNode** tree stored in Shopify metafields.\n- On the wire, `logic` is an arbitrary JSON **object**; its internal shape is **not** part of\n  this contract.\n","version":"1.0.0"},"servers":[{"url":"https://automatic-discounts.regiostech.com/api/v1","description":"Production"}],"tags":[{"name":"Discount Function types","description":"Shopify Discount Function types exposed by our app (use these when creating discounts)."},{"name":"Discounts","description":"Create, read, update, and deactivate discounts (code and automatic)."},{"name":"Redeem codes","description":"Bulk redeem codes on code discounts (code path only)."}],"security":[{"basicAuth":[]}],"paths":{"/discount-function-types":{"get":{"tags":["Discount function types"],"summary":"List discount function types","description":"Returns app discount types from Shopify (`appDiscountTypes`), normalized for REST. Use `functionId` when creating discounts via `POST /discounts/{code|automatic}`.\n","operationId":"getDiscountFunctionTypes","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","description":"Response from GET `/discount-function-types`.","required":["items"],"properties":{"items":{"description":"Available function types (order not guaranteed).","type":"array","items":{"type":"object","description":"One app discount function type available to the shop (from Shopify `appDiscountTypes`).","required":["name","discountType","functionId"],"properties":{"name":{"type":"string","description":"Merchant-facing label from Shopify (app discount type title)."},"discountType":{"description":"Editor / config shape for this function (same enum as discount `discountType`).","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"functionId":{"type":"string","description":"Shopify Function id without `gid://shopify/Function/`; use as `functionId` on POST create.\n"}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts":{"get":{"tags":["Discounts"],"summary":"List discounts (paginated)","description":"Paginated list of discounts for the authenticated shop. Filters and sort match query parameters below (comma-separated or repeated params for array values).\n","operationId":"listDiscounts","parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"default":25}},{"name":"sortField","in":"query","schema":{"type":"string","enum":["TITLE","CREATED_AT","STARTS_AT","ENDS_AT","UPDATED_AT"]}},{"name":"sortDirection","in":"query","schema":{"type":"string","enum":["ASC","DESC"]}},{"name":"method","in":"query","schema":{"type":"array","items":{"type":"string","enum":["AUTOMATIC","CODE"]}},"style":"form","explode":true,"description":"Filter by `AUTOMATIC` or `CODE` (Shopify discount kind)."},{"name":"discountClass","in":"query","schema":{"type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING"]}},"style":"form","explode":true},{"name":"discountType","in":"query","schema":{"type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART","METAFIELD","RETAIL_LOCATION","LINE_ITEM_PROPERTY","B2B_COMPANY","PRODUCT_ATTRIBUTE","INTERNATIONAL"]}},"style":"form","explode":true},{"name":"combinesWith","in":"query","schema":{"type":"array","items":{"type":"string","enum":["productDiscounts","orderDiscounts","shippingDiscounts"]}},"style":"form","explode":true},{"name":"status","in":"query","schema":{"type":"array","items":{"type":"string","enum":["ACTIVE","SCHEDULED","EXPIRED","DRAFT"]}},"style":"form","explode":true},{"name":"search","in":"query","schema":{"type":"string"},"description":"Case-insensitive partial match on title."},{"name":"startsAtOperator","in":"query","schema":{"type":"string","enum":["GT","GTE","LT","LTE","EQ"]}},{"name":"startsAtValue","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"endsAtOperator","in":"query","schema":{"type":"string","enum":["GT","GTE","LT","LTE","EQ"]}},{"name":"endsAtValue","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"neverEnds","in":"query","schema":{"type":"string","enum":["true"]},"description":"When `true`, only discounts with no end date."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","description":"Paginated GET `/discounts` response (mapped discounts only; unmappable rows are omitted).","required":["items","totalCount","page","limit","totalPages","hasNextPage","hasPreviousPage"],"properties":{"items":{"description":"Discounts on this page after server-side mapping.","type":"array","items":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}},"totalCount":{"type":"integer","description":"Total discounts matching filters (before pagination slice)."},"page":{"type":"integer","description":"Current page index (1-based)."},"limit":{"type":"integer","description":"Page size."},"totalPages":{"type":"integer","description":"Total number of pages for this `limit`."},"hasNextPage":{"type":"boolean","description":"Whether a higher page index exists."},"hasPreviousPage":{"type":"boolean","description":"Whether a lower page index exists."}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts/code":{"post":{"tags":["Discounts"],"summary":"Create a code discount","operationId":"createCodeDiscount","requestBody":{"required":true,"content":{"application/json":{"schema":{"description":"Request body for POST `/discounts/code` or `/discounts/automatic` (create).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["functionId"],"properties":{"functionId":{"type":"string","description":"Shopify Function resource id without the `gid://shopify/Function/` prefix; use a value from GET `/discount-function-types`.\n"}}}]},"examples":{"minimal":{"value":{"discountMethod":"CODE","discountClasses":["PRODUCT"],"discountType":"amount-off-products","title":"SUMMER10","customTitle":"Summer sale (internal label)","logic":{},"additionalShippingLogic":null,"combinesWith":{"orderDiscounts":false,"productDiscounts":true,"shippingDiscounts":false},"startsAt":"2026-01-01T00:00:00Z","endsAt":null,"usageLimit":1,"functionId":"1234567890"}}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts/automatic":{"post":{"tags":["Discounts"],"summary":"Create an automatic discount","operationId":"createAutomaticDiscount","requestBody":{"required":true,"content":{"application/json":{"schema":{"description":"Request body for POST `/discounts/code` or `/discounts/automatic` (create).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["functionId"],"properties":{"functionId":{"type":"string","description":"Shopify Function resource id without the `gid://shopify/Function/` prefix; use a value from GET `/discount-function-types`.\n"}}}]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts/code/{discountId}":{"get":{"tags":["Discounts"],"summary":"Get a code discount by id","operationId":"getCodeDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"put":{"tags":["Discounts"],"summary":"Replace a code discount","description":"Request body omits `discountType` and `functionId`; the server merges from Shopify before applying the update. `customTitle` omitted or JSON null resets the Shopify title to the redeem code.\n","operationId":"replaceCodeDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Full replace for PUT `/:discountId`. Same fields as the write body except `discountType` (and `functionId` when not applicable—see GET discount for current ids); server merges from Shopify before applying.\n","required":["discountMethod","discountClasses","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to; when `additionalShippingLogic` is non-null the server may append `SHIPPING` if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"title":{"type":"string","description":"Discount title; for `CODE` discounts also the primary redeem code."},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts (the app's \"Custom title\"). Omitted, JSON null, or empty resets the Shopify title to the redeem code. Ignored for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic (metafield `customLogic`).","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Shipping-specific logic extension; JSON null when not used.","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart` (any value is accepted but not stored — see DiscountWriteBody).\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"Combination rules with other discounts.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"Discount start time (ISO 8601)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"Discount end time or JSON null for no end date."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions; JSON null means unlimited. CODE only; AUTOMATIC must be JSON null.\n"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"patch":{"tags":["Discounts"],"summary":"Partially update a code discount","description":"Omit `customTitle` to keep the current internal label; send JSON null or empty to clear it.\n","operationId":"patchCodeDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Partial update for PATCH `/:discountId`. Omit a field to leave it unchanged. Do not send `functionId`, `discountType`, `id`, or `shopifyId`. Present fields follow the same rules as PUT.\n","properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to.","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"title":{"type":"string","description":"Discount title; for `CODE` discounts also the primary redeem code."},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts (the app's \"Custom title\"). Omit to leave unchanged; send JSON null or empty to clear it (Shopify title becomes the redeem code). Ignored for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic (metafield `customLogic`).","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Shipping-specific logic extension; JSON null when not used.","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Omit to leave unchanged. Ignored for `discountType` `auto-add-to-cart` (any value is accepted but not stored — see DiscountWriteBody).\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"Combination rules with other discounts.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Omit to leave unchanged. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"Discount start time (ISO 8601)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"Discount end time or JSON null for no end date."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions; JSON null clears the limit (unlimited). CODE only; AUTOMATIC must be JSON null if sent.\n"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"delete":{"tags":["Discounts"],"summary":"Deactivate a code discount","description":"Success returns **204** with an empty body.","operationId":"deleteCodeDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"responses":{"204":{"description":"No Content"},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts/automatic/{discountId}":{"get":{"tags":["Discounts"],"summary":"Get an automatic discount by id","operationId":"getAutomaticDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"put":{"tags":["Discounts"],"summary":"Replace an automatic discount","operationId":"replaceAutomaticDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Full replace for PUT `/:discountId`. Same fields as the write body except `discountType` (and `functionId` when not applicable—see GET discount for current ids); server merges from Shopify before applying.\n","required":["discountMethod","discountClasses","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to; when `additionalShippingLogic` is non-null the server may append `SHIPPING` if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"title":{"type":"string","description":"Discount title; for `CODE` discounts also the primary redeem code."},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts (the app's \"Custom title\"). Omitted, JSON null, or empty resets the Shopify title to the redeem code. Ignored for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic (metafield `customLogic`).","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Shipping-specific logic extension; JSON null when not used.","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart` (any value is accepted but not stored — see DiscountWriteBody).\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"Combination rules with other discounts.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"Discount start time (ISO 8601)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"Discount end time or JSON null for no end date."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions; JSON null means unlimited. CODE only; AUTOMATIC must be JSON null.\n"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"patch":{"tags":["Discounts"],"summary":"Partially update an automatic discount","operationId":"patchAutomaticDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Partial update for PATCH `/:discountId`. Omit a field to leave it unchanged. Do not send `functionId`, `discountType`, `id`, or `shopifyId`. Present fields follow the same rules as PUT.\n","properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to.","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"title":{"type":"string","description":"Discount title; for `CODE` discounts also the primary redeem code."},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts (the app's \"Custom title\"). Omit to leave unchanged; send JSON null or empty to clear it (Shopify title becomes the redeem code). Ignored for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic (metafield `customLogic`).","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Shipping-specific logic extension; JSON null when not used.","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Omit to leave unchanged. Ignored for `discountType` `auto-add-to-cart` (any value is accepted but not stored — see DiscountWriteBody).\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"Combination rules with other discounts.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Omit to leave unchanged. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"Discount start time (ISO 8601)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"Discount end time or JSON null for no end date."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions; JSON null clears the limit (unlimited). CODE only; AUTOMATIC must be JSON null if sent.\n"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"delete":{"tags":["Discounts"],"summary":"Deactivate an automatic discount","operationId":"deleteAutomaticDiscount","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"responses":{"204":{"description":"No Content"},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts/code/{discountId}/redeem-codes":{"get":{"tags":["Redeem codes"],"summary":"List redeem codes for a code discount","operationId":"listRedeemCodes","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"},{"name":"after","in":"query","schema":{"type":"string"},"description":"Cursor for forward pagination (Shopify connection)."},{"name":"before","in":"query","schema":{"type":"string"},"description":"Cursor for backward pagination."},{"name":"query","in":"query","schema":{"type":"string"},"description":"Search/filter string forwarded to Shopify."},{"name":"sort_key","in":"query","schema":{"type":"string"}},{"name":"reverse","in":"query","schema":{"type":"boolean"},"description":"Presence of the parameter enables reverse sort (handler checks `reverse` in query)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","description":"Response from GET `/discounts/code/{discountId}/redeem-codes` (one page).","required":["codesCount","codes","pageInfo"],"properties":{"codesCount":{"type":"integer","description":"Total redeem codes on this discount (Shopify `codesCount.count`); can be larger than `codes.length` for this response.\n"},"codes":{"description":"Codes returned for this request only. Page size is driven by Shopify/server (often tens per page).\n","type":"array","items":{"type":"object","description":"One redeem code row on a code discount (Shopify `DiscountRedeemCode`).","required":["id","code","asyncUsageCount"],"properties":{"id":{"type":"string","description":"Shopify Admin GraphQL `DiscountRedeemCode` id. Same string format accepted in `redeemCodeIds` on DELETE redeem-codes (GID and/or numeric id).\n"},"code":{"type":"string","description":"The string customers enter at checkout to redeem this code."},"asyncUsageCount":{"type":"integer","description":"Usage count from Shopify’s async counter on the redeem code (may not match every storefront “times used” read path).\n"}}}},"pageInfo":{"description":"Cursors to fetch the next or previous page of the same discount’s codes.","allOf":[{"type":"object","description":"Cursor pagination for the discount’s `codes` connection (Shopify connection semantics).","required":["endCursor","hasNextPage","hasPreviousPage","startCursor"],"properties":{"endCursor":{"type":"string","description":"Cursor for the end of this page; pass as `after` on the next list request."},"hasNextPage":{"type":"boolean","description":"Whether more codes exist after this page."},"hasPreviousPage":{"type":"boolean","description":"Whether codes exist before this page."},"startCursor":{"type":"string","description":"Cursor for the start of this page; pass as `before` when paging backward."}}}]}}}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"post":{"tags":["Redeem codes"],"summary":"Queue bulk creation of redeem codes","description":"Accepts a static list of code strings. The parent discount’s primary code is resolved from Shopify using `discountId`; clients must not send it in JSON.\n","operationId":"createRedeemCodes","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"POST `/discounts/code/{discountId}/redeem-codes`. Only a static string list (no random batches or CSV `userFileId` on v1). The parent discount’s primary code comes from Shopify via `discountId` in the path—do not send it in JSON.\n","required":["codes"],"properties":{"codes":{"description":"Redeem strings to add (non-empty after trim). Duplicates or conflicts may appear in `userErrors` or in job `status`, not necessarily as HTTP 400.\n","type":"array","items":{"type":"string"}}}}}}},"responses":{"201":{"description":"Created (jobs queued)","content":{"application/json":{"schema":{"type":"object","description":"Response after POST redeem-codes queues bulk-create work.","required":["jobs","userErrors"],"properties":{"jobs":{"description":"Jobs created or updated by this call; often a single summary row.","type":"array","items":{"type":"object","description":"Summary of a bulk create/delete redeem-code job (create/delete responses and jobs list).","required":["id","status","description"],"properties":{"id":{"type":"string","description":"Bulk job identifier from the app/Shopify pipeline."},"status":{"description":"Current lifecycle state of the job.","allOf":[{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]}]},"description":{"type":"string","description":"Human-readable summary of the job (e.g. bulk create/delete scope)."},"progress":{"type":"number","minimum":0,"maximum":1,"description":"Optional completion estimate in `[0, 1]` when known (e.g. processed ÷ expected for in-flight creates). Often omitted for deletes until completion.\n"}}}},"userErrors":{"description":"Request-level validation or Shopify errors. Empty when the body was accepted and work was queued (job-level failures are not duplicated here).\n","type":"array","items":{"type":"object","description":"Validation or Shopify user error in redeem-code job payloads (trimmed vs raw Admin GraphQL: no `code` / `extraInfo` here).\n","required":["message"],"properties":{"message":{"type":"string","description":"Human-readable error text (same role as Shopify `UserError.message`)."},"field":{"type":"array","items":{"type":"string"},"nullable":true,"description":"When Shopify returns an input path, its segments (e.g. `[\"codes\", \"0\"]`). JSON null when no path was provided.\n"}}}}}}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}},"delete":{"tags":["Redeem codes"],"summary":"Queue bulk deletion of redeem codes","description":"**201** with a job payload when delete work is queued (including empty id list, which returns **200** with empty jobs per server behavior for zero ids).\n","operationId":"deleteRedeemCodes","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"DELETE `/discounts/code/{discountId}/redeem-codes` JSON body. Identifiers are Shopify `DiscountRedeemCode` resource ids only (no lookup by checkout “code” string on the server). No “delete all” on v1.\n","required":["redeemCodeIds"],"properties":{"redeemCodeIds":{"type":"array","items":{"type":"string"},"description":"Ids to delete: full `gid://shopify/DiscountRedeemCode/...` and/or numeric id strings. Duplicates are deduped before queuing.\n"}}}}}},"responses":{"200":{"description":"OK (no ids after dedupe — empty jobs)","content":{"application/json":{"schema":{"type":"object","description":"Response after DELETE redeem-codes queues bulk-delete work (or returns empty jobs when no ids).","required":["jobs","userErrors"],"properties":{"jobs":{"description":"Delete job(s) scheduled for the resolved ids.","type":"array","items":{"type":"object","description":"Summary of a bulk create/delete redeem-code job (create/delete responses and jobs list).","required":["id","status","description"],"properties":{"id":{"type":"string","description":"Bulk job identifier from the app/Shopify pipeline."},"status":{"description":"Current lifecycle state of the job.","allOf":[{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]}]},"description":{"type":"string","description":"Human-readable summary of the job (e.g. bulk create/delete scope)."},"progress":{"type":"number","minimum":0,"maximum":1,"description":"Optional completion estimate in `[0, 1]` when known (e.g. processed ÷ expected for in-flight creates). Often omitted for deletes until completion.\n"}}}},"userErrors":{"description":"Errors that prevented scheduling a delete job (validation, limits, etc.).","type":"array","items":{"type":"object","description":"Validation or Shopify user error in redeem-code job payloads (trimmed vs raw Admin GraphQL: no `code` / `extraInfo` here).\n","required":["message"],"properties":{"message":{"type":"string","description":"Human-readable error text (same role as Shopify `UserError.message`)."},"field":{"type":"array","items":{"type":"string"},"nullable":true,"description":"When Shopify returns an input path, its segments (e.g. `[\"codes\", \"0\"]`). JSON null when no path was provided.\n"}}}}}}}}},"201":{"description":"Created (delete job queued)","content":{"application/json":{"schema":{"type":"object","description":"Response after DELETE redeem-codes queues bulk-delete work (or returns empty jobs when no ids).","required":["jobs","userErrors"],"properties":{"jobs":{"description":"Delete job(s) scheduled for the resolved ids.","type":"array","items":{"type":"object","description":"Summary of a bulk create/delete redeem-code job (create/delete responses and jobs list).","required":["id","status","description"],"properties":{"id":{"type":"string","description":"Bulk job identifier from the app/Shopify pipeline."},"status":{"description":"Current lifecycle state of the job.","allOf":[{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]}]},"description":{"type":"string","description":"Human-readable summary of the job (e.g. bulk create/delete scope)."},"progress":{"type":"number","minimum":0,"maximum":1,"description":"Optional completion estimate in `[0, 1]` when known (e.g. processed ÷ expected for in-flight creates). Often omitted for deletes until completion.\n"}}}},"userErrors":{"description":"Errors that prevented scheduling a delete job (validation, limits, etc.).","type":"array","items":{"type":"object","description":"Validation or Shopify user error in redeem-code job payloads (trimmed vs raw Admin GraphQL: no `code` / `extraInfo` here).\n","required":["message"],"properties":{"message":{"type":"string","description":"Human-readable error text (same role as Shopify `UserError.message`)."},"field":{"type":"array","items":{"type":"string"},"nullable":true,"description":"When Shopify returns an input path, its segments (e.g. `[\"codes\", \"0\"]`). JSON null when no path was provided.\n"}}}}}}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"402":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts/code/{discountId}/redeem-codes/{code}":{"get":{"tags":["Redeem codes"],"summary":"Look up a single redeem code on a code discount","description":"Returns the redeem code row matching `code` on this discount, including its Shopify async usage count. Returns **404** when the code is not attached to this discount.\n","operationId":"getRedeemCodeByCode","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"},{"name":"code","in":"path","required":true,"schema":{"type":"string"},"description":"The exact redeem string customers enter at checkout. Case-sensitive exact match (server filters Shopify's `code:` prefix search to one row).\n"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","description":"One redeem code row on a code discount (Shopify `DiscountRedeemCode`).","required":["id","code","asyncUsageCount"],"properties":{"id":{"type":"string","description":"Shopify Admin GraphQL `DiscountRedeemCode` id. Same string format accepted in `redeemCodeIds` on DELETE redeem-codes (GID and/or numeric id).\n"},"code":{"type":"string","description":"The string customers enter at checkout to redeem this code."},"asyncUsageCount":{"type":"integer","description":"Usage count from Shopify’s async counter on the redeem code (may not match every storefront “times used” read path).\n"}}}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"404":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}},"/discounts/code/{discountId}/redeem-code-jobs":{"get":{"tags":["Redeem codes"],"summary":"List redeem-code bulk jobs","description":"Returns a JSON **array** of job summaries (not wrapped in an object).","operationId":"listRedeemCodeJobs","parameters":[{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","description":"Summary of a bulk create/delete redeem-code job (create/delete responses and jobs list).","required":["id","status","description"],"properties":{"id":{"type":"string","description":"Bulk job identifier from the app/Shopify pipeline."},"status":{"description":"Current lifecycle state of the job.","allOf":[{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]}]},"description":{"type":"string","description":"Human-readable summary of the job (e.g. bulk create/delete scope)."},"progress":{"type":"number","minimum":0,"maximum":1,"description":"Optional completion estimate in `[0, 1]` when known (e.g. processed ÷ expected for in-flight creates). Often omitted for deletes until completion.\n"}}}}}}},"400":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"401":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"403":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"429":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}}}}},"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"Username = API public key, password = API secret (`Authorization: Basic ...`).\n"}},"parameters":{"Page":{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},"Limit":{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"default":25}},"SortField":{"name":"sortField","in":"query","schema":{"type":"string","enum":["TITLE","CREATED_AT","STARTS_AT","ENDS_AT","UPDATED_AT"]}},"SortDirection":{"name":"sortDirection","in":"query","schema":{"type":"string","enum":["ASC","DESC"]}},"DiscountId":{"name":"discountId","in":"path","required":true,"schema":{"type":"string"},"description":"Shopify discount node id in numeric form only (no `gid://` prefix). Same value as `id` on GET discount responses; use it in the URL path for GET/PUT/PATCH/DELETE.\n"}},"responses":{"Unauthorized":{"description":"Missing or invalid `Authorization` / credentials","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"invalidAuth":{"value":{"error":{"code":"invalid_authorization","message":"Missing or invalid Authorization header."}}}}}}},"Forbidden":{"description":"Valid credentials but no Shopify session for the shop (re-auth), or other 403 cases","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"NotFound":{"description":"Discount or route not found","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"BadRequest":{"description":"Validation or bad request","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"PaymentRequired":{"description":"Subscription canceled; discount writes blocked","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"ServerError":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}},"TooManyRequests":{"description":"**Too many requests.** A sliding-window limit was exceeded.\n\nThree **60 second** windows run in parallel; the first one you exhaust for this request\nproduces **429**:\n\n- **Client IP** — starts before valid HTTP Basic; default **600** requests per IP per window.\n- **API public key** — starts after successful auth (Basic username); default **1200**\n  requests per key per window.\n- **Shop** — starts after successful auth; default **1200** requests per shop per window (all\n  keys on that shop share this bucket).\n\nThe body uses `error.code` **`rate_limit_exceeded`**. `error.message` is human-readable only;\n**do not** branch logic on its exact wording.\n\n**Retrying:** Use exponential backoff. If a **`RateLimit`** header is present, use it to pace\nretries. Defaults can change; when throttled, **429** and **`RateLimit`** beat static numbers.\n\n**Clusters:** Each app instance tracks counts separately unless the deployment merges state, so\nobserved limits can differ slightly from the defaults above.\n","headers":{"RateLimit":{"description":"When present, describes quota for this response (IETF-style RateLimit field). Use it with **429** to schedule retries.\n","schema":{"type":"string"},"example":"limit=600, remaining=0, reset=45"}},"content":{"application/json":{"schema":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}},"examples":{"rateLimitExceeded":{"summary":"Shop window exhausted","value":{"error":{"code":"rate_limit_exceeded","message":"Too many requests for this shop. Slow down or wait for the rate limit window to reset."}}}}}}}},"schemas":{"DiscountMethodFilter":{"type":"string","enum":["AUTOMATIC","CODE"]},"DiscountClassFilter":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING"]},"DiscountTypeFilter":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART","METAFIELD","RETAIL_LOCATION","LINE_ITEM_PROPERTY","B2B_COMPANY","PRODUCT_ATTRIBUTE","INTERNATIONAL"]},"CombinesWithFilter":{"type":"string","enum":["productDiscounts","orderDiscounts","shippingDiscounts"]},"DiscountStatusFilter":{"type":"string","enum":["ACTIVE","SCHEDULED","EXPIRED","DRAFT"]},"DiscountSortField":{"type":"string","enum":["TITLE","CREATED_AT","STARTS_AT","ENDS_AT","UPDATED_AT"]},"SortDirection":{"type":"string","enum":["ASC","DESC"]},"DateComparisonOperator":{"type":"string","enum":["GT","GTE","LT","LTE","EQ"]},"LogicNode":{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"},"NullableLogicNode":{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"DiscountMethod":{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."},"DiscountClass":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"},"DiscountType":{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]},"DiscountCombinesWith":{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}},"DiscountWriteBody":{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},"CreateDiscountRequest":{"description":"Request body for POST `/discounts/code` or `/discounts/automatic` (create).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["functionId"],"properties":{"functionId":{"type":"string","description":"Shopify Function resource id without the `gid://shopify/Function/` prefix; use a value from GET `/discount-function-types`.\n"}}}]},"UpdateDiscountRequest":{"type":"object","description":"Full replace for PUT `/:discountId`. Same fields as the write body except `discountType` (and `functionId` when not applicable—see GET discount for current ids); server merges from Shopify before applying.\n","required":["discountMethod","discountClasses","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to; when `additionalShippingLogic` is non-null the server may append `SHIPPING` if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"title":{"type":"string","description":"Discount title; for `CODE` discounts also the primary redeem code."},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts (the app's \"Custom title\"). Omitted, JSON null, or empty resets the Shopify title to the redeem code. Ignored for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic (metafield `customLogic`).","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Shipping-specific logic extension; JSON null when not used.","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart` (any value is accepted but not stored — see DiscountWriteBody).\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"Combination rules with other discounts.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"Discount start time (ISO 8601)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"Discount end time or JSON null for no end date."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions; JSON null means unlimited. CODE only; AUTOMATIC must be JSON null.\n"}}},"PatchDiscountRequest":{"type":"object","description":"Partial update for PATCH `/:discountId`. Omit a field to leave it unchanged. Do not send `functionId`, `discountType`, `id`, or `shopifyId`. Present fields follow the same rules as PUT.\n","properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to.","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"title":{"type":"string","description":"Discount title; for `CODE` discounts also the primary redeem code."},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts (the app's \"Custom title\"). Omit to leave unchanged; send JSON null or empty to clear it (Shopify title becomes the redeem code). Ignored for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic (metafield `customLogic`).","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Shipping-specific logic extension; JSON null when not used.","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Omit to leave unchanged. Ignored for `discountType` `auto-add-to-cart` (any value is accepted but not stored — see DiscountWriteBody).\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"Combination rules with other discounts.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Omit to leave unchanged. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"Discount start time (ISO 8601)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"Discount end time or JSON null for no end date."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions; JSON null clears the limit (unlimited). CODE only; AUTOMATIC must be JSON null if sent.\n"}}},"Discount":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]},"DiscountListResponse":{"type":"object","description":"Paginated GET `/discounts` response (mapped discounts only; unmappable rows are omitted).","required":["items","totalCount","page","limit","totalPages","hasNextPage","hasPreviousPage"],"properties":{"items":{"description":"Discounts on this page after server-side mapping.","type":"array","items":{"description":"Discount returned by GET list/detail (includes read-only ids).","allOf":[{"type":"object","description":"Canonical discount fields for GET responses and POST bodies. PUT/PATCH use subsets (see those schemas). Use JSON null only where the field allows it (`endsAt`, `additionalShippingLogic`, `usageLimit`).\n","required":["discountMethod","discountClasses","discountType","title","logic","additionalShippingLogic","salePriceHandlingStrategy","combinesWith","tags","startsAt","endsAt","usageLimit"],"properties":{"discountMethod":{"description":"Must match the route (`CODE` vs `AUTOMATIC`).","allOf":[{"type":"string","enum":["CODE","AUTOMATIC"],"description":"Must match the URL path (`/discounts/code` vs `/discounts/automatic`)."}]},"discountClasses":{"description":"Classes this discount applies to. For `discountType` `auto-add-to-cart`, only `AUTO_ADD_TO_CART` and `PRODUCT` may appear (server may normalize to both). Other types must not include `AUTO_ADD_TO_CART`. When `additionalShippingLogic` is non-null, the server appends `SHIPPING` here if missing.\n","type":"array","items":{"type":"string","enum":["PRODUCT","ORDER","SHIPPING","AUTO_ADD_TO_CART"],"description":"Discount class on the persisted discount. `AUTO_ADD_TO_CART` is an app-level marker used with `PRODUCT` for auto-add-to-cart; only `PRODUCT`, `ORDER`, and `SHIPPING` are sent to Shopify Admin.\n"}},"discountType":{"description":"Editor / function shape for this discount. On PUT/PATCH the client does not send this; the server fills it from Shopify before mutations.\n","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"title":{"type":"string","description":"Discount title. For `CODE` discounts this is also the primary redeem code (no separate `code` field on this API).\n"},"customTitle":{"type":"string","nullable":true,"maxLength":255,"description":"Optional internal label for `CODE` discounts, the same as the app's \"Custom title\" field. Customers never see it. On write, a non-empty value becomes the Shopify discount title; otherwise the Shopify title is the redeem code (`title`), as in the app. Ignored for `AUTOMATIC` discounts. On GET it is the Shopify title when that differs from the primary redeem code, else JSON null; always JSON null for `AUTOMATIC`.\n"},"logic":{"description":"Main offer conditional logic; stored as `customLogic` in the function-configuration metafield (same JSON shape as persisted app config).\n","allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]},"additionalShippingLogic":{"description":"Extra rules when this discount also targets shipping. Must be JSON null for `auto-add-to-cart` or `amount-off-shipping`. When non-null, the server ensures `SHIPPING` appears in `discountClasses` if needed.\n","allOf":[{"description":"Same JSON shape as LogicNode; send JSON null when not applicable.","nullable":true,"allOf":[{"type":"object","description":"Proprietary conditional logic tree for the discount offer. Stored as JSON inside Shopify function configuration; **not** a public schema. Treat as an opaque object.\n"}]}]},"salePriceHandlingStrategy":{"description":"How this discount handles items that are already on sale. Ignored for `discountType` `auto-add-to-cart`: its Shopify Function call always hardcodes `APPLY_TO_COMPARE_AT_PRICE` and the admin has no control for it, so any value sent here is accepted but not stored, and GET always reports `APPLY_TO_COMPARE_AT_PRICE` for it.\n","allOf":[{"type":"string","description":"How the discount handles items whose compare-at price is greater than their sale price. `STACK` applies the discount on top of the current sale price.\n","enum":["APPLY_TO_COMPARE_AT_PRICE","STACK","STACK_ON_TOP_OF_SALE_PRICE_AND_PRODUCT_DISCOUNTS","SKIP"]}]},"combinesWith":{"description":"How this discount may combine with other discounts at checkout.","allOf":[{"type":"object","description":"Whether this discount may combine with other order, product, or shipping discounts.","required":["orderDiscounts","productDiscounts","shippingDiscounts"],"properties":{"orderDiscounts":{"type":"boolean","description":"Allow combining with other order discounts."},"productDiscounts":{"type":"boolean","description":"Allow combining with other product discounts."},"shippingDiscounts":{"type":"boolean","description":"Allow combining with other shipping discounts."},"productDiscountsWithTagsOnSameCartLine":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":10,"description":"Same-line stacking tags: the tags another product discount must carry (as its own `tags`) to combine with this one on the same cart line — this is the mechanism behind Shopify's merchant-facing \"combine specific discounts\" / sale-price stacking controls. Shopify Plus only; requires `productDiscounts: true`, and both discounts must reciprocate (each names the other's tags). Omit or send an empty array to require no tags; JSON null reads the same as an empty array. Max 10 tags (Shopify's own limit); accepted on write regardless of plan or discount class, but Shopify itself rejects it for non-Plus shops.\n"}}}]},"tags":{"type":"array","items":{"type":"string"},"maxItems":5,"description":"Tags on this discount, used to identify it for other discounts' same-line stacking (`combinesWith.productDiscountsWithTagsOnSameCartLine`). Empty array when unset. Max 5 tags (Shopify's own limit).\n"},"startsAt":{"type":"string","format":"date-time","description":"When the discount becomes active (ISO 8601, Shopify `startsAt`)."},"endsAt":{"type":"string","format":"date-time","nullable":true,"description":"When the discount stops; JSON null means open-ended (Shopify `endsAt`)."},"usageLimit":{"type":"integer","minimum":1,"nullable":true,"description":"Maximum total redemptions for this discount; JSON null means unlimited. Only applied for `CODE` discounts (Shopify `usageLimit`). For `AUTOMATIC` must be JSON null. Use `1` for a single-use code.\n"}}},{"type":"object","required":["id","shopifyId","functionId"],"properties":{"id":{"type":"string","description":"Stripped numeric Shopify id (same as path `:discountId` for writes)."},"shopifyId":{"type":"string","description":"Full GraphQL id (`gid://shopify/DiscountCodeNode/...` or `DiscountAutomaticNode/...`)."},"functionId":{"type":"string","description":"Shopify Function id for this discount (numeric; no `gid://` prefix)."}}}]}},"totalCount":{"type":"integer","description":"Total discounts matching filters (before pagination slice)."},"page":{"type":"integer","description":"Current page index (1-based)."},"limit":{"type":"integer","description":"Page size."},"totalPages":{"type":"integer","description":"Total number of pages for this `limit`."},"hasNextPage":{"type":"boolean","description":"Whether a higher page index exists."},"hasPreviousPage":{"type":"boolean","description":"Whether a lower page index exists."}}},"DiscountFunctionType":{"type":"object","description":"One app discount function type available to the shop (from Shopify `appDiscountTypes`).","required":["name","discountType","functionId"],"properties":{"name":{"type":"string","description":"Merchant-facing label from Shopify (app discount type title)."},"discountType":{"description":"Editor / config shape for this function (same enum as discount `discountType`).","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"functionId":{"type":"string","description":"Shopify Function id without `gid://shopify/Function/`; use as `functionId` on POST create.\n"}}},"DiscountFunctionTypesResponse":{"type":"object","description":"Response from GET `/discount-function-types`.","required":["items"],"properties":{"items":{"description":"Available function types (order not guaranteed).","type":"array","items":{"type":"object","description":"One app discount function type available to the shop (from Shopify `appDiscountTypes`).","required":["name","discountType","functionId"],"properties":{"name":{"type":"string","description":"Merchant-facing label from Shopify (app discount type title)."},"discountType":{"description":"Editor / config shape for this function (same enum as discount `discountType`).","allOf":[{"type":"string","description":"In-app editor / configuration shape (Shopify function “subdirectory”). Same enum as `discountType` on write bodies and `additionalData.restApiDiscountType` in stored config.\n","enum":["amount-off-products","amount-off-order","amount-off-shipping","shipping-address","metafield-discount","pos-discount","line-item-props-discount","auto-add-to-cart","b2b-company-discount","product-attribute-discount","international-discount"]}]},"functionId":{"type":"string","description":"Shopify Function id without `gid://shopify/Function/`; use as `functionId` on POST create.\n"}}}}}},"RedeemCode":{"type":"object","description":"One redeem code row on a code discount (Shopify `DiscountRedeemCode`).","required":["id","code","asyncUsageCount"],"properties":{"id":{"type":"string","description":"Shopify Admin GraphQL `DiscountRedeemCode` id. Same string format accepted in `redeemCodeIds` on DELETE redeem-codes (GID and/or numeric id).\n"},"code":{"type":"string","description":"The string customers enter at checkout to redeem this code."},"asyncUsageCount":{"type":"integer","description":"Usage count from Shopify’s async counter on the redeem code (may not match every storefront “times used” read path).\n"}}},"PageInfo":{"type":"object","description":"Cursor pagination for the discount’s `codes` connection (Shopify connection semantics).","required":["endCursor","hasNextPage","hasPreviousPage","startCursor"],"properties":{"endCursor":{"type":"string","description":"Cursor for the end of this page; pass as `after` on the next list request."},"hasNextPage":{"type":"boolean","description":"Whether more codes exist after this page."},"hasPreviousPage":{"type":"boolean","description":"Whether codes exist before this page."},"startCursor":{"type":"string","description":"Cursor for the start of this page; pass as `before` when paging backward."}}},"GetRedeemCodesResponse":{"type":"object","description":"Response from GET `/discounts/code/{discountId}/redeem-codes` (one page).","required":["codesCount","codes","pageInfo"],"properties":{"codesCount":{"type":"integer","description":"Total redeem codes on this discount (Shopify `codesCount.count`); can be larger than `codes.length` for this response.\n"},"codes":{"description":"Codes returned for this request only. Page size is driven by Shopify/server (often tens per page).\n","type":"array","items":{"type":"object","description":"One redeem code row on a code discount (Shopify `DiscountRedeemCode`).","required":["id","code","asyncUsageCount"],"properties":{"id":{"type":"string","description":"Shopify Admin GraphQL `DiscountRedeemCode` id. Same string format accepted in `redeemCodeIds` on DELETE redeem-codes (GID and/or numeric id).\n"},"code":{"type":"string","description":"The string customers enter at checkout to redeem this code."},"asyncUsageCount":{"type":"integer","description":"Usage count from Shopify’s async counter on the redeem code (may not match every storefront “times used” read path).\n"}}}},"pageInfo":{"description":"Cursors to fetch the next or previous page of the same discount’s codes.","allOf":[{"type":"object","description":"Cursor pagination for the discount’s `codes` connection (Shopify connection semantics).","required":["endCursor","hasNextPage","hasPreviousPage","startCursor"],"properties":{"endCursor":{"type":"string","description":"Cursor for the end of this page; pass as `after` on the next list request."},"hasNextPage":{"type":"boolean","description":"Whether more codes exist after this page."},"hasPreviousPage":{"type":"boolean","description":"Whether codes exist before this page."},"startCursor":{"type":"string","description":"Cursor for the start of this page; pass as `before` when paging backward."}}}]}}},"RedeemCodeJobStatus":{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]},"RedeemCodeJob":{"type":"object","description":"Summary of a bulk create/delete redeem-code job (create/delete responses and jobs list).","required":["id","status","description"],"properties":{"id":{"type":"string","description":"Bulk job identifier from the app/Shopify pipeline."},"status":{"description":"Current lifecycle state of the job.","allOf":[{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]}]},"description":{"type":"string","description":"Human-readable summary of the job (e.g. bulk create/delete scope)."},"progress":{"type":"number","minimum":0,"maximum":1,"description":"Optional completion estimate in `[0, 1]` when known (e.g. processed ÷ expected for in-flight creates). Often omitted for deletes until completion.\n"}}},"RedeemCodeUserError":{"type":"object","description":"Validation or Shopify user error in redeem-code job payloads (trimmed vs raw Admin GraphQL: no `code` / `extraInfo` here).\n","required":["message"],"properties":{"message":{"type":"string","description":"Human-readable error text (same role as Shopify `UserError.message`)."},"field":{"type":"array","items":{"type":"string"},"nullable":true,"description":"When Shopify returns an input path, its segments (e.g. `[\"codes\", \"0\"]`). JSON null when no path was provided.\n"}}},"CreateRedeemCodesRequest":{"type":"object","description":"POST `/discounts/code/{discountId}/redeem-codes`. Only a static string list (no random batches or CSV `userFileId` on v1). The parent discount’s primary code comes from Shopify via `discountId` in the path—do not send it in JSON.\n","required":["codes"],"properties":{"codes":{"description":"Redeem strings to add (non-empty after trim). Duplicates or conflicts may appear in `userErrors` or in job `status`, not necessarily as HTTP 400.\n","type":"array","items":{"type":"string"}}}},"CreateRedeemCodesResponse":{"type":"object","description":"Response after POST redeem-codes queues bulk-create work.","required":["jobs","userErrors"],"properties":{"jobs":{"description":"Jobs created or updated by this call; often a single summary row.","type":"array","items":{"type":"object","description":"Summary of a bulk create/delete redeem-code job (create/delete responses and jobs list).","required":["id","status","description"],"properties":{"id":{"type":"string","description":"Bulk job identifier from the app/Shopify pipeline."},"status":{"description":"Current lifecycle state of the job.","allOf":[{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]}]},"description":{"type":"string","description":"Human-readable summary of the job (e.g. bulk create/delete scope)."},"progress":{"type":"number","minimum":0,"maximum":1,"description":"Optional completion estimate in `[0, 1]` when known (e.g. processed ÷ expected for in-flight creates). Often omitted for deletes until completion.\n"}}}},"userErrors":{"description":"Request-level validation or Shopify errors. Empty when the body was accepted and work was queued (job-level failures are not duplicated here).\n","type":"array","items":{"type":"object","description":"Validation or Shopify user error in redeem-code job payloads (trimmed vs raw Admin GraphQL: no `code` / `extraInfo` here).\n","required":["message"],"properties":{"message":{"type":"string","description":"Human-readable error text (same role as Shopify `UserError.message`)."},"field":{"type":"array","items":{"type":"string"},"nullable":true,"description":"When Shopify returns an input path, its segments (e.g. `[\"codes\", \"0\"]`). JSON null when no path was provided.\n"}}}}}},"DeleteRedeemCodesRequest":{"type":"object","description":"DELETE `/discounts/code/{discountId}/redeem-codes` JSON body. Identifiers are Shopify `DiscountRedeemCode` resource ids only (no lookup by checkout “code” string on the server). No “delete all” on v1.\n","required":["redeemCodeIds"],"properties":{"redeemCodeIds":{"type":"array","items":{"type":"string"},"description":"Ids to delete: full `gid://shopify/DiscountRedeemCode/...` and/or numeric id strings. Duplicates are deduped before queuing.\n"}}},"DeleteRedeemCodesResponse":{"type":"object","description":"Response after DELETE redeem-codes queues bulk-delete work (or returns empty jobs when no ids).","required":["jobs","userErrors"],"properties":{"jobs":{"description":"Delete job(s) scheduled for the resolved ids.","type":"array","items":{"type":"object","description":"Summary of a bulk create/delete redeem-code job (create/delete responses and jobs list).","required":["id","status","description"],"properties":{"id":{"type":"string","description":"Bulk job identifier from the app/Shopify pipeline."},"status":{"description":"Current lifecycle state of the job.","allOf":[{"type":"string","description":"Bulk job lifecycle: `PENDING` (queued), `IN_PROGRESS`, `SUCCEEDED`, or `FAILED`.\n","enum":["FAILED","IN_PROGRESS","PENDING","SUCCEEDED"]}]},"description":{"type":"string","description":"Human-readable summary of the job (e.g. bulk create/delete scope)."},"progress":{"type":"number","minimum":0,"maximum":1,"description":"Optional completion estimate in `[0, 1]` when known (e.g. processed ÷ expected for in-flight creates). Often omitted for deletes until completion.\n"}}}},"userErrors":{"description":"Errors that prevented scheduling a delete job (validation, limits, etc.).","type":"array","items":{"type":"object","description":"Validation or Shopify user error in redeem-code job payloads (trimmed vs raw Admin GraphQL: no `code` / `extraInfo` here).\n","required":["message"],"properties":{"message":{"type":"string","description":"Human-readable error text (same role as Shopify `UserError.message`)."},"field":{"type":"array","items":{"type":"string"},"nullable":true,"description":"When Shopify returns an input path, its segments (e.g. `[\"codes\", \"0\"]`). JSON null when no path was provided.\n"}}}}}},"ApiV1ErrorCode":{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]},"ErrorField":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}},"ErrorEnvelope":{"type":"object","description":"Standard JSON shape for any `/api/v1` error response (4xx / 5xx). Read `error.code` for programmatic handling and `error.message` for display; optional `error.fields` lists per-field validation or Shopify user error rows.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"description":"Error payload (single object; no top-level success fields).","properties":{"code":{"description":"Stable error category; see schema `ApiV1ErrorCode` for allowed values.","allOf":[{"type":"string","description":"Machine-readable error category for `/api/v1` JSON bodies. Branch on this value; use `error.message` for a default user-facing string. Values: **`invalid_authorization`** — missing `Authorization`, not `Basic`, or bad Base64 / `user:secret` shape; **`invalid_api_credentials`** — unknown API key or secret mismatch; **`shop_session_required`** — no Shopify offline session for this app instance (re-auth); **`subscription_canceled`** — shop subscription canceled; discount writes blocked; **`add_on_required`** — the shop needs the API & MCP add-on (**403**); **`discount_not_found`** — discount id missing or not visible; **`not_found`** — generic 404 (e.g. no matching `/api/v1` route); **`validation_error`** — body or params failed validation (see `error.fields`); **`shopify_user_errors`** — Shopify Admin returned `userErrors` for the operation; **`bad_request`** — other 4xx fallback; **`internal_error`** — 5xx or unexpected failure; **`rate_limit_exceeded`** — too many requests in the configured window (**429**).\n","enum":["invalid_authorization","invalid_api_credentials","shop_session_required","subscription_canceled","add_on_required","discount_not_found","not_found","validation_error","shopify_user_errors","bad_request","internal_error","rate_limit_exceeded"]}]},"message":{"type":"string","description":"Short human-readable summary for logs or a default UI message."},"fields":{"description":"Present for validation failures and some Shopify errors: each entry is a field path plus message. Omitted when there are no per-field details.\n","type":"array","items":{"type":"object","description":"One validation or Shopify-reported issue tied to an input path.","required":["field","message"],"properties":{"field":{"type":"string","description":"Logical field path (e.g. Joi path joined with `.`, or Shopify `userErrors[].field`).\n"},"message":{"type":"string","description":"Human-readable explanation for this field."}}}}}}}}}}}