# returnDeclineRequest - admin-graphql - MUTATION Version: 2024-07 ## Description Declines a return on an order. When a return is declined, each `ReturnLineItem.fulfillmentLineItem` can be associated to a new return. Use the `ReturnCreate` or `ReturnRequest` mutation to initiate a new return. ### Access Scopes `write_returns` access scope or `write_marketplace_returns` access scope. Also: Requires the `write_orders` access scope. The user must have `return_orders` permission. ## Arguments * [input](/docs/api/admin-graphql/2024-07/input-objects/ReturnDeclineRequestInput): ReturnDeclineRequestInput! - The input fields for declining a customer's return request. ## Returns * [return](/docs/api/admin-graphql/2024-07/objects/Return): Return The declined return. * [userErrors](/docs/api/admin-graphql/2024-07/objects/ReturnUserError): ReturnUserError! The list of errors that occurred from executing the mutation. ## Examples ### Cannot decline a return that has been refunded Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) { returnDeclineRequest(input: $input) { return { id status } userErrors { code field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Return/491427904\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Return/491427904\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Return/491427904\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Return/491427904\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n}" #### Graphql Input { "input": { "id": "gid://shopify/Return/491427904", "declineReason": "RETURN_PERIOD_ENDED" } } #### Graphql Response { "data": { "returnDeclineRequest": { "return": null, "userErrors": [ { "code": "INVALID_STATE", "field": [ "input", "id" ], "message": "Return is not declinable. Only non-refunded returns with status REQUESTED can be declined." } ] } } } ### Cannot decline a return with an invalid status Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) { returnDeclineRequest(input: $input) { return { id status } userErrors { code field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000954\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000954\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000954\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000954\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n }\n userErrors {\n code\n field\n message\n }\n }\n}" #### Graphql Input { "input": { "id": "gid://shopify/Return/945000954", "declineReason": "RETURN_PERIOD_ENDED" } } #### Graphql Response { "data": { "returnDeclineRequest": { "return": null, "userErrors": [ { "code": "INVALID_STATE", "field": [ "input", "id" ], "message": "Return is not declinable. Only non-refunded returns with status REQUESTED can be declined." } ] } } } ### Decline a return Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) { returnDeclineRequest(input: $input) { return { id status decline { reason } returnLineItems(first: 1) { edges { node { id } } } order { id } } userErrors { code field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000960\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n decline {\n reason\n }\n returnLineItems(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n order {\n id\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000960\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n decline {\n reason\n }\n returnLineItems(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n order {\n id\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000960\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n decline {\n reason\n }\n returnLineItems(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n order {\n id\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Return/945000960\",\n \"declineReason\": \"RETURN_PERIOD_ENDED\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {\n returnDeclineRequest(input: $input) {\n return {\n id\n status\n decline {\n reason\n }\n returnLineItems(first: 1) {\n edges {\n node {\n id\n }\n }\n }\n order {\n id\n }\n }\n userErrors {\n code\n field\n message\n }\n }\n}" #### Graphql Input { "input": { "id": "gid://shopify/Return/945000960", "declineReason": "RETURN_PERIOD_ENDED" } } #### Graphql Response { "data": { "returnDeclineRequest": { "return": { "id": "gid://shopify/Return/945000960", "status": "DECLINED", "decline": { "reason": "RETURN_PERIOD_ENDED" }, "returnLineItems": { "edges": [ { "node": { "id": "gid://shopify/ReturnLineItem/677614677" } } ] }, "order": { "id": "gid://shopify/Order/625362839" } }, "userErrors": [] } } }