Skip to content

Create Order

API Overview

Submits a single new parcel order to the WMG platform. The system validates the recipient and sender details, assigns a WMG tracking number, and routes the parcel to the appropriate carrier. Use this endpoint for real-time order creation from your fulfillment workflow.

Request Information

  • Method: POST
  • Path: /openapi/order/create-order
  • Authentication: Standard OpenAPI token (MD5-based)

Request Headers

FieldDescription
Content-Typeapplication/json
x-auth-name$API_NAME
x-auth-seed$SEED (13-digit millisecond Unix timestamp)
x-auth-token$TOKEN (MD5 hash)

Request Parameters

The request body is in JSON format and includes the following fields:

ParameterTypeRequiredDescription
custom_tracking_numstringYesYour internal order reference. Alphanumeric, -, and _ only; max 32 characters
recipient_namestringYesRecipient full name; max 64 characters
recipient_countrystringYesRecipient ISO 3166-1 alpha-2 country code (uppercase, length 2)
recipient_phonestringYesRecipient phone number; digits only; max 24 characters
recipient_addressstringYesRecipient street address; max 512 characters
sender_countrystringYesSender ISO 3166-1 alpha-2 country code (uppercase, length 2)
client_sizestringYesParcel dimensions in L,W,H (centimetres), three comma-separated non-negative numbers, e.g. 30,20,10; max 30 characters
client_weightfloatYesParcel weight (range 0–9999); unit per your account settings
declared_valuefloatYesDeclared customs value; range 0–9999.99
declared_value_currencystringYesDeclared-value currency in ISO 4217 alpha-3 (length 3)
itemarrayYesArray of item objects — see item[] table below
postal_codestringConditionalRecipient postal code. Required for every destination except HK. Non-digit characters are stripped before validation, then the length is checked per destination (SG = 5–6, MY = 4–5, KR = 4–5, JP = 5–7, all other destinations 3–10)
recipient_statestringConditionalRecipient state / province; required when recipient_country = US; max 60 characters
recipient_citystringNoRecipient city; max 64 characters
recipient_emailstringNoRecipient email address; max 320 characters
sender_namestringConditionalSender full name; required for pickup service types; max 64 characters
sender_phonestringConditionalSender phone (digits only, max 24); required for pickup service types
sender_addressstringConditionalSender street address (max 512); required for pickup service types
sender_postal_codestringConditionalSender postal code (3–10). For pickup service types it is required unless sender_country = HK; for non-pickup service types it is optional
sender_citystringNoSender city; max 64 characters
sender_emailstringNoSender email address; max 320 characters
service_typestringNoService type code, length 3. Use the code assigned to your account; when omitted the order is handled as last mile only. Pickup service types also require the sender_* fields
service_codestringNoCarrier routing service code, length 3. Required and must be a valid code when recipient_country = US; optional for SG but must be valid if sent; ignored for every other destination. Contact WMG for the codes enabled on your account
instructionstringNoDelivery instructions; max 1024 characters
cashfloatNoCash-on-delivery amount; 0–9999.99; requires cash_currency
cash_currencystringNoCOD currency ISO 4217 alpha-3; for recipient_country = SG must be SGD; requires cash
supplier_namestringNoSupplier name; max 64 characters
supplier_gstnstringNoSupplier GST registration number; max 64 characters
total_gst_amountfloatNoTotal GST amount; 0–9999.99
gst_currencystringNoGST currency ISO 4217 alpha-3
gst_paidstringNoY or N
incoterm_typestringNoIncoterm code: DDU or DDP
locker_typestringNoParcel locker handling. A = the address is already a locker address; B = a normal address that should be converted to the nearest locker. Only A and B are accepted.
locker_stationobjectConditionalRequired when locker_type is A. See the locker_station table below.

Each element of item[] must contain:

