Skip to content

deliveryOrders

Required scope: view_delivery_orders

Retrieve all delivery orders associated with a given parent order. An order may be split into multiple delivery orders, one per fulfillment location.


Query

graphql
query GetDeliveryOrders($orderId: String!) {
  deliveryOrders(orderId: $orderId) {
    id
    orderNumber
    status
    location {
      id
      name
    }
    lines {
      sku
      quantity
      status
    }
  }
}

Arguments

ArgumentTypeRequiredDescription
orderIdString!YesUUID of the parent order whose delivery orders should be listed

Example

Variables

json
{
  "orderId": "ord_xyz789"
}

Response

json
{
  "data": {
    "deliveryOrders": [
      {
        "id": "do_abc123",
        "orderNumber": "DO-2024-00042",
        "status": "OPENED",
        "location": {
          "id": "loc_123",
          "name": "paris-warehouse"
        },
        "lines": [
          {
            "sku": "TSHIRT-M-BLUE",
            "quantity": 2,
            "status": "ACCEPTED"
          }
        ]
      },
      {
        "id": "do_def456",
        "orderNumber": "DO-2024-00043",
        "status": "PENDING",
        "location": {
          "id": "loc_456",
          "name": "lyon-warehouse"
        },
        "lines": [
          {
            "sku": "HOODIE-L-BLACK",
            "quantity": 1,
            "status": "PENDING"
          }
        ]
      }
    ]
  }
}

Code Examples

bash
curl -X POST https://api-v3.happycolis.com/graphql \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query GetDeliveryOrders($orderId: String!) { deliveryOrders(orderId: $orderId) { id orderNumber status location { id name } lines { sku quantity status } } }",
    "variables": {
      "orderId": "ord_xyz789"
    }
  }'
js
async function getDeliveryOrders(accessToken, orderId) {
  const response = await fetch('https://api-v3.happycolis.com/graphql', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      query: `
        query GetDeliveryOrders($orderId: String!) {
          deliveryOrders(orderId: $orderId) {
            id
            orderNumber
            status
            location { id name }
            lines {
              sku
              quantity
              status
            }
          }
        }
      `,
      variables: { orderId },
    }),
  });

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

// Usage
const deliveryOrders = await getDeliveryOrders(accessToken, 'ord_xyz789');
python
import requests

def get_delivery_orders(access_token, order_id):
    response = requests.post(
        'https://api-v3.happycolis.com/graphql',
        headers={
            'Authorization': f'Bearer {access_token}',
            'Content-Type': 'application/json',
        },
        json={
            'query': '''
                query GetDeliveryOrders($orderId: String!) {
                    deliveryOrders(orderId: $orderId) {
                        id
                        orderNumber
                        status
                        location { id name }
                        lines {
                            sku
                            quantity
                            status
                        }
                    }
                }
            ''',
            'variables': {'orderId': order_id},
        },
    )
    result = response.json()
    if 'errors' in result:
        raise Exception(result['errors'][0]['message'])
    return result['data']['deliveryOrders']

# Usage
delivery_orders = get_delivery_orders(access_token, 'ord_xyz789')
php
function getDeliveryOrders(string $accessToken, string $orderId): array
{
    $client = new \GuzzleHttp\Client();

    $response = $client->post('https://api-v3.happycolis.com/graphql', [
        'headers' => [
            'Authorization' => 'Bearer ' . $accessToken,
            'Content-Type'  => 'application/json',
        ],
        'json' => [
            'query' => '
                query GetDeliveryOrders($orderId: String!) {
                    deliveryOrders(orderId: $orderId) {
                        id
                        orderNumber
                        status
                        location { id name }
                        lines {
                            sku
                            quantity
                            status
                        }
                    }
                }
            ',
            'variables' => ['orderId' => $orderId],
        ],
    ]);

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

// Usage
$deliveryOrders = getDeliveryOrders($accessToken, 'ord_xyz789');
go
package main

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

func getDeliveryOrders(accessToken string, orderId string) ([]interface{}, error) {
    query := `
        query GetDeliveryOrders($orderId: String!) {
            deliveryOrders(orderId: $orderId) {
                id
                orderNumber
                status
                location { id name }
                lines {
                    sku
                    quantity
                    status
                }
            }
        }
    `

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

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

HappyColis API Documentation