Anchor to section titled 'undefined'

returnDeclineRequest
mutation

Requires write_returns access scope or write_marketplace_returns access scope. Also: Requires the write_orders access scope. The user must have return_orders permission.

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.


The input fields for declining a customer's return request.


Was this section helpful?

The declined return.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {
  returnDeclineRequest(input: $input) {
    return {
      id
      status
    }
    userErrors {
      code
      field
      message
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) { returnDeclineRequest(input: $input) { return { id status } userErrors { code field message } } }",
 "variables": {
    "input": {
      "id": "gid://shopify/Return/491427904",
      "declineReason": "RETURN_PERIOD_ENDED"
    }
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {
    returnDeclineRequest(input: $input) {
      return {
        id
        status
      }
      userErrors {
        code
        field
        message
      }
    }
  }`,
  {
    variables: {
      "input": {
        "id": "gid://shopify/Return/491427904",
        "declineReason": "RETURN_PERIOD_ENDED"
      }
    },
  },
);

const data = await response.json();
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 ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {
    returnDeclineRequest(input: $input) {
      return {
        id
        status
      }
      userErrors {
        code
        field
        message
      }
    }
  }
QUERY

variables = {
  "input": {
    "id": "gid://shopify/Return/491427904",
    "declineReason": "RETURN_PERIOD_ENDED"
  }
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {
      returnDeclineRequest(input: $input) {
        return {
          id
          status
        }
        userErrors {
          code
          field
          message
        }
      }
    }`,
    "variables": {
      "input": {
        "id": "gid://shopify/Return/491427904",
        "declineReason": "RETURN_PERIOD_ENDED"
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation ReturnDeclineRequest($input: ReturnDeclineRequestInput!) {
    returnDeclineRequest(input: $input) {
      return {
        id
        status
      }
      userErrors {
        code
        field
        message
      }
    }
  }
QUERY;

$variables = [
  "input" => [
    "id" => "gid://shopify/Return/491427904",
    "declineReason" => "RETURN_PERIOD_ENDED",
  ],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "input": {
    "id": "gid://shopify/Return/491427904",
    "declineReason": "RETURN_PERIOD_ENDED"
  }
}
Hide code
Response
JSON
{
  "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."
      }
    ]
  }
}