FieldTypeRequiredDescription
descriptionstringYesItem description; max 255 characters
unitPricefloatYesUnit price; ≥ 0
quantitynumberYesQuantity; ≥ 0
weightfloatYesItem weight; ≥ 0
currencystringYesISO 4217 alpha-3 currency code (length 3)
totalValuefloatYesItem total value; ≥ 0
countryOfOriginstringNoISO 3166-1 alpha-2 country code (length 2)
itemHSCodestringNoCustoms HS code; max 255 characters
productURLstringNoProduct page URL; max 500 characters

locker_station

FieldTypeRequiredDescriptionLength
zipcodestringYesZipcode<= 16 characters
station_namestringYesStation Name<= 64 characters
station_addressstringYesStation Address<= 255 characters
address_detailstringYesAddress Detail<= 255 characters
distancefloatYesDistance
station_codestringYesStation Code<= 10 characters

Request Body Example

json
{
  "custom_tracking_num": "ORDER-20260501-001",
  "recipient_name": "Jane Smith",
  "recipient_country": "SG",
  "recipient_phone": "6591234567",
  "recipient_address": "123 Orchard Road",
  "recipient_city": "Singapore",
  "recipient_email": "jane@example.com",
  "postal_code": "238858",
  "sender_country": "SG",
  "client_size": "30,20,10",
  "client_weight": 1.5,
  "declared_value": 99.99,
  "declared_value_currency": "SGD",
  "item": [
    {
      "description": "Electronics",
      "itemHSCode": "8471300000",
      "quantity": 1,
      "unitPrice": 99.99,
      "weight": 1.5,
      "currency": "SGD",
      "totalValue": 99.99
    }
  ]
}

Token Generation Example

The authentication token is computed from your credentials and seed only -- request parameters are not included.

seed  = "1746700000000"   (13-digit ms timestamp)
token = md5( strtolower(api_name) + api_key + seed )

Authentication

This endpoint uses Standard OpenAPI Authentication (MD5 token).

For complete authentication instructions and code examples, see Authentication Guide.

Response Information

The response is in JSON format.

Response Format

FieldTypeDescription
codeintegerResult code. 0 = success, 1 = failure
messagestringResult description
dataobjectResponse payload

Success Response

  • Status Code: 200
  • Response Body:
json
{
  "code": 0,
  "message": "success",
  "data": {
    "custom_tracking_num": "C240719112805334a634B",
    "wmg_tracking_num": "WGC000000000233",
    "date_time": "2024-07-19T13:34:26+08:00",
    "status": "",
    "error": []
  }
}
FieldTypeDescription
data.custom_tracking_numstringYour submitted order reference
data.wmg_tracking_numstringWMG-assigned tracking number
data.date_timestringISO 8601 timestamp when the order was created
data.statusstringPer-order status flag; empty string for an accepted real-time create
data.errorarrayPer-order errors collected during processing; empty array on success

Error Response

  • Status Code: 200 (business logic error) or 4xx/5xx (system error)
  • Response Body:
json
{
  "code": 1,
  "message": "Client Size invalid",
  "data": []
}

Common errors:

  • Authentication failure → code 1; the message depends on the cause (e.g. x-auth-token: INVALID, x-auth-seed: TIMEOUT) — see signature.md
  • Missing or invalid field -- code 1, field validation message (e.g. client_weight require, recipient_country invalid)
  • Duplicate custom_tracking_num for this client -- code 1, message custom_tracking_num (XXX) already exist
  • Invalid service_code -- code 1, message Service code invalid (US) or Service code (XXX) invalid (SG)
  • Recipient country not in the allowed list -- code 1, message recipient_country(XX) not allow
  • Per-item validation failure -- code 1, message Item <row> <field> <reason> (e.g. Item 1 unitPrice require)

Code Reference

CodeDescription
0Success
1Failure

Example

Bash

bash
API_NAME="your_api_name"
API_KEY="your_api_key"
SEED=$(date +%s%3N)
TOKEN=$(printf '%s' "$(echo -n "$API_NAME" | tr '[:upper:]' '[:lower:]')${API_KEY}${SEED}" | md5sum | cut -d' ' -f1)

