ctevan
1
In a returnCreate I’m getting the error “Mutation had user errors: “Return reason definition not found.”“
{
"returnInput": {
"orderId": "{{order.id}}",
"returnLineItems": [
{
"quantity": 1,
"returnReasonNote": "Automatic return",
"returnReasonDefinitionId": "gid://shopify/ReturnReasonDefinition/551551176",
"fulfillmentLineItemId": "{% for fulfillmentLineItems_item in fulfillment.fulfillmentLineItems %}{% if fulfillmentLineItems_item.lineItem.sku == "121792" %}{{ fulfillmentLineItems_item.id }}{% endif %}{% endfor %}"
}
]
}
}
I got the ID i’m using from returnReasonDefinitions - GraphQL Admin
Moeed
2
Hey @ctevan
That error means the returnReasonDefinitionId you’re using doesn’t exist in your store. Those IDs are store-specific.
Run this query in your admin GraphiQL to get the valid ones for your store:
{
returnReasonDefinitions(first: 25) {
edges {
node {
id
name
reason
}
}
}
}
Then swap out the ID in your code:
{
"returnInput": {
"orderId": "{{order.id}}",
"returnLineItems": [
{
"quantity": 1,
"returnReasonNote": "Automatic return",
"returnReasonDefinitionId": "PASTE_YOUR_ID_HERE",
"fulfillmentLineItemId": "{% for fulfillmentLineItems_item in fulfillment.fulfillmentLineItems %}{% if fulfillmentLineItems_item.lineItem.sku == \"121792\" %}{{ fulfillmentLineItems_item.id }}{% endif %}{% endfor %}"
}
]
}
}
Replace PASTE_YOUR_ID_HERE with one of the IDs from the query results and you should be good to go.
Hope that helps! If it did, a Like and Marking it as Solution goes a long way and helps others find the fix faster too.
Best,
Moeed