批量创建订单
该接口当前不可用
无论传什么参数,/openapi/order/create-orders 一律返回 code: 1,message 为 Api not found。 请改用创建订单逐单提交。本页在接口重新开放前仅作参考保留。
接口说明
一次提交多个包裹下单。当前处于停用状态,见上方提示。
请求信息
- 方法:POST
- 路径:
/openapi/order/create-orders - 认证方式:标准 OpenAPI token(基于 MD5)
请求头
| 字段 | 说明 |
|---|---|
| Content-Type | application/json |
| x-auth-name | $API_NAME |
| x-auth-seed | $SEED(13 位毫秒级 UNIX 时间戳) |
| x-auth-token | $TOKEN(MD5 哈希) |
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| orders | array | 是 | 订单对象数组。每个元素的字段与创建订单的请求体相同 |
请求体示例
json
{
"orders": [
{
"custom_tracking_num": "ORDER-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 生成说明
token 只由凭证和 seed 计算得出 —— 请求参数不参与。
seed = "1746700000000" (13 位毫秒时间戳)
token = md5( strtolower(api_name) + api_key + seed )认证
本接口使用标准 OpenAPI 认证(MD5 token)。
完整的认证说明与多语言示例见认证与签名。
响应信息
响应为 JSON 格式。
响应结构
| 字段 | 类型 | 说明 |
|---|---|---|
| code | integer | 结果码。0 = 成功,1 = 失败 |
| message | string | 结果描述 |
| data | array | 逐单结果 |
成功响应
- HTTP 状态码:200
接口重新开放后的响应形态如下,当前不会返回。
json
{
"code": 0,
"message": "success",
"data": {
"success": [
{
"custom_tracking_num": "C240719112801849950gAA",
"date_time": "2024-07-19T13:30:48+08:00",
"status": "Accepted",
"error": []
}
],
"errors": [
{
"custom_tracking_num": "C240719112801849A950gAA",
"date_time": "2024-07-19T13:30:48+08:00",
"status": "Rejected",
"error": [
{
"reason": "Service Code invalid"
}
]
}
]
}
}| 字段 | 类型 | 说明 |
|---|---|---|
| data.success | array | 已受理并进入创建队列的订单 |
| data.success[].custom_tracking_num | string | 你提交的内部单号 |
| data.success[].date_time | string | 批次处理时间,ISO 8601 格式 |
| data.success[].status | string | 已入队的订单为 Accepted |
| data.success[].error | array | 受理成功时为空数组 |
| data.errors | array | 校验未通过被拒绝的订单;元素结构与 success[] 相同,但 status 为 Rejected,且 error[] 中带一条或多条原因 |
失败响应
- HTTP 状态码:200(业务错误)或 4xx/5xx(系统错误)
json
{
"code": 1,
"message": "Api not found",
"data": []
}常见错误:
- 认证失败 → code
1;具体 message 取决于失败原因(如x-auth-token: INVALID、x-auth-seed: TIMEOUT)—— 见认证与签名 - 接口停用 → code
1,message 为Api not found(当前所有请求的实际返回) - 单次推送订单数超过配置上限 → code
1,message 为The one-time push order data cannot exceed N pieces
结果码
| Code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 失败 |
调用示例
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-orders" \
-H "Content-Type: application/json" \
-H "x-auth-name: $API_NAME" \
-H "x-auth-seed: $SEED" \
-H "x-auth-token: $TOKEN" \
-d '{
"orders": [
{
"custom_tracking_num": "ORDER-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") })
$order = [ordered]@{
custom_tracking_num = "ORDER-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 })
}
$body = [ordered]@{ orders = @($order) } | ConvertTo-Json -Depth 6 -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-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 = {
'orders': [
{
'custom_tracking_num': 'ORDER-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-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({
orders: [
{
custom_tracking_num: 'ORDER-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-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 = [
'orders' => [
[
'custom_tracking_num' => 'ORDER-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-orders');
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, 30);
$response = curl_exec($ch);
curl_close($ch);
echo json_encode(json_decode($response, true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
?>注意事项
- 该接口当前对所有请求返回
Api not found,请使用创建订单。 - 接口重新开放后,单次提交条数受服务端配置上限约束,超出会返回
The one-time push order data cannot exceed N pieces。 - 认证 token 不包含请求参数,只用凭证和 seed 计算。
x-auth-seed必须是 13 位毫秒级 UNIX 时间戳,且与服务器时间相差不超过 ±10 分钟。- 所有参数区分大小写。
错误码
| code | message | 说明 |
|---|---|---|
1 | 认证错误消息 | 认证失败;具体 message 取决于失败原因 —— 完整清单见认证与签名 |
1 | Api not found | 接口当前处于停用状态,所有请求都返回该消息 |
1 | The one-time push order data cannot exceed N pieces | 单次提交条数超过服务端配置上限 |