curl -X POST "https://api.test.wmgdelivery.com/v1/openapi/order/create-order" \
  -H "Content-Type: application/json" \
  -H "x-auth-name: $API_NAME" \
  -H "x-auth-seed: $SEED" \
  -H "x-auth-token: $TOKEN" \
  -d '{
    "custom_tracking_num": "ORDER-20260501-001",
    "recipient_name": "Jane Smith",
    "recipient_country": "SG",
    "recipient_phone": "6591234567",
    "recipient_address": "123 Orchard Road",
    "recipient_city": "Singapore",
    "recipient_email": "jane@example.com",
    "postal_code": "238858",
    "sender_country": "SG",
    "client_size": "30,20,10",
    "client_weight": 1.5,
    "declared_value": 99.99,
    "declared_value_currency": "SGD",
    "item": [{"description": "Electronics", "itemHSCode": "8471300000", "quantity": 1, "unitPrice": 99.99, "weight": 1.5, "currency": "SGD", "totalValue": 99.99}]
  }'

Windows PowerShell

powershell
$API_NAME = "your_api_name"
$API_KEY  = "your_api_key"
$SEED     = [string]([DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds())

$raw   = [System.Text.Encoding]::UTF8.GetBytes($API_NAME.ToLower() + $API_KEY + $SEED)
$md5   = [System.Security.Cryptography.MD5]::Create().ComputeHash($raw)
$TOKEN = -join ($md5 | ForEach-Object { $_.ToString("x2") })

$body = [ordered]@{
    custom_tracking_num     = "ORDER-20260501-001"
    recipient_name          = "Jane Smith"
    recipient_country       = "SG"
    recipient_phone         = "6591234567"
    recipient_address       = "123 Orchard Road"
    recipient_city          = "Singapore"
    recipient_email         = "jane@example.com"
    postal_code             = "238858"
    sender_country          = "SG"
    client_size             = "30,20,10"
    client_weight           = 1.5
    declared_value          = 99.99
    declared_value_currency = "SGD"
    item                    = @(@{ description = "Electronics"; itemHSCode = "8471300000"; quantity = 1; unitPrice = 99.99; weight = 1.5; currency = "SGD"; totalValue = 99.99 })
} | ConvertTo-Json -Depth 5 -Compress

$headers = @{
    "Content-Type" = "application/json"
    "x-auth-name"  = $API_NAME
    "x-auth-seed"  = $SEED
    "x-auth-token" = $TOKEN
}

$response = Invoke-RestMethod `
    -Uri "https://api.test.wmgdelivery.com/v1/openapi/order/create-order" `
    -Method Post -Headers $headers -Body $body
$response | ConvertTo-Json -Depth 10

Python

python
import hashlib, time
import requests

API_NAME = 'your_api_name'
API_KEY  = 'your_api_key'
SEED     = str(int(time.time() * 1000))
TOKEN    = hashlib.md5((API_NAME.lower() + API_KEY + SEED).encode()).hexdigest()

headers = {
    'Content-Type': 'application/json',
    'x-auth-name':  API_NAME,
    'x-auth-seed':  SEED,
    'x-auth-token': TOKEN,
}

body = {
    'custom_tracking_num':     'ORDER-20260501-001',
    'recipient_name':          'Jane Smith',
    'recipient_country':       'SG',
    'recipient_phone':         '6591234567',
    'recipient_address':       '123 Orchard Road',
    'recipient_city':          'Singapore',
    'recipient_email':         'jane@example.com',
    'postal_code':             '238858',
    'sender_country':          'SG',
    'client_size':             '30,20,10',
    'client_weight':           1.5,
    'declared_value':          99.99,
    'declared_value_currency': 'SGD',
    'item': [{'description': 'Electronics', 'itemHSCode': '8471300000', 'quantity': 1, 'unitPrice': 99.99, 'weight': 1.5, 'currency': 'SGD', 'totalValue': 99.99}],
}

resp = requests.post('https://api.test.wmgdelivery.com/v1/openapi/order/create-order', json=body, headers=headers)
print(resp.json())

Node.js / TypeScript

typescript
import crypto from 'node:crypto';

const API_NAME = 'your_api_name';
const API_KEY  = 'your_api_key';
const SEED     = String(Date.now());
const TOKEN    = crypto.createHash('md5').update(API_NAME.toLowerCase() + API_KEY + SEED).digest('hex');

const body = JSON.stringify({
    custom_tracking_num:     'ORDER-20260501-001',
    recipient_name:          'Jane Smith',
    recipient_country:       'SG',
    recipient_phone:         '6591234567',
    recipient_address:       '123 Orchard Road',
    recipient_city:          'Singapore',
    recipient_email:         'jane@example.com',
    postal_code:             '238858',
    sender_country:          'SG',
    client_size:             '30,20,10',
    client_weight:           1.5,
    declared_value:          99.99,
    declared_value_currency: 'SGD',
    item: [{ description: 'Electronics', itemHSCode: '8471300000', quantity: 1, unitPrice: 99.99, weight: 1.5, currency: 'SGD', totalValue: 99.99 }],
});

const resp = await fetch('https://api.test.wmgdelivery.com/v1/openapi/order/create-order', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'x-auth-name':  API_NAME,
        'x-auth-seed':  SEED,
        'x-auth-token': TOKEN,
    },
    body,
});
console.log(JSON.stringify(await resp.json(), null, 2));

