Skip to content

locationUpdate

Required scope: edit_locations

This page covers two update mutations for locations:


locationUpdate

Update the core fields of an existing location.

Mutation

graphql
mutation LocationUpdate($input: LocationUpdateInput!) {
  locationUpdate(input: $input) {
    id
    name
    title
    description
  }
}

Input: LocationUpdateInput

FieldTypeRequiredDescription
idStringYesLocation UUID to update
nameStringNoNew slug name. Must remain unique within the organization.
titleStringNoNew display name
descriptionStringNoNew description
socialReasonStringNoLegal company name
addressStringNoStreet address line 1
addressComplementStringNoStreet address line 2
zipCodeStringNoZip or postal code
cityStringNoCity
countryStringNoISO 3166-1 alpha-2 country code
phoneStringNoContact phone number
emailStringNoContact email address

Example Variables

json
{
  "input": {
    "id": "loc_123",
    "title": "Paris Warehouse — Updated",
    "description": "Relocated to a new building in Q2",
    "address": "456 Avenue de la République",
    "zipCode": "75011",
    "city": "Paris",
    "country": "FR"
  }
}

Example Response

json
{
  "data": {
    "locationUpdate": {
      "id": "loc_123",
      "name": "paris-warehouse",
      "title": "Paris Warehouse — Updated",
      "description": "Relocated to a new building in Q2"
    }
  }
}

locationFulfillmentConfigUpdate

Configure the country restrictions, preparation delay, and inventory policy for a location.

Mutation

graphql
mutation LocationFulfillmentConfigUpdate($input: LocationFulfillmentConfigUpdateInput!) {
  locationFulfillmentConfigUpdate(input: $input) {
    id
    fulfillmentConfig {
      allowedCountries
      excludedCountries
      preparationDelay
      inventoryPolicy
    }
  }
}

Input: LocationFulfillmentConfigUpdateInput

FieldTypeRequiredDescription
idStringYesLocation UUID to update
allowedCountries[String!]NoISO country codes this location may ship to. Pass an empty array to remove all restrictions.
excludedCountries[String!]NoISO country codes this location must never ship to. Takes priority over allowedCountries.
preparationDelayIntNoNumber of business days for order preparation
inventoryPolicyInventoryPolicyEnumNoDENY to block orders when stock is insufficient, CONTINUE to allow overselling

Example Variables

json
{
  "input": {
    "id": "loc_123",
    "allowedCountries": ["FR", "BE", "CH", "DE"],
    "excludedCountries": ["IT"],
    "preparationDelay": 2,
    "inventoryPolicy": "DENY"
  }
}

Example Response

json
{
  "data": {
    "locationFulfillmentConfigUpdate": {
      "id": "loc_123",
      "fulfillmentConfig": {
        "allowedCountries": ["FR", "BE", "CH", "DE"],
        "excludedCountries": ["IT"],
        "preparationDelay": 2,
        "inventoryPolicy": "DENY"
      }
    }
  }
}

Code Examples

The examples below demonstrate locationUpdate. Swap the query and variables to use locationFulfillmentConfigUpdate.

bash
# locationUpdate
curl -X POST https://api-v3.happycolis.com/graphql \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation LocationUpdate($input: LocationUpdateInput!) { locationUpdate(input: $input) { id name title description } }",
    "variables": {
      "input": {
        "id": "loc_123",
        "title": "Paris Warehouse — Updated",
        "address": "456 Avenue de la République",
        "zipCode": "75011",
        "city": "Paris",
        "country": "FR"
      }
    }
  }'

# locationFulfillmentConfigUpdate
curl -X POST https://api-v3.happycolis.com/graphql \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation LocationFulfillmentConfigUpdate($input: LocationFulfillmentConfigUpdateInput!) { locationFulfillmentConfigUpdate(input: $input) { id fulfillmentConfig { allowedCountries excludedCountries preparationDelay inventoryPolicy } } }",
    "variables": {
      "input": {
        "id": "loc_123",
        "allowedCountries": ["FR", "BE", "CH", "DE"],
        "excludedCountries": ["IT"]
      }
    }
  }'
js
async function updateLocation(accessToken, input) {
  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 LocationUpdate($input: LocationUpdateInput!) {
          locationUpdate(input: $input) {
            id
            name
            title
            description
          }
        }
      `,
      variables: { input },
    }),
  });

  const { data, errors } = await response.json();
  if (errors) throw new Error(errors[0].message);
  return data.locationUpdate;
}

async function updateFulfillmentConfig(accessToken, input) {
  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 LocationFulfillmentConfigUpdate($input: LocationFulfillmentConfigUpdateInput!) {
          locationFulfillmentConfigUpdate(input: $input) {
            id
            fulfillmentConfig {
              allowedCountries
              excludedCountries
              preparationDelay
              inventoryPolicy
            }
          }
        }
      `,
      variables: { input },
    }),
  });

  const { data, errors } = await response.json();
  if (errors) throw new Error(errors[0].message);
  return data.locationFulfillmentConfigUpdate;
}

