Create & Close Order
API Overview
Creates a shipment order (CN38) from parcels you have already registered, groups them into bags/AKEs/pallets, and closes the order in the same call. Closing triggers generation of the shipment documents, which you then retrieve with Get Order File.
Every parcel referenced here must already exist, belong to your account, and not yet be part of another order.
Request Information
- Method: POST
- Path:
/api/order/create-order - Authentication: Bearer Token
Request Headers
| Field | Description |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Request Parameters
The request body is in JSON format and includes the following fields:
| Parameter | Type | Required | Description |
|---|---|---|---|
| ship_type | integer | Yes | Container type: 1 = Bag, 2 = AKE, 3 = Pallet. |
| ship_route | integer | Yes | Shipping route: 1 = Direct CN, 2 = Master2CN, 3 = Master2CN(T2T), 4 = Master2CN(OA), 5 = Transshipment CN, 6 = Transshipment CN(AF), 7 = Transshipment CN(VP). |
| is_ddp | string | No | Clearance mode: Y = DDP, N = DDU. Defaults to N. Must match the clearance mode of every parcel in the order. |
| destination | string | Yes | Destination country as a 2-letter code, e.g. SG for Singapore, TH for Thailand. Exactly 2 characters. |
| departure_port | string | Yes | Departure port code. Exactly 3 characters. |
| destination_port | string | Yes | Destination port code. Exactly 3 characters. |
| outbound_flight_no | string | Yes | Outbound flight number. Maximum 60 characters. |
| estimated_departure_datetime | string | Yes | Estimated local departure time at origin, as a 10-digit UNIX timestamp in seconds. |
| estimated_arrival_datetime | string | Yes | Estimated local arrival time at destination, as a 10-digit UNIX timestamp in seconds. Must be later than estimated_departure_datetime. |
| shipment_service | string | Conditional | Required when shipment services are available for the destination: TP = Tracked Packet, EM = EMS. Ignored for destinations that offer no choice. |
| ship_type_details | array | Yes | Array of containers. Each element is an array of the WMG tracking numbers packed into that bag/AKE/pallet, and must not be empty. |
| order_mawb | object | Conditional | MAWB details. Required when ship_route is 2, 3 or 4. |
| order_mawb.mawb_no | string | Conditional | MAWB number. Maximum 60 characters. |
| order_mawb.departure_airport | string | Conditional | Departure airport code. Exactly 3 characters. |
| order_mawb.arrival_airport | string | Conditional | Arrival airport code. Exactly 3 characters. |
| order_mawb.outbound_flight_no | string | Conditional | Flight number on the MAWB. Maximum 60 characters. |
| order_mawb.estimated_departure_datetime | string | Conditional | Estimated departure time, as a 10-digit UNIX timestamp in seconds. |
| order_mawb.estimated_arrival_datetime | string | Conditional | Estimated arrival time, as a 10-digit UNIX timestamp in seconds. Must be later than order_mawb.estimated_departure_datetime. |
Request Body Example
Direct CN route — no MAWB required, two containers:
{
"ship_type": 1,
"ship_route": 1,
"is_ddp": "N",
"departure_port": "SIN",
"destination_port": "PHS",
"outbound_flight_no": "SQ918",
"estimated_departure_datetime": "1784115300",
"estimated_arrival_datetime": "1784128800",
"destination": "PH",
"shipment_service": "TP",
"ship_type_details": [
[
"TES00123456TP",
"TES00123457TP"
],
[
"TES00123458TP"
]
]
}Master2CN route — order_mawb is required:
{
"ship_type": 3,
"ship_route": 2,
"is_ddp": "Y",
"departure_port": "SIN",
"destination_port": "TPE",
"outbound_flight_no": "SQ876",
"estimated_departure_datetime": "1784115300",
"estimated_arrival_datetime": "1784128800",
"destination": "TW",
"order_mawb": {
"mawb_no": "12123224",
"departure_airport": "SIN",
"arrival_airport": "TPE",
"outbound_flight_no": "SQ876",
"estimated_departure_datetime": "1784115300",
"estimated_arrival_datetime": "1784128800"
},
"ship_type_details": [
[
"BX000000014CG",
"BX000000028CG"
]
]
}Authentication
This endpoint uses Bearer token authentication.
Obtain a token from Get Token and send it as Authorization: Bearer <Token>.
Response Information
The response is in JSON format.
Response Format
| Field | Type | Description |
|---|---|---|
| Code | integer | 0 = success; non-zero = failure |
| Message | string | Human-readable result |
| Data | object | Payload; empty array [] on failure |
Success Response
- Status Code: 200
{
"Code": 0,
"Message": "Success",
"Data": {
"JobNo": "CN38SG24010001"
}
}| Field | Type | Description |
|---|---|---|
| Data.JobNo | string | The job number of the created order. Use it as job_no in Get Order File. |
Error Response
- Status Code: 200 (business logic error) or 4xx/5xx (system error)
{
"Code": 1,
"Message": "WMG Tracking Num(TES00123456TP) not exists!",
"Data": []
}Code Reference
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Failure |
Example
Bash
BASE_URL="https://api.postal.test.wmgdelivery.com"
TOKEN="your_access_token"
curl -X POST "$BASE_URL/api/order/create-order" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"ship_type": 1,
"ship_route": 1,
"is_ddp": "N",
"departure_port": "SIN",
"destination_port": "PHS",
"outbound_flight_no": "SQ918",
"estimated_departure_datetime": "1784115300",
"estimated_arrival_datetime": "1784128800",
"destination": "PH",
"shipment_service": "TP",
"ship_type_details": [["TES00123456TP", "TES00123457TP"]]
}'Windows PowerShell
$BASE_URL = "https://api.postal.test.wmgdelivery.com"
$TOKEN = "your_access_token"
# @(, @(...)) keeps the inner array nested — a single inner array would otherwise flatten
$body = @{
ship_type = 1
ship_route = 1
is_ddp = "N"
departure_port = "SIN"
destination_port = "PHS"
outbound_flight_no = "SQ918"
estimated_departure_datetime = "1784115300"
estimated_arrival_datetime = "1784128800"
destination = "PH"
shipment_service = "TP"
ship_type_details = @(, @("TES00123456TP", "TES00123457TP"))
} | ConvertTo-Json -Depth 5
$response = Invoke-RestMethod -Uri "$BASE_URL/api/order/create-order" -Method Post `
-ContentType "application/json" -Body $body -Headers @{Authorization = "Bearer $TOKEN"}
$response.Data.JobNoPython
import requests
BASE_URL = "https://api.postal.test.wmgdelivery.com"
TOKEN = "your_access_token"
resp = requests.post(f"{BASE_URL}/api/order/create-order", json={
"ship_type": 1,
"ship_route": 1,
"is_ddp": "N",
"departure_port": "SIN",
"destination_port": "PHS",
"outbound_flight_no": "SQ918",
"estimated_departure_datetime": "1784115300",
"estimated_arrival_datetime": "1784128800",
"destination": "PH",
"shipment_service": "TP",
# Outer array = containers, inner array = the parcels in that container
"ship_type_details": [["TES00123456TP", "TES00123457TP"]],
}, headers={"Authorization": f"Bearer {TOKEN}"}, timeout=60)
print(resp.json())Node.js / TypeScript
const BASE_URL = "https://api.postal.test.wmgdelivery.com";
const TOKEN = "your_access_token";
const res = await fetch(`${BASE_URL}/api/order/create-order`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${TOKEN}`,
},
body: JSON.stringify({
ship_type: 1,
ship_route: 1,
is_ddp: "N",
departure_port: "SIN",
destination_port: "PHS",
outbound_flight_no: "SQ918",
estimated_departure_datetime: "1784115300",
estimated_arrival_datetime: "1784128800",
destination: "PH",
shipment_service: "TP",
// Outer array = containers, inner array = the parcels in that container
ship_type_details: [["TES00123456TP", "TES00123457TP"]],
}),
});
console.log(await res.json());PHP
<?php
$BASE_URL = 'https://api.postal.test.wmgdelivery.com';
$TOKEN = 'your_access_token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $BASE_URL . '/api/order/create-order');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . $TOKEN,
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'ship_type' => 1,
'ship_route' => 1,
'is_ddp' => 'N',
'departure_port' => 'SIN',
'destination_port' => 'PHS',
'outbound_flight_no' => 'SQ918',
'estimated_departure_datetime' => '1784115300',
'estimated_arrival_datetime' => '1784128800',
'destination' => 'PH',
'shipment_service' => 'TP',
// Outer array = containers, inner array = the parcels in that container
'ship_type_details' => [['TES00123456TP', 'TES00123457TP']],
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$response = curl_exec($ch);
curl_close($ch);
echo json_encode(json_decode($response, true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
?>Notes
- The order is created and closed in a single call. There is no separate close step, and the order cannot be amended through the API afterwards — verify the payload before sending it.
- Shipment documents are generated after closing, not instantly. Retrieve them with Get Order File, which waits briefly for generation to finish.
ship_type_detailsis an array of arrays: the outer array is the list of containers, each inner array holds the WMG tracking numbers packed into that container. No inner array may be empty.- A maximum of 999 parcels may be included across all containers in one order.
- The same tracking number may not appear twice in
ship_type_details, in any container. - Every parcel must satisfy all of the following, or the whole request is rejected:
- it exists and belongs to your account;
- it is not already part of another order — a re-used parcel is reported with the "scanned before in previous shipments" message and needs a fresh CN23 label;
- its clearance mode matches the order's
is_ddp; - its destination matches the order's
destination— except on the Transshipment CN and Transshipment CN(AF) routes, where this check is skipped; - its carrier matches the order's carrier;
- its size type matches the order's container size;
- its dimensions and weight are within the limits for its service and destination.
order_mawbis only required on the Master2CN routes (ship_route2,3,4). It is accepted but not required on the others.- Timestamps are 10-digit UNIX seconds; the examples send them as strings, which is what existing integrations use.
- This call performs the full order build, document trigger and close, so it is slower than a lookup — allow a generous client timeout.
- All parameters are case-sensitive.
Error Codes
| code | message | Description |
|---|---|---|
1 | ship_type require | ship_type is missing or empty. |
1 | ship_type invalid | ship_type is not 1, 2 or 3. |
1 | ship_route require | ship_route is missing or empty. |
1 | Ship Route Invalid | ship_route is not one of 1–7. |
1 | is_ddp must be in Y,N | is_ddp is neither Y nor N. |
1 | destination require | destination is missing or empty. |
1 | size of destination must be 2 | destination is not exactly 2 characters. |
1 | departure_port require | departure_port is missing or empty. |
1 | size of departure_port must be 3 | departure_port is not exactly 3 characters. |
1 | destination_port require | destination_port is missing or empty. |
1 | size of destination_port must be 3 | destination_port is not exactly 3 characters. |
1 | outbound_flight_no require | outbound_flight_no is missing or empty. |
1 | max size of outbound_flight_no must be 60 | outbound_flight_no is longer than 60 characters. |
1 | estimated_departure_datetime require | estimated_departure_datetime is missing or empty. |
1 | estimated_departure_datetime must be a timestamp | estimated_departure_datetime is not a valid UNIX timestamp. |
1 | estimated_arrival_datetime require | estimated_arrival_datetime is missing or empty. |
1 | estimated_arrival_datetime must be a timestamp | estimated_arrival_datetime is not a valid UNIX timestamp. |
1 | estimated_arrival_datetime must be greater than 'estimated_departure_datetime' | Arrival is not later than departure. |
1 | shipment_service must be TP or EM | The destination offers a service choice and shipment_service is neither TP nor EM. |
1 | ship_type_details require | ship_type_details is missing or empty. |
1 | ship_type_details must be a array | ship_type_details is not an array. |
1 | ship_type_details must contain non-empty bags | One of the containers in ship_type_details is empty or not an array. |
1 | bags require | ship_type_details resolved to no containers at all. |
1 | bag item(1) must be array | The container at that position is not an array. The number is the 1-based container index. |
1 | bag item parcel(1) must be string | The entry at that position inside a container is not a string. The number is the 1-based entry index. |
1 | WMG Tracking Num(TES00123456TP) Duplicate! | The same tracking number appears more than once across all containers. |
1 | The number of items cannot exceed 999 | More than 999 parcels in one order. |
1 | WMG Tracking Num(TES00123456TP) not exists! | No such parcel in your account. |
1 | Order clearance mode(DDP) is inconsistent with the parcel((TES00123456TP)) clearance mode(DDU) | The parcel's clearance mode differs from the order's is_ddp. |
1 | Parcel(TES00123456TP) destination(TH) is inconsistent with order destination(PH) | The parcel's destination differs from the order's destination. |
1 | Parcel(TES00123456TP) partner is inconsistent with order partner | The parcel's carrier differs from the order's carrier. |
1 | (TES00123456TP) The package size does not match the size set in the order | The parcel's size type differs from the order's container size. |
1 | (TES00123456TP)This parcel has been scanned before in previous shipments. Please generate a new CN23 label for this parcel and redo bagging scan. | The parcel already belongs to another order. Generate a new CN23 label and re-bag it. |
1 | Parcel(TES00123456TP): | The parcel exceeds the dimension, length or weight limit for its service and destination. The text after the colon states which limit. |
1 | Error encountered, please contact tech@wmg-group.com with screenshot of error page for resolution. | Unexpected server error. |
1003 | Token error | The token is missing, expired, or superseded by a newer login. Call Get Token again. |
Order build and carrier-matching failures surface their own message text with Code: 1. Treat any unrecognised Message as a rejection of the whole order — nothing is created when the call fails.