PHP

php
<?php
$API_NAME = 'your_api_name';
$API_KEY  = 'your_api_key';
$SEED     = (string)(time() * 1000);
$TOKEN    = md5(strtolower($API_NAME) . $API_KEY . $SEED);

$body = [
    'custom_tracking_num'     => 'ORDER-20260501-001',
    'recipient_name'          => 'Jane Smith',
    'recipient_country'       => 'SG',
    'recipient_phone'         => '6591234567',
    'recipient_address'       => '123 Orchard Road',
    'recipient_city'          => 'Singapore',
    'recipient_email'         => 'jane@example.com',
    'postal_code'             => '238858',
    'sender_country'          => 'SG',
    'client_size'             => '30,20,10',
    'client_weight'           => 1.5,
    'declared_value'          => 99.99,
    'declared_value_currency' => 'SGD',
    'item'                    => [
        ['description' => 'Electronics', 'itemHSCode' => '8471300000', 'quantity' => 1, 'unitPrice' => 99.99, 'weight' => 1.5, 'currency' => 'SGD', 'totalValue' => 99.99],
    ],
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.test.wmgdelivery.com/v1/openapi/order/create-order');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'x-auth-name: '  . $API_NAME,
    'x-auth-seed: '  . $SEED,
    'x-auth-token: ' . $TOKEN,
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
curl_close($ch);
echo json_encode(json_decode($response, true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
?>

Notes

  • custom_tracking_num accepts only alphanumeric characters, -, and _; maximum 32 characters.
  • postal_code should contain digits only.
  • The authentication token does not include request parameters; only credentials and seed are used.
  • The seed must be a 13-digit millisecond Unix timestamp and within ±10 minutes of server time.
  • All parameters are case-sensitive.

Error Codes

codemessageDescription
1Authentication error messageAuthentication failed; the returned message depends on the cause — see the full list in signature.md
1custom_tracking_num (XXX) already existA previous order with the same custom_tracking_num already exists for this client. Note that exist has no trailing s
1Service code invalidrecipient_country = US and service_code is missing or is not a recognised code
1Service code (XXX) invalidrecipient_country = SG and the submitted service_code is not a recognised code
1recipient_country(XX) not allowThe recipient ISO country code is not in the platform's allowed-country list
1Item <row> <field> <reason>One of the item[] rows failed validation; the row number and field name pinpoint the failure
1Field validation messageOther field-level validation failures (required, length, format, enum)