appCreateDiscountCode
Requires permission products:discount:create.
Create a discount code from an installed app, for named customers. The server picks the code (APP-<HANDLE>-<random>) and fixes the scheme: bound to those customers, applied only when a buyer enters the code, percent only, switched off when the app is uninstalled. Needs write_discount_codes.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation AppCreateDiscountCode($input: AppCreateDiscountCodeInput!) {
appCreateDiscountCode(input: $input) {
id
code
name
customerIds
isActive
percentageValue
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation AppCreateDiscountCode($input: AppCreateDiscountCodeInput!) {\n appCreateDiscountCode(input: $input) {\n id\n code\n name\n customerIds\n isActive\n percentageValue\n }\n}",
"variables": {
"input": {
"customerIds": [
"id"
],
"name": "string",
"percentageValue": 0
}
}
}
EOF
Variables:
{
"input": {
"customerIds": [
"id"
],
"name": "string",
"percentageValue": 0
}
}
Response:
{
"data": {
"appCreateDiscountCode": {
"id": "id",
"code": "string",
"name": "string",
"customerIds": [
"id"
],
"isActive": true,
"percentageValue": 0
}
}
}
appCreateDiscountCode(
input: AppCreateDiscountCodeInput!
): AppDiscountCode!
Arguments
appCreateDiscountCode.input ● AppCreateDiscountCodeInput! non-null input
The code's customers and percentage.
Type
AppDiscountCode object
A discount code an installed app created.