locationActivate
Required scope: edit_locations
Sets a location to active. Once active, the location can receive stock and fulfill orders.
Mutation
graphql
mutation LocationActivate($id: String!) {
locationActivate(id: $id) {
id
active
}
}Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | String | Yes | UUID of the location to activate |
Example
Variables
json
{
"id": "loc_123"
}Response
json
{
"data": {
"locationActivate": {
"id": "loc_123",
"active": true
}
}
}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 LocationActivate($id: String!) { locationActivate(id: $id) { id active } }",
"variables": {
"id": "loc_123"
}
}'js
async function activateLocation(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 LocationActivate($id: String!) {
locationActivate(id: $id) {
id
active
}
}
`,
variables: { id: locationId },
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
return data.locationActivate;
}
// Usage
const location = await activateLocation(accessToken, 'loc_123');
console.log(location.active); // truepython
import requests
def activate_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 LocationActivate($id: String!) {
locationActivate(id: $id) {
id
active
}
}
''',
'variables': {'id': location_id},
},
)
result = response.json()
if 'errors' in result:
raise Exception(result['errors'][0]['message'])
return result['data']['locationActivate']
# Usage
location = activate_location(access_token, 'loc_123')
print(location['active']) # Truephp
function activateLocation(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 LocationActivate($id: String!) {
locationActivate(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']['locationActivate'];
}go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func activateLocation(accessToken, locationID string) (map[string]interface{}, error) {
body, _ := json.Marshal(map[string]interface{}{
"query": `
mutation LocationActivate($id: String!) {
locationActivate(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["locationActivate"].(map[string]interface{}), nil
}