// Usage
await updateLocation(accessToken, {
  id: 'loc_123',
  title: 'Paris Warehouse — Updated',
  address: '456 Avenue de la République',
  zipCode: '75011',
  city: 'Paris',
  country: 'FR',
});

await updateFulfillmentConfig(accessToken, {
  id: 'loc_123',
  allowedCountries: ['FR', 'BE', 'CH', 'DE'],
  excludedCountries: ['IT'],
});
python
import requests

def update_location(access_token, input_data):
    response = requests.post(
        'https://api-v3.happycolis.com/graphql',
        headers={
            'Authorization': f'Bearer {access_token}',
            'Content-Type': 'application/json',
        },
        json={
            'query': '''
                mutation LocationUpdate($input: LocationUpdateInput!) {
                    locationUpdate(input: $input) {
                        id
                        name
                        title
                        description
                    }
                }
            ''',
            'variables': {'input': input_data},
        },
    )
    result = response.json()
    if 'errors' in result:
        raise Exception(result['errors'][0]['message'])
    return result['data']['locationUpdate']

def update_fulfillment_config(access_token, input_data):
    response = requests.post(
        'https://api-v3.happycolis.com/graphql',
        headers={
            'Authorization': f'Bearer {access_token}',
            'Content-Type': 'application/json',
        },
        json={
            'query': '''
                mutation LocationFulfillmentConfigUpdate($input: LocationFulfillmentConfigUpdateInput!) {
                    locationFulfillmentConfigUpdate(input: $input) {
                        id
                        fulfillmentConfig {
                            allowedCountries
                            excludedCountries
                            preparationDelay
                            inventoryPolicy
                        }
                    }
                }
            ''',
            'variables': {'input': input_data},
        },
    )
    result = response.json()
    if 'errors' in result:
        raise Exception(result['errors'][0]['message'])
    return result['data']['locationFulfillmentConfigUpdate']

# Usage
update_location(access_token, {
    'id': 'loc_123',
    'title': 'Paris Warehouse — Updated',
})

update_fulfillment_config(access_token, {
    'id': 'loc_123',
    'allowedCountries': ['FR', 'BE', 'CH', 'DE'],
    'excludedCountries': ['IT'],
})
php
function updateLocation(string $accessToken, array $input): 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 LocationUpdate($input: LocationUpdateInput!) {
                    locationUpdate(input: $input) {
                        id
                        name
                        title
                        description
                    }
                }
            ',
            'variables' => ['input' => $input],
        ],
    ]);

    $result = json_decode($response->getBody()->getContents(), true);
    if (isset($result['errors'])) {
        throw new \Exception($result['errors'][0]['message']);
    }
    return $result['data']['locationUpdate'];
}

function updateFulfillmentConfig(string $accessToken, array $input): 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 LocationFulfillmentConfigUpdate($input: LocationFulfillmentConfigUpdateInput!) {
                    locationFulfillmentConfigUpdate(input: $input) {
                        id
                        fulfillmentConfig {
                            allowedCountries
                            excludedCountries
                            preparationDelay
                            inventoryPolicy
                        }
                    }
                }
            ',
            'variables' => ['input' => $input],
        ],
    ]);

    $result = json_decode($response->getBody()->getContents(), true);
    if (isset($result['errors'])) {
        throw new \Exception($result['errors'][0]['message']);
    }
    return $result['data']['locationFulfillmentConfigUpdate'];
}
go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func graphqlPost(accessToken, query string, variables map[string]interface{}) (map[string]interface{}, error) {
    body, _ := json.Marshal(map[string]interface{}{
        "query":     query,
        "variables": variables,
    })

    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)
    }
    return result["data"].(map[string]interface{}), nil
}

func updateLocation(accessToken string, input map[string]interface{}) (map[string]interface{}, error) {
    data, err := graphqlPost(accessToken, `
        mutation LocationUpdate($input: LocationUpdateInput!) {
            locationUpdate(input: $input) {
                id
                name
                title
                description
            }
        }
    `, map[string]interface{}{"input": input})
    if err != nil {
        return nil, err
    }
    return data["locationUpdate"].(map[string]interface{}), nil
}

func updateFulfillmentConfig(accessToken string, input map[string]interface{}) (map[string]interface{}, error) {
    data, err := graphqlPost(accessToken, `
        mutation LocationFulfillmentConfigUpdate($input: LocationFulfillmentConfigUpdateInput!) {
            locationFulfillmentConfigUpdate(input: $input) {
                id
                fulfillmentConfig {
                    allowedCountries
                    excludedCountries
                    preparationDelay
                    inventoryPolicy
                }
            }
        }
    `, map[string]interface{}{"input": input})
    if err != nil {
        return nil, err
    }
    return data["locationFulfillmentConfigUpdate"].(map[string]interface{}), nil
}

HappyColis API Documentation