Skip to content

deliveryOrder

Required scope: view_delivery_orders

Retrieve a single delivery order by its ID. Returns the full delivery order including its lines, fulfillment event history, linked orders, and shipments.


Query

graphql
query GetDeliveryOrder($id: String!) {
  deliveryOrder(id: $id) {
    id
    orderNumber
    invoiceNumber
    status
    type
    priority
    total
    currency
    location {
      id
      name
    }
    deliveryAddress {
      fullname
      address
      city
      zipcode
      country
    }
    lines {
      id
      sku
      label
      quantity
      fulfilledQuantity
      status
    }
    orders {
      id
    }
    fulfillmentData {
      events {
        type
        level
        message
        date
      }
    }
  }
}

Arguments

ArgumentTypeRequiredDescription
idString!YesUUID of the delivery order to retrieve

Example

Variables

json
{
  "id": "do_abc123"
}

Response

json
{
  "data": {
    "deliveryOrder": {
      "id": "do_abc123",
      "orderNumber": "DO-2024-00042",
      "invoiceNumber": "INV-2024-00042",
      "status": "OPENED",
      "type": "WAREHOUSE",
      "priority": "NORMAL",
      "total": 149.99,
      "currency": "EUR",
      "location": {
        "id": "loc_123",
        "name": "paris-warehouse"
      },
      "deliveryAddress": {
        "fullname": "Alice Dupont",
        "address": "12 Rue de Rivoli",
        "city": "Paris",
        "zipcode": "75001",
        "country": "FR"
      },
      "lines": [
        {
          "id": "dol_001",
          "sku": "TSHIRT-M-BLUE",
          "label": "Blue T-Shirt (M)",
          "quantity": 2,
          "fulfilledQuantity": 0,
          "status": "ACCEPTED"
        }
      ],
      "orders": [
        { "id": "ord_xyz789" }
      ],
      "fulfillmentData": {
        "events": [
          {
            "type": "FULFILLMENT_REQUESTED",
            "level": "NORMAL",
            "message": null,
            "date": "2024-06-01T10:00:00.000Z"
          },
          {
            "type": "FULFILLMENT_ACCEPTED",
            "level": "NORMAL",
            "message": null,
            "date": "2024-06-01T10:05:00.000Z"
          }
        ]
      }
    }
  }
}

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 GetDeliveryOrder($id: String!) { deliveryOrder(id: $id) { id orderNumber invoiceNumber status type priority total currency location { id name } deliveryAddress { fullname address city zipcode country } lines { id sku label quantity fulfilledQuantity status } orders { id } fulfillmentData { events { type level message date } } } }",
    "variables": {
      "id": "do_abc123"
    }
  }'
js
async function getDeliveryOrder(accessToken, id) {
  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 GetDeliveryOrder($id: String!) {
          deliveryOrder(id: $id) {
            id
            orderNumber
            invoiceNumber
            status
            type
            priority
            total
            currency
            location { id name }
            deliveryAddress {
              fullname
              address
              city
              zipcode
              country
            }
            lines {
              id
              sku
              label
              quantity
              fulfilledQuantity
              status
            }
            orders { id }
            fulfillmentData {
              events {
                type
                level
                message
                date
              }
            }
          }
        }
      `,
      variables: { id },
    }),
  });

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

// Usage
const deliveryOrder = await getDeliveryOrder(accessToken, 'do_abc123');
python
import requests

def get_delivery_order(access_token, delivery_order_id):
    response = requests.post(
        'https://api-v3.happycolis.com/graphql',
        headers={
            'Authorization': f'Bearer {access_token}',
            'Content-Type': 'application/json',
        },
        json={
            'query': '''
                query GetDeliveryOrder($id: String!) {
                    deliveryOrder(id: $id) {
                        id
                        orderNumber
                        invoiceNumber
                        status
                        type
                        priority
                        total
                        currency
                        location { id name }
                        deliveryAddress {
                            fullname
                            address
                            city
                            zipcode
                            country
                        }
                        lines {
                            id
                            sku
                            label
                            quantity
                            fulfilledQuantity
                            status
                        }
                        orders { id }
                        fulfillmentData {
                            events {
                                type
                                level
                                message
                                date
                            }
                        }
                    }
                }
            ''',
            'variables': {'id': delivery_order_id},
        },
    )
    result = response.json()
    if 'errors' in result:
        raise Exception(result['errors'][0]['message'])
    return result['data']['deliveryOrder']

# Usage
delivery_order = get_delivery_order(access_token, 'do_abc123')
php
function getDeliveryOrder(string $accessToken, string $id): 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 GetDeliveryOrder($id: String!) {
                    deliveryOrder(id: $id) {
                        id
                        orderNumber
                        invoiceNumber
                        status
                        type
                        priority
                        total
                        currency
                        location { id name }
                        deliveryAddress {
                            fullname
                            address
                            city
                            zipcode
                            country
                        }
                        lines {
                            id
                            sku
                            label
                            quantity
                            fulfilledQuantity
                            status
                        }
                        orders { id }
                        fulfillmentData {
                            events {
                                type
                                level
                                message
                                date
                            }
                        }
                    }
                }
            ',
            'variables' => ['id' => $id],
        ],
    ]);

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

// Usage
$deliveryOrder = getDeliveryOrder($accessToken, 'do_abc123');
go
package main

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

func getDeliveryOrder(accessToken string, id string) (map[string]interface{}, error) {
    query := `
        query GetDeliveryOrder($id: String!) {
            deliveryOrder(id: $id) {
                id
                orderNumber
                invoiceNumber
                status
                type
                priority
                total
                currency
                location { id name }
                deliveryAddress {
                    fullname
                    address
                    city
                    zipcode
                    country
                }
                lines {
                    id
                    sku
                    label
                    quantity
                    fulfilledQuantity
                    status
                }
                orders { id }
                fulfillmentData {
                    events {
                        type
                        level
                        message
                        date
                    }
                }
            }
        }
    `

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

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

HappyColis API Documentation