draftOrderCreate / draftOrderUpdate called as a staff member: if the appapply_discounts_to_draft_orders tries to add a discount for a staff member without the permission, it gets ACCESS_DENIED. The draft order isn't saved, and the error is returned not in userErrors but in the top-level errors . Applies to all supported API versions.
apply_discounts_to_draft_orders permission, the entire mutation is rejected with ACCESS_DENIED .null. The error doesn't appear in userErrors .
Top-level errors contains ACCESS_DENIED.data.draftOrderUpdate(or draftOrderCreate) returns null. No changes are saved at all.
Existing discounts on a draft order can still bekept as is, orremovedjust as before. Only adding discounts is rejected.
| Operation (DraftOrderInput) | draftOrderUpdate | draftOrderCreate |
|---|---|---|
discountCodes set with a code |
Counts as adding Contains a codenot already onthe draft order | Counts as adding Always, if not empty(since the draft order doesn't exist yet) |
acceptAutomaticDiscounts: true |
Counts as adding Set to true on a draft order that doesn't yet accept automatic discounts | Counts as adding Always, if true |
| Keep existing discounts | Works as before | — |
| Remove existing discounts | Works as before | — |
mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {
draftOrderUpdate(id: $id, input: $input) {
draftOrder {
id
discountCodes
acceptAutomaticDiscounts
}
userErrors {
field
message
}
}
}
{
"id": "gid://shopify/DraftOrder/276395349",
"input": {
"discountCodes": ["SUMMER10"],
"acceptAutomaticDiscounts": true
}
}
{
"errors": [
{
"message": "Access denied for draftOrderUpdate field. Required access: `write_draft_orders` access scope. Also: The user must have access to manage draft orders.",
"locations": [{ "line": 2, "column": 3 }],
"path": ["draftOrderUpdate"],
"extensions": {
"code": "ACCESS_DENIED",
"documentation": "https://shopify.dev/api/usage/access-scopes",
"requiredAccess": "`write_draft_orders` access scope. Also: The user must have access to manage draft orders."
}
}
],
"data": {
"draftOrderUpdate": null
}
}
The payload itself is null , so code that readsdata.draftOrderUpdate.userErrors breaks at that point.
The error type is identified by extensions.code = "ACCESS_DENIED", and the target by path .
draftOrderCreate returns the same error. The message and path become draftOrderCreate , anddata.draftOrderCreate is null.
draftOrderCreate or draftOrderUpdate is run as a staff member.
Relies on adding discount codes or turning on automatic discounts.
Doesn't make sure the staff member has the apply_discounts_to_draft_orders permission.
For example, requests made with an offline access token.
Requests that only keep or remove existing discounts.
Find places that, acting as staff, call draftOrderCreate / draftOrderUpdate and passdiscountCodes or acceptAutomaticDiscounts .
userErrors alone isn't enough. Add handling that checks the top-level errors array for ACCESS_DENIED .
If you need to add discounts, ask the merchant to give staff the Apply discounts permission under Draft orders.
draftOrderCreate / draftOrderUpdate / DraftOrderInput / Store permissions (both on shopify.dev).If you detect failures using only userErrors.length , the payload null may throw an exception or be misread as a success. The article explicitly states that error handling needs to be updated.
This isn't a change starting from a specific API version. It applies to all supported versions, so the behavior changes even if you stay on your current version.
In the example response, message / requiredAccess mention the write_draft_orders scope. The wording doesn't make it clear that the cause is the discount permission, so it's safer to branch onextensions.code and path .
Update only covers adding codes that don't already exist, or newly turning on automatic discounts. For Create, a non-empty discountCodes or acceptAutomaticDiscounts: true isalwaystreated as an addition. On Update, simply resending existing values as-is won't trigger it.
The change affectsrequests acting as staffonly. Requests that don't act as a staff member, such as those using offline access tokens, are not affected. The fastest way to assess impact is to inventory which token type your apps use to call the draft order API.
userErrors alone, which means this ACCESS_DENIED could be missed.draftOrderCreate / draftOrderUpdate , then add shared handling that checks the top-level errors for ACCESS_DENIED .extensions.code and path(draftOrderCreate / draftOrderUpdate). Write null-safe code, assuming the payload will be null .draftOrderUpdate call sends both line item changes and discount additions, so when permissions are insufficient, even the line item changes aren't saved.discountCodes ,acceptAutomaticDiscounts: true) and, if needed, redesign the flow so non-discount updates are sent first.discountCodes is always treated as adding a discount, so you need a branch that creates the order without discounts for staff who lack the permission.apply_discounts_to_draft_orders permission is now required.