Cancel Orders
API Overview
Cancels one or more parcels that have already been routed to the SPX carrier. Results are split into success (cancelled) and errors (could not be cancelled). Up to 100 tracking numbers per request. Only orders previously assigned to SPX (including pickup variants) are eligible.
Request Information
- Method: POST
- Path:
/openapi/order/cancel-orders - Authentication: Standard OpenAPI token (MD5-based)
Request Headers
| Field | Description |
|---|---|
| Content-Type | application/json |
| x-auth-name | $API_NAME |
| x-auth-seed | $SEED (13-digit millisecond Unix timestamp) |
| x-auth-token | $TOKEN (MD5 hash) |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| tracking_nums | array | Yes | Array of WMG tracking number strings to cancel |
Request Body Example
json
{
"tracking_nums": ["WMG1234567", "WMG7654321"]
}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
| Field | Type | Description |
|---|---|---|
| code | integer | Result code. 0 = success, 1 = failure |
| message | string | Result description |
| data | object | Contains success and errors arrays |
Success Response
- Status Code: 200
- Response Body:
json
{
"code": 0,
"message": "success",
"data": {
"success": [
"WR0BL260000046SG",
"SPXSG066849392891",
"SPXSG068750771351"
],
"errors": [
{
"remarks": "Canceled",
"tracking_number": "C251230155241302430003"
},
{
"remarks": "No Record(s)",
"tracking_number": "NZ2601089000005"
},
{
"remarks": "Distribution process not found:dp id[660]",
"tracking_number": "SPXSG061914269951"
}
]
}
}| Field | Type | Description |
|---|---|---|
| data.success | array of string | WMG tracking numbers that were successfully cancelled |
| data.errors | array of object | Orders that could not be cancelled |
| data.errors[].tracking_number | string | The WMG tracking number that failed to cancel |
| data.errors[].remarks | string | Reason. One of: No Record(s) (not found under this client / not an SPX order), Canceled (already cancelled), Not Found In Partner System (carrier has no tracking number on file), Cancel Fail (carrier API rejected the batch), or a message returned directly by the carrier's cancel API |
Error Response
- Status Code: 200 (business logic error) or 4xx/5xx (system error)
- Response Body:
json
{
"code": 1,
"message": "tracking_nums required",
"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 - Empty
tracking_numsarray -- code1, messagetracking_nums required - More than 100 tracking numbers in one request -- code
1, messageBatch Cancel Maximum 100 tracking nums
Code Reference
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Failure |
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/cancel-orders" \
-H "Content-Type: application/json" \
-H "x-auth-name: $API_NAME" \
-H "x-auth-seed: $SEED" \
-H "x-auth-token: $TOKEN" \
-d '{"tracking_nums": ["WMG1234567", "WMG7654321"]}'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 = @{
tracking_nums = @("WMG1234567", "WMG7654321")
} | ConvertTo-Json -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/cancel-orders" `
-Method Post -Headers $headers -Body $body
$response | ConvertTo-Json -Depth 10Python
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 = {
'tracking_nums': ['WMG1234567', 'WMG7654321'],
}
resp = requests.post('https://api.test.wmgdelivery.com/v1/openapi/order/cancel-orders', 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({
tracking_nums: ['WMG1234567', 'WMG7654321'],
});
const resp = await fetch('https://api.test.wmgdelivery.com/v1/openapi/order/cancel-orders', {
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 = [
'tracking_nums' => ['WMG1234567', 'WMG7654321'],
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.test.wmgdelivery.com/v1/openapi/order/cancel-orders');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body, JSON_UNESCAPED_UNICODE));
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
- This endpoint is only available to specifically authorised accounts; standard credentials will receive an access error.
- Orders that cannot be cancelled (e.g., already delivered or in transit) are returned in
data.errors. - 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
| code | message | Description |
|---|---|---|
1 | Authentication error message | Authentication failed; the returned message depends on the cause — see the full list in signature.md |
1 | tracking_nums required | tracking_nums is missing or empty |
1 | Batch Cancel Maximum 100 tracking nums | More than 100 tracking numbers were submitted in one request |