deliveryOrderCreate
Required scope: create_delivery_orders
Manually creates a delivery order for a specific fulfillment location. This mutation is used when the dispatching strategy is set to MANUAL — the platform will not automatically split the parent order into delivery orders in this case.
Mutation
graphql
mutation DeliveryOrderCreate($input: DeliveryOrderInput!) {
deliveryOrderCreate(input: $input) {
id
orderNumber
status
}
}Input: DeliveryOrderInput
| Field | Type | Required | Description |
|---|---|---|---|
orderId | String | Yes | UUID of the parent order |
locationId | String | Yes | UUID of the fulfillment location |
lines | [DeliveryOrderLineInput!] | Yes | Lines to include in the delivery order |
priority | PriorityEnum | No | Fulfillment priority: LOW, NORMAL, or HIGH. Defaults to NORMAL. |
DeliveryOrderLineInput
| Field | Type | Required | Description |
|---|---|---|---|
orderLineId | String | Yes | UUID of the parent order line to fulfil |
quantity | Int | Yes | Number of units to include in this delivery order |
Example
Variables
json
{
"input": {
"orderId": "ord_xyz789",
"locationId": "loc_123",
"priority": "HIGH",
"lines": [
{
"orderLineId": "ol_001",
"quantity": 2
},
{
"orderLineId": "ol_002",
"quantity": 1
}
]
}
}Response
json
{
"data": {
"deliveryOrderCreate": {
"id": "do_abc123",
"orderNumber": "DO-2024-00042",
"status": "DRAFT"
}
}
}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 DeliveryOrderCreate($input: DeliveryOrderInput!) { deliveryOrderCreate(input: $input) { id orderNumber status } }",
"variables": {
"input": {
"orderId": "ord_xyz789",
"locationId": "loc_123",
"priority": "HIGH",
"lines": [
{ "orderLineId": "ol_001", "quantity": 2 },
{ "orderLineId": "ol_002", "quantity": 1 }
]
}
}
}'js
async function createDeliveryOrder(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 DeliveryOrderCreate($input: DeliveryOrderInput!) {
deliveryOrderCreate(input: $input) {
id
orderNumber
status
}
}
`,
variables: { input },
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
return data.deliveryOrderCreate;
}
// Usage
const deliveryOrder = await createDeliveryOrder(accessToken, {
orderId: 'ord_xyz789',
locationId: 'loc_123',
priority: 'HIGH',
lines: [
{ orderLineId: 'ol_001', quantity: 2 },
{ orderLineId: 'ol_002', quantity: 1 },
],
});python
import requests
def create_delivery_order(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 DeliveryOrderCreate($input: DeliveryOrderInput!) {
deliveryOrderCreate(input: $input) {
id
orderNumber
status
}
}
''',
'variables': {'input': input_data},
},
)
result = response.json()
if 'errors' in result:
raise Exception(result['errors'][0]['message'])
return result['data']['deliveryOrderCreate']
# Usage
delivery_order = create_delivery_order(access_token, {
'orderId': 'ord_xyz789',
'locationId': 'loc_123',
'priority': 'HIGH',
'lines': [
{'orderLineId': 'ol_001', 'quantity': 2},
{'orderLineId': 'ol_002', 'quantity': 1},
],
})php
function createDeliveryOrder(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 DeliveryOrderCreate($input: DeliveryOrderInput!) {
deliveryOrderCreate(input: $input) {
id
orderNumber
status
}
}
',
'variables' => ['input' => $input],
],
]);
$result = json_decode($response->getBody()->getContents(), true);
if (isset($result['errors'])) {
throw new \Exception($result['errors'][0]['message']);
}
return $result['data']['deliveryOrderCreate'];
}
// Usage
$deliveryOrder = createDeliveryOrder($accessToken, [
'orderId' => 'ord_xyz789',
'locationId' => 'loc_123',
'priority' => 'HIGH',
'lines' => [
['orderLineId' => 'ol_001', 'quantity' => 2],
['orderLineId' => 'ol_002', 'quantity' => 1],
],
]);go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type DeliveryOrderLineInput struct {
OrderLineID string `json:"orderLineId"`
Quantity int `json:"quantity"`
}
type DeliveryOrderInput struct {
OrderID string `json:"orderId"`
LocationID string `json:"locationId"`
Priority *string `json:"priority,omitempty"`
Lines []DeliveryOrderLineInput `json:"lines"`
}
func createDeliveryOrder(accessToken string, input DeliveryOrderInput) (map[string]interface{}, error) {
query := `
mutation DeliveryOrderCreate($input: DeliveryOrderInput!) {
deliveryOrderCreate(input: $input) {
id
orderNumber
status
}
}
`
body, _ := json.Marshal(map[string]interface{}{
"query": query,
"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["deliveryOrderCreate"].(map[string]interface{}), nil
}