API reference
CreateDiscountCode
Create a discount code and, with connectionId, place it on that store. Write access, discounts toolset, MCP tool create_discount_code.
Access: Write
Variables
| Variable | Type | Required | Accepts | Description |
|---|---|---|---|---|
input | CreateDiscountCodeInput! | yes | Input object, below |
Input types
CreateDiscountCodeInput
| Field | Type | Required | Accepts | Description |
|---|---|---|---|---|
body | JSON! | yes | Object, fields below | Discount create body. Invalid input returns userErrors. |
connectionId | UUID | no | Optional owner connection. Omit to create a workspace-level (unplaced) discount and place it on connections later; pass a connectionId to seed a single owner placement. |
CreateDiscountCodeInput.body
| Field | Type | Required | Accepts | Description |
|---|---|---|---|---|
code | string | yes | 1 to 255 characters, matches ^\S+$ | |
aliased_codes | list of object | yes | Object, fields below. at most 1000 items | |
title | string | yes | 1 to 255 characters | |
display_name | string or null | no | at most 255 characters | |
value_kind | string | yes | One of percent, amount | |
value_percent | number or null | yes | 0 to 100 | |
value_amount | number or null | yes | 0 to 5000 | |
usage_limit | integer or null | yes | 1 to 999999 | |
start_at | string,null | yes | ||
ends_at | string,null | yes | ||
one_time_purchase | boolean | no | ||
status | string | yes | One of EXPIRED, DRAFT, SCHEDULED, ACTIVE | |
is_public | boolean | no | ||
public_tier | string | no | One of BASIC, QUICK, ENHANCED | |
origin | string | no | 1 to 255 characters | |
tags | object | no | ||
placements | list of object | no | Object, fields below |
CreateDiscountCodeInput.body.aliased_codes
| Field | Type | Required | Accepts | Description |
|---|---|---|---|---|
id | string | no | 1 to 255 characters | |
code | string | yes | 1 to 255 characters, matches ^\S+$ |
CreateDiscountCodeInput.body.placements
| Field | Type | Required | Accepts | Description |
|---|---|---|---|---|
connectionId | string | yes | 1 to 255 characters | |
child | object | no |
Call it
bash
curl https://api.missin.co.uk/graphql/v1 \
-H "Authorization: Bearer $MISSIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"operationName":"CreateDiscountCode","variables":{"input":{"body":{"code":"…","aliased_codes":[],"title":"…","value_kind":"percent","value_percent":20,"value_amount":20,"usage_limit":20,"start_at":{},"ends_at":{},"status":"EXPIRED"}}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"f4ca9e669e52156460beaf9f84994e2f356794298c6bb5a3a7fc9bfdda2d1919"}}}'Document
graphql
mutation CreateDiscountCode($input: CreateDiscountCodeInput!) { __typename createDiscountCode(input: $input) { __typename id pendingSync userErrors { __typename code field message } } }