priceRuleDiscountCodeCreate mutation
Create a discount code for a price rule.
Required access
write_price_rules access scope.
On this page
Interactive example
This is an example mutation query. Use the embedded interactive tool below to edit the query.
Hint: use Ctrl + Space for autocompleting fields.
mutation priceRuleDiscountCodeCreate($priceRuleId: ID!, $code: String!) { priceRuleDiscountCodeCreate(priceRuleId: $priceRuleId, code: $code) {} } { “priceRuleId”: “Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE=”, “code”: “placeholder” }
<font style="color:#1F61A0;">priceRule</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">id</font><font style="color:#555555;">}</font><font style="color:#1F61A0;">priceRuleDiscountCode</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">id</font><font style="color:#555555;">}</font><font style="color:#1F61A0;">priceRuleUserErrors</font> <font style="color:#555555;">{</font><font style="color:#1F61A0;">code</font><font style="color:#1F61A0;">field</font><font style="color:#1F61A0;">message</font><font style="color:#555555;">}</font>
Arguments
Return fields
- priceRule (
[PriceRule](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerule))
The updated price rule. - priceRuleDiscountCode (
[PriceRuleDiscountCode](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/pricerulediscountcode))
The newly created discount code. - priceRuleUserErrors (
[[PriceRuleUserError!]!](https://shopify.dev/docs/admin-api/graphql/reference/discounts-and-marketing/priceruleusererror))
List of errors that occurred executing the mutation. 
Deprecated return fields
- userErrors (
[[UserError!]!](https://shopify.dev/docs/admin-api/graphql/reference/usererror)) DEPRECATED
List of errors that occurred executing the mutation.
Deprecation warning
UsepriceRuleUserErrorsinstead 
