Skip to content

locationConnectToFulfillmentService ​

Required scope: edit_locations

Connects a location to a fulfillment service, changing its type to WAREHOUSE. Once connected, the fulfillment service handles stock and order fulfillment for that location.

This page also covers locationDisconnectToFulfillmentService — which removes the connection and reverts the location to type INTERNAL.


locationConnectToFulfillmentService ​

Mutation ​

graphql
mutation LocationConnectToFulfillmentService($input: LocationConnectToFulfillmentServiceInput!) {
  locationConnectToFulfillmentService(input: $input) {
    id
    locationType
    integration {
      id
      state
      fulfillmentService {
        id
        name
      }
    }
  }
}

Input: LocationConnectToFulfillmentServiceInput ​

FieldTypeRequiredDescription
idStringYesLocation UUID to connect
fulfillmentServiceIdStringYesUUID of the fulfillment service to connect to
acceptFulfillmentAtDateTimeNoISO 8601 datetime at which the fulfillment service should start accepting orders. Defaults to immediately.

Example Variables ​

json
{
  "input": {
    "id": "loc_123",
    "fulfillmentServiceId": "fs_456",
    "acceptFulfillmentAt": "2026-04-01T00:00:00Z"
  }
}

Example Response ​

json
{
  "data": {
    "locationConnectToFulfillmentService": {
      "id": "loc_123",
      "locationType": "WAREHOUSE",
      "integration": {
        "id": "int_789",
        "state": "PENDING",
        "fulfillmentService": {
          "id": "fs_456",
          "name": "Acme Fulfillment"
        }
      }
    }
  }
}

The integration starts in PENDING state. It transitions to ACTIVE once the fulfillment service confirms the connection. See Integration States for the full lifecycle.


locationDisconnectToFulfillmentService ​

Removes the connection between a location and its fulfillment service. The location type reverts to INTERNAL and the integration field becomes null.

Mutation ​

graphql
mutation LocationDisconnectToFulfillmentService($id: String!) {
  locationDisconnectToFulfillmentService(id: $id) {
    id
    locationType
  }
}

Arguments ​

ArgumentTypeRequiredDescription
idStringYesLocation UUID to disconnect

Example Variables ​

json
{
  "id": "loc_123"
}

Example Response ​

json
{
  "data": {
    "locationDisconnectToFulfillmentService": {
      "id": "loc_123",
      "locationType": "INTERNAL"
    }
  }
}

Code Examples ​

bash
# Connect
curl -X POST https://api-v3.happycolis.com/graphql \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation LocationConnectToFulfillmentService($input: LocationConnectToFulfillmentServiceInput!) { locationConnectToFulfillmentService(input: $input) { id locationType integration { id state fulfillmentService { id name } } } }",
    "variables": {
      "input": {
        "id": "loc_123",
        "fulfillmentServiceId": "fs_456",
        "acceptFulfillmentAt": "2026-04-01T00:00:00Z"
      }
    }
  }'

# Disconnect
curl -X POST https://api-v3.happycolis.com/graphql \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation LocationDisconnectToFulfillmentService($id: String!) { locationDisconnectToFulfillmentService(id: $id) { id locationType } }",
    "variables": {
      "id": "loc_123"
    }
  }'
js
async function connectToFulfillmentService(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 LocationConnectToFulfillmentService($input: LocationConnectToFulfillmentServiceInput!) {
          locationConnectToFulfillmentService(input: $input) {
            id
            locationType
            integration {
              id
              state
              fulfillmentService {
                id
                name
              }
            }
          }
        }
      `,
      variables: { input },
    }),
  });

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

async function disconnectFromFulfillmentService(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 LocationDisconnectToFulfillmentService($id: String!) {
          locationDisconnectToFulfillmentService(id: $id) {
            id
            locationType
          }
        }
      `,
      variables: { id: locationId },
    }),
  });

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

// Usage
const connected = await connectToFulfillmentService(accessToken, {
  id: 'loc_123',
  fulfillmentServiceId: 'fs_456',
  acceptFulfillmentAt: '2026-04-01T00:00:00Z',
});

const disconnected = await disconnectFromFulfillmentService(accessToken, 'loc_123');
python
import requests

def connect_to_fulfillment_service(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 LocationConnectToFulfillmentService($input: LocationConnectToFulfillmentServiceInput!) {
                    locationConnectToFulfillmentService(input: $input) {
                        id
                        locationType
                        integration {
                            id
                            state
                            fulfillmentService {
                                id
                                name
                            }
                        }
                    }
                }
            ''',
            'variables': {'input': input_data},
        },
    )
    result = response.json()
    if 'errors' in result:
        raise Exception(result['errors'][0]['message'])
    return result['data']['locationConnectToFulfillmentService']

def disconnect_from_fulfillment_service(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 LocationDisconnectToFulfillmentService($id: String!) {
                    locationDisconnectToFulfillmentService(id: $id) {
                        id
                        locationType
                    }
                }
            ''',
            'variables': {'id': location_id},
        },
    )
    result = response.json()
    if 'errors' in result:
        raise Exception(result['errors'][0]['message'])
    return result['data']['locationDisconnectToFulfillmentService']

# Usage
connected = connect_to_fulfillment_service(access_token, {
    'id': 'loc_123',
    'fulfillmentServiceId': 'fs_456',
    'acceptFulfillmentAt': '2026-04-01T00:00:00Z',
})

disconnected = disconnect_from_fulfillment_service(access_token, 'loc_123')
php
function connectToFulfillmentService(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 LocationConnectToFulfillmentService($input: LocationConnectToFulfillmentServiceInput!) {
                    locationConnectToFulfillmentService(input: $input) {
                        id
                        locationType
                        integration {
                            id
                            state
                            fulfillmentService {
                                id
                                name
                            }
                        }
                    }
                }
            ',
            'variables' => ['input' => $input],
        ],
    ]);

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

function disconnectFromFulfillmentService(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 LocationDisconnectToFulfillmentService($id: String!) {
                    locationDisconnectToFulfillmentService(id: $id) {
                        id
                        locationType
                    }
                }
            ',
            'variables' => ['id' => $locationId],
        ],
    ]);

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

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

type ConnectInput struct {
    ID                   string     `json:"id"`
    FulfillmentServiceID string     `json:"fulfillmentServiceId"`
    AcceptFulfillmentAt  *time.Time `json:"acceptFulfillmentAt,omitempty"`
}

func connectToFulfillmentService(accessToken string, input ConnectInput) (map[string]interface{}, error) {
    body, _ := json.Marshal(map[string]interface{}{
        "query": `
            mutation LocationConnectToFulfillmentService($input: LocationConnectToFulfillmentServiceInput!) {
                locationConnectToFulfillmentService(input: $input) {
                    id
                    locationType
                    integration {
                        id
                        state
                        fulfillmentService {
                            id
                            name
                        }
                    }
                }
            }
        `,
        "variables": map[string]interface{}{"input": input},
    })

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

func disconnectFromFulfillmentService(accessToken, locationID string) (map[string]interface{}, error) {
    body, _ := json.Marshal(map[string]interface{}{
        "query": `
            mutation LocationDisconnectToFulfillmentService($id: String!) {
                locationDisconnectToFulfillmentService(id: $id) {
                    id
                    locationType
                }
            }
        `,
        "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["locationDisconnectToFulfillmentService"].(map[string]interface{}), nil
}

HappyColis API Documentation