Anchor to returnRequestreturn
returnRequest
mutation
Requires access scope or
access scope. Also: Requires the
access scope. The user must have
permission.
A customer's return request that hasn't been approved or declined.
This mutation sets the value of the Return.status
field to .
To create a return that has the
Return.status
field set to , use the
mutation.
Anchor to Arguments
Arguments
- Anchor to inputinput•Return
Request requiredInput! The input fields for requesting a return.
Was this section helpful?
Anchor to ReturnRequestPayload returnsReturnRequestPayload returns
- Anchor to returnreturn•
The requested return.
- Anchor to userErrorsuser•
Errors [ReturnUser non-nullError!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Request a return
- returnRequest reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation ReturnRequest($input: ReturnRequestInput!) {6 returnRequest(input: $input) {7 userErrors {8 field9 message10 }11 return {12 id13 status14 returnLineItems(first: 1) {15 edges {16 node {17 id18 returnReason19 customerNote20 }21 }22 }23 order {24 id25 }26 }27 }28 }`,29 {30 variables: {31 "input": {32 "orderId": "gid://shopify/Order/625362839",33 "returnLineItems": [34 {35 "fulfillmentLineItemId": "gid://shopify/FulfillmentLineItem/820022594",36 "quantity": 1,37 "returnReason": "WRONG_ITEM",38 "customerNote": "Sorry, I ordered the wrong item. Could I get a refund or store credit?"39 }40 ]41 }42 },43 },44);4546const data = await response.json();47
mutation ReturnRequest($input: ReturnRequestInput!) {
returnRequest(input: $input) {
userErrors {
field
message
}
return {
id
status
returnLineItems(first: 1) {
edges {
node {
id
returnReason
customerNote
}
}
}
order {
id
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation ReturnRequest($input: ReturnRequestInput!) { returnRequest(input: $input) { userErrors { field message } return { id status returnLineItems(first: 1) { edges { node { id returnReason customerNote } } } order { id } } } }",
"variables": {
"input": {
"orderId": "gid://shopify/Order/625362839",
"returnLineItems": [
{
"fulfillmentLineItemId": "gid://shopify/FulfillmentLineItem/820022594",
"quantity": 1,
"returnReason": "WRONG_ITEM",
"customerNote": "Sorry, I ordered the wrong item. Could I get a refund or store credit?"
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation ReturnRequest($input: ReturnRequestInput!) {
returnRequest(input: $input) {
userErrors {
field
message
}
return {
id
status
returnLineItems(first: 1) {
edges {
node {
id
returnReason
customerNote
}
}
}
order {
id
}
}
}
}`,
{
variables: {
"input": {
"orderId": "gid://shopify/Order/625362839",
"returnLineItems": [
{
"fulfillmentLineItemId": "gid://shopify/FulfillmentLineItem/820022594",
"quantity": 1,
"returnReason": "WRONG_ITEM",
"customerNote": "Sorry, I ordered the wrong item. Could I get a refund or store credit?"
}
]
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation ReturnRequest($input: ReturnRequestInput!) {
returnRequest(input: $input) {
userErrors {
field
message
}
return {
id
status
returnLineItems(first: 1) {
edges {
node {
id
returnReason
customerNote
}
}
}
order {
id
}
}
}
}`,
"variables": {
"input": {
"orderId": "gid://shopify/Order/625362839",
"returnLineItems": [
{
"fulfillmentLineItemId": "gid://shopify/FulfillmentLineItem/820022594",
"quantity": 1,
"returnReason": "WRONG_ITEM",
"customerNote": "Sorry, I ordered the wrong item. Could I get a refund or store credit?"
}
]
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation ReturnRequest($input: ReturnRequestInput!) {
returnRequest(input: $input) {
userErrors {
field
message
}
return {
id
status
returnLineItems(first: 1) {
edges {
node {
id
returnReason
customerNote
}
}
}
order {
id
}
}
}
}
QUERY
variables = {
"input": {
"orderId": "gid://shopify/Order/625362839",
"returnLineItems": [{"fulfillmentLineItemId"=>"gid://shopify/FulfillmentLineItem/820022594", "quantity"=>1, "returnReason"=>"WRONG_ITEM", "customerNote"=>"Sorry, I ordered the wrong item. Could I get a refund or store credit?"}]
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "input": {3 "orderId": "gid://shopify/Order/625362839",4 "returnLineItems": [5 {6 "fulfillmentLineItemId": "gid://shopify/FulfillmentLineItem/820022594",7 "quantity": 1,8 "returnReason": "WRONG_ITEM",9 "customerNote": "Sorry, I ordered the wrong item. Could I get a refund or store credit?"10 }11 ]12 }13}
Response
JSON1{2 "returnRequest": {3 "userErrors": [],4 "return": {5 "id": "gid://shopify/Return/945000961",6 "status": "REQUESTED",7 "returnLineItems": {8 "edges": [9 {10 "node": {11 "id": "gid://shopify/ReturnLineItem/677614678",12 "returnReason": "WRONG_ITEM",13 "customerNote": "Sorry, I ordered the wrong item. Could I get a refund or store credit?"14 }15 }16 ]17 },18 "order": {19 "id": "gid://shopify/Order/625362839"20 }21 }22 }23}