location Deactivatemutation
mutation
2024-10latest
Requires write
access scope.
Deactivates a location and moves inventory, pending orders, and moving transfers to a destination location.
Arguments
Anchor to destinationLocationIddestinationLocationIdThe ID of a destination location to which inventory, pending orders and moving transfers will be moved from the location to deactivate.
The ID of a location to deactivate.
Was this section helpful?
LocationDeactivatePayload returns
The location that was deactivated.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: locationDeactivate
Query Reference for MUTATION: locationDeactivate
"mutation locationDeactivate($locationId: ID!) {\n locationDeactivate(locationId: $locationId) {\n location {\n # Location fields\n }\n locationDeactivateUserErrors {\n # LocationDeactivateUserError fields\n }\n }\n}"
Input Reference for MUTATION: locationDeactivate
"{\n \"destinationLocationId\": \"gid://shopify/<objectName>/10079785100\",\n \"locationId\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: locationDeactivate
""
Display Examples for MUTATION: locationDeactivate
[ { "example": { "type_name": "locationdeactivate", "title": "Deactivate a location with active inventory", "description": "Deactivating a location with inventory without specifying a destination location returns an error.", "query_string": "mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n}", "query_arguments": { "locationId": "gid://shopify/Location/922479430" }, "response": { "data": { "locationDeactivate": { "location": { "id": "gid://shopify/Location/922479430", "isActive": true }, "locationDeactivateUserErrors": [ { "message": "Location could not be deactivated without specifying where to relocate inventory stocked at the location.", "code": "HAS_ACTIVE_INVENTORY_ERROR", "field": [ "locationId" ] } ] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/shop_identity/test/unit/graph_api/admin/mutations/location_deactivate_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation locationDeactivate { locationDeactivate(locationId: \\\"gid://shopify/Location/922479430\\\") { location { id isActive } locationDeactivateUserErrors { message code field } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }`,\n);\n\nconst data = await response.json();\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 locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] }, { "example": { "type_name": "locationdeactivate", "title": "Deactivate a location with pending orders", "description": "Deactivating a location with pending orders without specifying a destination location returns an error", "query_string": "mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/123\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n}", "query_arguments": { "locationId": "gid://shopify/Location/123" }, "response": { "data": { "locationDeactivate": { "location": null, "locationDeactivateUserErrors": [ { "message": "Location could not be deactivated because it has open purchase orders.", "code": "HAS_OPEN_PURCHASE_ORDERS_ERROR", "field": [ "locationId" ] } ] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/shop_identity/test/unit/graph_api/admin/mutations/location_deactivate_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation locationDeactivate { locationDeactivate(locationId: \\\"gid://shopify/Location/123\\\") { location { id isActive } locationDeactivateUserErrors { message code field } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/123\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }`,\n);\n\nconst data = await response.json();\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 locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/123\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/123\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation locationDeactivate {\n locationDeactivate(locationId: \"gid://shopify/Location/123\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] }, { "example": { "type_name": "locationdeactivate", "title": "Deactivate an active location", "description": "Deactivates a location and transfers inventory, pending orders, and transfers to another location", "query_string": "mutation {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\", destinationLocationId: \"gid://shopify/Location/147921425\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n}", "query_arguments": { "locationId": "gid://shopify/Location/922479430", "destinationLocationId": "gid://shopify/Location/147921425" }, "response": { "data": { "locationDeactivate": { "location": { "id": "gid://shopify/Location/922479430", "isActive": false }, "locationDeactivateUserErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/shop_identity/test/unit/graph_api/admin/mutations/location_deactivate_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation { locationDeactivate(locationId: \\\"gid://shopify/Location/922479430\\\", destinationLocationId: \\\"gid://shopify/Location/147921425\\\") { location { id isActive } locationDeactivateUserErrors { message code field } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\", destinationLocationId: \"gid://shopify/Location/147921425\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }`,\n);\n\nconst data = await response.json();\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 {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\", destinationLocationId: \"gid://shopify/Location/147921425\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\", destinationLocationId: \"gid://shopify/Location/147921425\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation {\n locationDeactivate(locationId: \"gid://shopify/Location/922479430\", destinationLocationId: \"gid://shopify/Location/147921425\") {\n location {\n id\n isActive\n }\n locationDeactivateUserErrors {\n message\n code\n field\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [] } ]