> Markdown versions of all pages of this connector library are available by appending `.md` to the page URL. For the full index of connectors, see [llms.txt](https://connectors.appmixer.com/llms.txt).

# appmixer.shopify.discounts.CreateDiscountCode

- Component: `appmixer.shopify.discounts.CreateDiscountCode`
- Kind: Action
- Version: 1.0.0
- Visibility: Public
- Connector: [appmixer.shopify 4.1.0](https://connectors.appmixer.com/connector/appmixer.shopify/4.1.0.md)
- Component page: <https://connectors.appmixer.com/connector/appmixer.shopify/4.1.0/component/appmixer.shopify.discounts.CreateDiscountCode>

Create a discount code that takes a percentage or a fixed amount off the order. Leave the code empty to have one generated.

## Input ports

### Port `in`

| Field | Type | Description |
| --- | --- | --- |
| Discount Type (`valueType`) | select | Whether the code takes a percentage off the order subtotal or a fixed amount in the store currency. |
| Discount Value (`value`) | number | The size of the discount as a positive number, e.g. **15** for 15% off or 15 off in the store currency. Percentage discounts cannot exceed 100. |
| Discount Code (`code`) | text | The code customers enter at checkout. Leave empty to have a random 8-character code generated. Codes must be unique in the store. |
| Title (`title`) | text | The name of the discount shown in the Shopify admin. Defaults to the discount code. |
| Minimum Order Subtotal (`minimumSubtotal`) | number | Only apply the code when the order subtotal reaches this amount. Leave empty for no minimum. |
| Starts At (`startsAt`) | date-time | When the code becomes usable. Defaults to the moment the component runs. |
| Ends At (`endsAt`) | date-time | When the code expires. Leave empty for a code that never expires. |
| Usage Limit (`usageLimit`) | number | How many times the code can be redeemed in total. Leave empty for unlimited. |
| Once Per Customer (`appliesOncePerCustomer`) | toggle | Whether each customer can redeem the code only once. |

## Output ports

### Port `out`

| Field | Type | Description |
| --- | --- | --- |
| Discount ID (`id`) | string | - |
| Discount Type (`discountType`) | string | - |
| Title (`title`) | string | - |
| Status (`status`) | string | - |
| Starts At (`startsAt`) | string | - |
| Ends At (`endsAt`) | string | - |
| Usage Limit (`usageLimit`) | integer | - |
| Once Per Customer (`appliesOncePerCustomer`) | boolean | - |
| Usage Count (`asyncUsageCount`) | integer | - |
| Created At (`createdAt`) | string | - |
| Updated At (`updatedAt`) | string | - |
| Combines With (`combinesWith`) | object | - |
| Codes (`codes`) | array | - |
| Summary (`summary`) | string | - |
| Customer Gets (`customerGets`) | object | - |
| Minimum Requirement (`minimumRequirement`) | object | - |

## Full metadata (component.json)

```json
{
  "name": "appmixer.shopify.discounts.CreateDiscountCode",
  "description": "Create a discount code that takes a percentage or a fixed amount off the order. Leave the code empty to have one generated.",
  "author": "Appmixer <info@appmixer.com>",
  "private": false,
  "auth": {
    "service": "appmixer:shopify",
    "scope": [
      "read_discounts",
      "write_discounts"
    ]
  },
  "quota": {
    "manager": "appmixer:shopify",
    "resources": "requests",
    "scope": {
      "userId": "{{userId}}"
    }
  },
  "inPorts": [
    {
      "name": "in",
      "schema": {
        "type": "object",
        "properties": {
          "valueType": {
            "type": "string",
            "enum": [
              "percentage",
              "fixedAmount"
            ]
          },
          "value": {
            "type": "number"
          },
          "code": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "minimumSubtotal": {
            "type": "number"
          },
          "startsAt": {
            "type": "string",
            "format": "date-time"
          },
          "endsAt": {
            "type": "string",
            "format": "date-time"
          },
          "usageLimit": {
            "type": "integer"
          },
          "appliesOncePerCustomer": {
            "type": "boolean"
          }
        },
        "required": [
          "valueType",
          "value"
        ]
      },
      "inspector": {
        "inputs": {
          "valueType": {
            "type": "select",
            "label": "Discount Type",
            "index": 0,
            "defaultValue": "percentage",
            "tooltip": "Whether the code takes a percentage off the order subtotal or a fixed amount in the store currency.",
            "options": [
              {
                "label": "Percentage",
                "value": "percentage"
              },
              {
                "label": "Fixed Amount",
                "value": "fixedAmount"
              }
            ]
          },
          "value": {
            "type": "number",
            "label": "Discount Value",
            "index": 1,
            "min": 0,
            "tooltip": "The size of the discount as a positive number, e.g. <b>15</b> for 15% off or 15 off in the store currency. Percentage discounts cannot exceed 100."
          },
          "code": {
            "type": "text",
            "label": "Discount Code",
            "index": 2,
            "tooltip": "The code customers enter at checkout. Leave empty to have a random 8-character code generated. Codes must be unique in the store."
          },
          "title": {
            "type": "text",
            "label": "Title",
            "index": 3,
            "tooltip": "The name of the discount shown in the Shopify admin. Defaults to the discount code."
          },
          "minimumSubtotal": {
            "type": "number",
            "label": "Minimum Order Subtotal",
            "index": 4,
            "min": 0,
            "tooltip": "Only apply the code when the order subtotal reaches this amount. Leave empty for no minimum."
          },
          "startsAt": {
            "type": "date-time",
            "label": "Starts At",
            "index": 5,
            "tooltip": "When the code becomes usable. Defaults to the moment the component runs."
          },
          "endsAt": {
            "type": "date-time",
            "label": "Ends At",
            "index": 6,
            "tooltip": "When the code expires. Leave empty for a code that never expires."
          },
          "usageLimit": {
            "type": "number",
            "label": "Usage Limit",
            "index": 7,
            "min": 1,
            "tooltip": "How many times the code can be redeemed in total. Leave empty for unlimited."
          },
          "appliesOncePerCustomer": {
            "type": "toggle",
            "label": "Once Per Customer",
            "index": 8,
            "defaultValue": false,
            "tooltip": "Whether each customer can redeem the code only once."
          }
        }
      }
    }
  ],
  "outPorts": [
    {
      "name": "out",
      "schema": {
        "type": "object",
        "required": [
          "id",
          "discountType",
          "title",
          "status",
          "startsAt",
          "appliesOncePerCustomer",
          "asyncUsageCount",
          "createdAt",
          "updatedAt",
          "combinesWith",
          "codes"
        ],
        "properties": {
          "id": {
            "type": "string",
            "title": "Discount ID",
            "example": "gid://shopify/DiscountCodeNode/2382143062097"
          },
          "discountType": {
            "type": "string",
            "title": "Discount Type",
            "example": "DiscountCodeBasic"
          },
          "title": {
            "type": "string",
            "title": "Title",
            "example": "Autumn sale"
          },
          "status": {
            "type": "string",
            "title": "Status",
            "example": "ACTIVE"
          },
          "startsAt": {
            "type": "string",
            "title": "Starts At",
            "example": "2026-10-05T08:23:12Z",
            "format": "date-time"
          },
          "endsAt": {
            "type": "string",
            "title": "Ends At",
            "example": "2026-11-04T08:23:12Z",
            "format": "date-time"
          },
          "usageLimit": {
            "type": "integer",
            "title": "Usage Limit",
            "example": 10
          },
          "appliesOncePerCustomer": {
            "type": "boolean",
            "title": "Once Per Customer",
            "example": false
          },
          "asyncUsageCount": {
            "type": "integer",
            "title": "Usage Count",
            "example": 0
          },
          "createdAt": {
            "type": "string",
            "title": "Created At",
            "example": "2026-10-05T08:23:13Z",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "title": "Updated At",
            "example": "2026-10-05T08:23:13Z",
            "format": "date-time"
          },
          "combinesWith": {
            "type": "object",
            "title": "Combines With",
            "required": [
              "orderDiscounts",
              "productDiscounts",
              "shippingDiscounts"
            ],
            "properties": {
              "orderDiscounts": {
                "type": "boolean",
                "title": "Combines With.Order Discounts",
                "example": false
              },
              "productDiscounts": {
                "type": "boolean",
                "title": "Combines With.Product Discounts",
                "example": false
              },
              "shippingDiscounts": {
                "type": "boolean",
                "title": "Combines With.Shipping Discounts",
                "example": false
              }
            }
          },
          "codes": {
            "type": "array",
            "title": "Codes",
            "items": {
              "type": "object",
              "required": [
                "id",
                "code",
                "asyncUsageCount",
                "createdAt"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "title": "ID",
                  "example": "gid://shopify/DiscountRedeemCode/34881968013393"
                },
                "code": {
                  "type": "string",
                  "title": "Code",
                  "example": "AUTUMN15"
                },
                "asyncUsageCount": {
                  "type": "integer",
                  "title": "Usage Count",
                  "example": 0
                },
                "createdAt": {
                  "type": "string",
                  "title": "Created At",
                  "example": "2026-10-05T08:23:13Z",
                  "format": "date-time"
                }
              }
            },
            "example": [
              {
                "id": "gid://shopify/DiscountRedeemCode/34881968013393",
                "code": "AUTUMN15",
                "asyncUsageCount": 0,
                "createdAt": "2026-10-05T08:23:13Z"
              }
            ]
          },
          "summary": {
            "type": "string",
            "title": "Summary",
            "example": "15% off one-time purchase products • Minimum purchase of $50.00"
          },
          "customerGets": {
            "type": "object",
            "title": "Customer Gets",
            "required": [
              "value"
            ],
            "properties": {
              "value": {
                "type": "object",
                "title": "Customer Gets.Value",
                "properties": {
                  "percentage": {
                    "type": "number",
                    "title": "Customer Gets.Value.Percentage",
                    "example": 0.15
                  },
                  "amount": {
                    "type": "object",
                    "title": "Customer Gets.Value.Amount",
                    "required": [
                      "amount",
                      "currencyCode"
                    ],
                    "properties": {
                      "amount": {
                        "type": "string",
                        "title": "Customer Gets.Value.Amount.Amount",
                        "example": "5.0"
                      },
                      "currencyCode": {
                        "type": "string",
                        "title": "Customer Gets.Value.Amount.Currency Code",
                        "example": "USD"
                      }
                    }
                  },
                  "appliesOnEachItem": {
                    "type": "boolean",
                    "title": "Customer Gets.Value.Applies on Each Item",
                    "example": false
                  }
                }
              }
            }
          },
          "minimumRequirement": {
            "type": "object",
            "title": "Minimum Requirement",
            "properties": {
              "greaterThanOrEqualToSubtotal": {
                "type": "object",
                "title": "Minimum Requirement.Minimum Subtotal",
                "required": [
                  "amount",
                  "currencyCode"
                ],
                "properties": {
                  "amount": {
                    "type": "string",
                    "title": "Minimum Requirement.Minimum Subtotal.Amount",
                    "example": "50.0"
                  },
                  "currencyCode": {
                    "type": "string",
                    "title": "Minimum Requirement.Minimum Subtotal.Currency Code",
                    "example": "USD"
                  }
                }
              },
              "greaterThanOrEqualToQuantity": {
                "type": "string",
                "title": "Minimum Requirement.Minimum Quantity",
                "example": "2"
              }
            }
          }
        }
      }
    }
  ],
  "icon": "(data URI omitted)"
}
```
