locationDeactivate
Required scope: edit_locations
Sets a location to inactive. Inactive locations do not receive new orders and are hidden from fulfillment routing.
Before deactivating
Transfer any remaining stock and reassign open orders to another active location before deactivating. Orders and stock movements targeting an inactive location may fail or be blocked.
Mutation
graphql
mutation LocationDeactivate($id: String!) {
locationDeactivate(id: $id) {
id
active
}
}Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | String | Yes | UUID of the location to deactivate |
Example
Variables
json
{
"id": "loc_123"
}Response
json
{
"data": {
"locationDeactivate": {
"id": "loc_123",
"active": false
}
}
}Code Examples
bash
curl -X POST https://api-v3.happycolis.com/graphql \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation LocationDeactivate($id: String!) { locationDeactivate(id: $id) { id active } }",
"variables": {
"id": "loc_123"
}
}'js
async function deactivateLocation(accessToken, locationId) {
const response = await fetch('https://api-v3.happycolis.com/graphql', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
mutation LocationDeactivate($id: String!) {
locationDeactivate(id: $id) {
id
active
}
}
`,
variables: { id: locationId },
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
return data.locationDeactivate;
}
// Usage
const location = await deactivateLocation(accessToken, 'loc_123');
console.log(location.active); // falsepython
import requests
def deactivate_location(access_token, location_id):
response = requests.post(
'https://api-v3.happycolis.com/graphql',
headers={
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json',
},
json={
'query': '''
mutation LocationDeactivate($id: String!) {
locationDeactivate(id: $id) {
id
active
}
}
''',
'variables': {'id': location_id},
},
)
result = response.json()
if 'errors' in result:
raise Exception(result['errors'][0]['message'])
return result['data']['locationDeactivate']
# Usage
location = deactivate_location(access_token, 'loc_123')
print(location['active']) # Falsephp
function deactivateLocation(string $accessToken, string $locationId): array
{
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api-v3.happycolis.com/graphql', [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json',
],
'json' => [
'query' => '
mutation LocationDeactivate($id: String!) {
locationDeactivate(id: $id) {
id
active
}
}
',
'variables' => ['id' => $locationId],
],
]);
$result = json_decode($response->getBody()->getContents(), true);
if (isset($result['errors'])) {
throw new \Exception($result['errors'][0]['message']);
}
return $result['data']['locationDeactivate'];
}go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func deactivateLocation(accessToken, locationID string) (map[string]interface{}, error) {
body, _ := json.Marshal(map[string]interface{}{
"query": `
mutation LocationDeactivate($id: String!) {
locationDeactivate(id: $id) {
id
active
}
}
`,
"variables": map[string]string{"id": locationID},
})
req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+accessToken)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
if errs, ok := result["errors"]; ok {
return nil, fmt.Errorf("graphql error: %v", errs)
}
data := result["data"].(map[string]interface{})
return data["locationDeactivate"].(map[string]interface{}), nil
}