curl --request POST \
--url https://api.flexforwardship.com/labels \
--header 'Content-Type: application/json' \
--header 'x-rr-apikey: <api-key>' \
--header 'x-rr-apitoken: <api-key>' \
--data '
{
"idempotencyKey": "unique-key-per-request",
"courier": "yunexpress",
"service": {
"productCode": "HKMUZXR"
},
"label": {
"format": "PDF"
},
"units": {
"weight": "KG",
"dimension": "CM"
},
"order": {
"customerOrderNumber": "N-2026-05-27-TEST-03",
"orderNumbers": {
"platformOrderNumber": "platform-order-number",
"referenceNumbers": [
"ref-number-1",
"ref-number-2"
]
}
},
"shipment": {
"shipTo": {
"contact": {
"firstName": "Alex",
"lastName": "Smith",
"phone": 8554377467,
"email": "[email protected]"
},
"address": {
"streetLines": [
"18 Distribution Blvd"
],
"city": "Edison",
"state": "New jersey",
"postalCode": 8817,
"countryCode": "US"
}
},
"shipFrom": {
"contact": {
"firstName": "John",
"lastName": "Doe",
"phone": 886900676877,
"email": "[email protected]"
},
"address": {
"streetLines": [
"Habucho"
],
"city": "Kishiwada-Shi",
"state": "Osaka",
"postalCode": "596-0825",
"countryCode": "JP"
}
},
"parcels": [
{
"weight": 0.5,
"dimension": {
"length": 30,
"width": 20,
"height": 10
},
"items": [
{
"descriptionEn": "Muji Ink pen",
"descriptionLocal": "文具",
"quantity": 1,
"unitPrice": {
"amount": 29.99,
"currency": "USD"
},
"unitWeight": 0.5
}
]
}
]
},
"serviceOptions": [
{
"code": "V1",
"value": "云途预缴"
}
],
"courierOptions": {
"yunexpress": {
"sourceCode": "YT",
"sensitiveType": "D"
}
}
}
'import requests
url = "https://api.flexforwardship.com/labels"
payload = {
"idempotencyKey": "unique-key-per-request",
"courier": "yunexpress",
"service": { "productCode": "HKMUZXR" },
"label": { "format": "PDF" },
"units": {
"weight": "KG",
"dimension": "CM"
},
"order": {
"customerOrderNumber": "N-2026-05-27-TEST-03",
"orderNumbers": {
"platformOrderNumber": "platform-order-number",
"referenceNumbers": ["ref-number-1", "ref-number-2"]
}
},
"shipment": {
"shipTo": {
"contact": {
"firstName": "Alex",
"lastName": "Smith",
"phone": 8554377467,
"email": "[email protected]"
},
"address": {
"streetLines": ["18 Distribution Blvd"],
"city": "Edison",
"state": "New jersey",
"postalCode": 8817,
"countryCode": "US"
}
},
"shipFrom": {
"contact": {
"firstName": "John",
"lastName": "Doe",
"phone": 886900676877,
"email": "[email protected]"
},
"address": {
"streetLines": ["Habucho"],
"city": "Kishiwada-Shi",
"state": "Osaka",
"postalCode": "596-0825",
"countryCode": "JP"
}
},
"parcels": [
{
"weight": 0.5,
"dimension": {
"length": 30,
"width": 20,
"height": 10
},
"items": [
{
"descriptionEn": "Muji Ink pen",
"descriptionLocal": "文具",
"quantity": 1,
"unitPrice": {
"amount": 29.99,
"currency": "USD"
},
"unitWeight": 0.5
}
]
}
]
},
"serviceOptions": [
{
"code": "V1",
"value": "云途预缴"
}
],
"courierOptions": { "yunexpress": {
"sourceCode": "YT",
"sensitiveType": "D"
} }
}
headers = {
"x-rr-apikey": "<api-key>",
"x-rr-apitoken": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-rr-apikey': '<api-key>',
'x-rr-apitoken': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
idempotencyKey: 'unique-key-per-request',
courier: 'yunexpress',
service: {productCode: 'HKMUZXR'},
label: {format: 'PDF'},
units: {weight: 'KG', dimension: 'CM'},
order: {
customerOrderNumber: 'N-2026-05-27-TEST-03',
orderNumbers: {
platformOrderNumber: 'platform-order-number',
referenceNumbers: ['ref-number-1', 'ref-number-2']
}
},
shipment: {
shipTo: {
contact: {
firstName: 'Alex',
lastName: 'Smith',
phone: 8554377467,
email: '[email protected]'
},
address: {
streetLines: ['18 Distribution Blvd'],
city: 'Edison',
state: 'New jersey',
postalCode: 8817,
countryCode: 'US'
}
},
shipFrom: {
contact: {
firstName: 'John',
lastName: 'Doe',
phone: 886900676877,
email: '[email protected]'
},
address: {
streetLines: ['Habucho'],
city: 'Kishiwada-Shi',
state: 'Osaka',
postalCode: '596-0825',
countryCode: 'JP'
}
},
parcels: [
{
weight: 0.5,
dimension: {length: 30, width: 20, height: 10},
items: [
{
descriptionEn: 'Muji Ink pen',
descriptionLocal: '文具',
quantity: 1,
unitPrice: {amount: 29.99, currency: 'USD'},
unitWeight: 0.5
}
]
}
]
},
serviceOptions: [{code: 'V1', value: '云途预缴'}],
courierOptions: {yunexpress: {sourceCode: 'YT', sensitiveType: 'D'}}
})
};
fetch('https://api.flexforwardship.com/labels', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flexforwardship.com/labels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'idempotencyKey' => 'unique-key-per-request',
'courier' => 'yunexpress',
'service' => [
'productCode' => 'HKMUZXR'
],
'label' => [
'format' => 'PDF'
],
'units' => [
'weight' => 'KG',
'dimension' => 'CM'
],
'order' => [
'customerOrderNumber' => 'N-2026-05-27-TEST-03',
'orderNumbers' => [
'platformOrderNumber' => 'platform-order-number',
'referenceNumbers' => [
'ref-number-1',
'ref-number-2'
]
]
],
'shipment' => [
'shipTo' => [
'contact' => [
'firstName' => 'Alex',
'lastName' => 'Smith',
'phone' => 8554377467,
'email' => '[email protected]'
],
'address' => [
'streetLines' => [
'18 Distribution Blvd'
],
'city' => 'Edison',
'state' => 'New jersey',
'postalCode' => 8817,
'countryCode' => 'US'
]
],
'shipFrom' => [
'contact' => [
'firstName' => 'John',
'lastName' => 'Doe',
'phone' => 886900676877,
'email' => '[email protected]'
],
'address' => [
'streetLines' => [
'Habucho'
],
'city' => 'Kishiwada-Shi',
'state' => 'Osaka',
'postalCode' => '596-0825',
'countryCode' => 'JP'
]
],
'parcels' => [
[
'weight' => 0.5,
'dimension' => [
'length' => 30,
'width' => 20,
'height' => 10
],
'items' => [
[
'descriptionEn' => 'Muji Ink pen',
'descriptionLocal' => '文具',
'quantity' => 1,
'unitPrice' => [
'amount' => 29.99,
'currency' => 'USD'
],
'unitWeight' => 0.5
]
]
]
]
],
'serviceOptions' => [
[
'code' => 'V1',
'value' => '云途预缴'
]
],
'courierOptions' => [
'yunexpress' => [
'sourceCode' => 'YT',
'sensitiveType' => 'D'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-rr-apikey: <api-key>",
"x-rr-apitoken: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flexforwardship.com/labels"
payload := strings.NewReader("{\n \"idempotencyKey\": \"unique-key-per-request\",\n \"courier\": \"yunexpress\",\n \"service\": {\n \"productCode\": \"HKMUZXR\"\n },\n \"label\": {\n \"format\": \"PDF\"\n },\n \"units\": {\n \"weight\": \"KG\",\n \"dimension\": \"CM\"\n },\n \"order\": {\n \"customerOrderNumber\": \"N-2026-05-27-TEST-03\",\n \"orderNumbers\": {\n \"platformOrderNumber\": \"platform-order-number\",\n \"referenceNumbers\": [\n \"ref-number-1\",\n \"ref-number-2\"\n ]\n }\n },\n \"shipment\": {\n \"shipTo\": {\n \"contact\": {\n \"firstName\": \"Alex\",\n \"lastName\": \"Smith\",\n \"phone\": 8554377467,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"18 Distribution Blvd\"\n ],\n \"city\": \"Edison\",\n \"state\": \"New jersey\",\n \"postalCode\": 8817,\n \"countryCode\": \"US\"\n }\n },\n \"shipFrom\": {\n \"contact\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"phone\": 886900676877,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"Habucho\"\n ],\n \"city\": \"Kishiwada-Shi\",\n \"state\": \"Osaka\",\n \"postalCode\": \"596-0825\",\n \"countryCode\": \"JP\"\n }\n },\n \"parcels\": [\n {\n \"weight\": 0.5,\n \"dimension\": {\n \"length\": 30,\n \"width\": 20,\n \"height\": 10\n },\n \"items\": [\n {\n \"descriptionEn\": \"Muji Ink pen\",\n \"descriptionLocal\": \"文具\",\n \"quantity\": 1,\n \"unitPrice\": {\n \"amount\": 29.99,\n \"currency\": \"USD\"\n },\n \"unitWeight\": 0.5\n }\n ]\n }\n ]\n },\n \"serviceOptions\": [\n {\n \"code\": \"V1\",\n \"value\": \"云途预缴\"\n }\n ],\n \"courierOptions\": {\n \"yunexpress\": {\n \"sourceCode\": \"YT\",\n \"sensitiveType\": \"D\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-rr-apikey", "<api-key>")
req.Header.Add("x-rr-apitoken", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flexforwardship.com/labels")
.header("x-rr-apikey", "<api-key>")
.header("x-rr-apitoken", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"idempotencyKey\": \"unique-key-per-request\",\n \"courier\": \"yunexpress\",\n \"service\": {\n \"productCode\": \"HKMUZXR\"\n },\n \"label\": {\n \"format\": \"PDF\"\n },\n \"units\": {\n \"weight\": \"KG\",\n \"dimension\": \"CM\"\n },\n \"order\": {\n \"customerOrderNumber\": \"N-2026-05-27-TEST-03\",\n \"orderNumbers\": {\n \"platformOrderNumber\": \"platform-order-number\",\n \"referenceNumbers\": [\n \"ref-number-1\",\n \"ref-number-2\"\n ]\n }\n },\n \"shipment\": {\n \"shipTo\": {\n \"contact\": {\n \"firstName\": \"Alex\",\n \"lastName\": \"Smith\",\n \"phone\": 8554377467,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"18 Distribution Blvd\"\n ],\n \"city\": \"Edison\",\n \"state\": \"New jersey\",\n \"postalCode\": 8817,\n \"countryCode\": \"US\"\n }\n },\n \"shipFrom\": {\n \"contact\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"phone\": 886900676877,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"Habucho\"\n ],\n \"city\": \"Kishiwada-Shi\",\n \"state\": \"Osaka\",\n \"postalCode\": \"596-0825\",\n \"countryCode\": \"JP\"\n }\n },\n \"parcels\": [\n {\n \"weight\": 0.5,\n \"dimension\": {\n \"length\": 30,\n \"width\": 20,\n \"height\": 10\n },\n \"items\": [\n {\n \"descriptionEn\": \"Muji Ink pen\",\n \"descriptionLocal\": \"文具\",\n \"quantity\": 1,\n \"unitPrice\": {\n \"amount\": 29.99,\n \"currency\": \"USD\"\n },\n \"unitWeight\": 0.5\n }\n ]\n }\n ]\n },\n \"serviceOptions\": [\n {\n \"code\": \"V1\",\n \"value\": \"云途预缴\"\n }\n ],\n \"courierOptions\": {\n \"yunexpress\": {\n \"sourceCode\": \"YT\",\n \"sensitiveType\": \"D\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flexforwardship.com/labels")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-rr-apikey"] = '<api-key>'
request["x-rr-apitoken"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"idempotencyKey\": \"unique-key-per-request\",\n \"courier\": \"yunexpress\",\n \"service\": {\n \"productCode\": \"HKMUZXR\"\n },\n \"label\": {\n \"format\": \"PDF\"\n },\n \"units\": {\n \"weight\": \"KG\",\n \"dimension\": \"CM\"\n },\n \"order\": {\n \"customerOrderNumber\": \"N-2026-05-27-TEST-03\",\n \"orderNumbers\": {\n \"platformOrderNumber\": \"platform-order-number\",\n \"referenceNumbers\": [\n \"ref-number-1\",\n \"ref-number-2\"\n ]\n }\n },\n \"shipment\": {\n \"shipTo\": {\n \"contact\": {\n \"firstName\": \"Alex\",\n \"lastName\": \"Smith\",\n \"phone\": 8554377467,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"18 Distribution Blvd\"\n ],\n \"city\": \"Edison\",\n \"state\": \"New jersey\",\n \"postalCode\": 8817,\n \"countryCode\": \"US\"\n }\n },\n \"shipFrom\": {\n \"contact\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"phone\": 886900676877,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"Habucho\"\n ],\n \"city\": \"Kishiwada-Shi\",\n \"state\": \"Osaka\",\n \"postalCode\": \"596-0825\",\n \"countryCode\": \"JP\"\n }\n },\n \"parcels\": [\n {\n \"weight\": 0.5,\n \"dimension\": {\n \"length\": 30,\n \"width\": 20,\n \"height\": 10\n },\n \"items\": [\n {\n \"descriptionEn\": \"Muji Ink pen\",\n \"descriptionLocal\": \"文具\",\n \"quantity\": 1,\n \"unitPrice\": {\n \"amount\": 29.99,\n \"currency\": \"USD\"\n },\n \"unitWeight\": 0.5\n }\n ]\n }\n ]\n },\n \"serviceOptions\": [\n {\n \"code\": \"V1\",\n \"value\": \"云途预缴\"\n }\n ],\n \"courierOptions\": {\n \"yunexpress\": {\n \"sourceCode\": \"YT\",\n \"sensitiveType\": \"D\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "created",
"courier": "yunexpress",
"customerOrderNumber": "N-2026-05-27-TEST-03",
"courierOrderNumber": "YT2503010001",
"courierTrackingNumber": "YT2503010001CN",
"error": {
"code": "COURIER_ERROR",
"message": "YunExpress API returned HTTP 400: Bad request"
}
}{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "created",
"courier": "yunexpress",
"customerOrderNumber": "N-2026-05-27-TEST-03",
"courierOrderNumber": "YT2503010001",
"courierTrackingNumber": "YT2503010001CN",
"error": {
"code": "COURIER_ERROR",
"message": "YunExpress API returned HTTP 400: Bad request"
}
}{
"error": "Validation failed",
"details": [
{
"field": "service.productCode",
"message": "service.productCode is required"
}
]
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "created",
"courier": "yunexpress",
"customerOrderNumber": "N-2026-05-27-TEST-03",
"courierOrderNumber": "YT2503010001",
"courierTrackingNumber": "YT2503010001CN",
"error": {
"code": "COURIER_ERROR",
"message": "YunExpress API returned HTTP 400: Bad request"
}
}创建配送标签
为指定的物流商和货件详情创建配送标签。支持幂等创建 — 使用相同 idempotencyKey 重发请求将以 HTTP 200 返回原始结果,而不创建重复标签。
curl --request POST \
--url https://api.flexforwardship.com/labels \
--header 'Content-Type: application/json' \
--header 'x-rr-apikey: <api-key>' \
--header 'x-rr-apitoken: <api-key>' \
--data '
{
"idempotencyKey": "unique-key-per-request",
"courier": "yunexpress",
"service": {
"productCode": "HKMUZXR"
},
"label": {
"format": "PDF"
},
"units": {
"weight": "KG",
"dimension": "CM"
},
"order": {
"customerOrderNumber": "N-2026-05-27-TEST-03",
"orderNumbers": {
"platformOrderNumber": "platform-order-number",
"referenceNumbers": [
"ref-number-1",
"ref-number-2"
]
}
},
"shipment": {
"shipTo": {
"contact": {
"firstName": "Alex",
"lastName": "Smith",
"phone": 8554377467,
"email": "[email protected]"
},
"address": {
"streetLines": [
"18 Distribution Blvd"
],
"city": "Edison",
"state": "New jersey",
"postalCode": 8817,
"countryCode": "US"
}
},
"shipFrom": {
"contact": {
"firstName": "John",
"lastName": "Doe",
"phone": 886900676877,
"email": "[email protected]"
},
"address": {
"streetLines": [
"Habucho"
],
"city": "Kishiwada-Shi",
"state": "Osaka",
"postalCode": "596-0825",
"countryCode": "JP"
}
},
"parcels": [
{
"weight": 0.5,
"dimension": {
"length": 30,
"width": 20,
"height": 10
},
"items": [
{
"descriptionEn": "Muji Ink pen",
"descriptionLocal": "文具",
"quantity": 1,
"unitPrice": {
"amount": 29.99,
"currency": "USD"
},
"unitWeight": 0.5
}
]
}
]
},
"serviceOptions": [
{
"code": "V1",
"value": "云途预缴"
}
],
"courierOptions": {
"yunexpress": {
"sourceCode": "YT",
"sensitiveType": "D"
}
}
}
'import requests
url = "https://api.flexforwardship.com/labels"
payload = {
"idempotencyKey": "unique-key-per-request",
"courier": "yunexpress",
"service": { "productCode": "HKMUZXR" },
"label": { "format": "PDF" },
"units": {
"weight": "KG",
"dimension": "CM"
},
"order": {
"customerOrderNumber": "N-2026-05-27-TEST-03",
"orderNumbers": {
"platformOrderNumber": "platform-order-number",
"referenceNumbers": ["ref-number-1", "ref-number-2"]
}
},
"shipment": {
"shipTo": {
"contact": {
"firstName": "Alex",
"lastName": "Smith",
"phone": 8554377467,
"email": "[email protected]"
},
"address": {
"streetLines": ["18 Distribution Blvd"],
"city": "Edison",
"state": "New jersey",
"postalCode": 8817,
"countryCode": "US"
}
},
"shipFrom": {
"contact": {
"firstName": "John",
"lastName": "Doe",
"phone": 886900676877,
"email": "[email protected]"
},
"address": {
"streetLines": ["Habucho"],
"city": "Kishiwada-Shi",
"state": "Osaka",
"postalCode": "596-0825",
"countryCode": "JP"
}
},
"parcels": [
{
"weight": 0.5,
"dimension": {
"length": 30,
"width": 20,
"height": 10
},
"items": [
{
"descriptionEn": "Muji Ink pen",
"descriptionLocal": "文具",
"quantity": 1,
"unitPrice": {
"amount": 29.99,
"currency": "USD"
},
"unitWeight": 0.5
}
]
}
]
},
"serviceOptions": [
{
"code": "V1",
"value": "云途预缴"
}
],
"courierOptions": { "yunexpress": {
"sourceCode": "YT",
"sensitiveType": "D"
} }
}
headers = {
"x-rr-apikey": "<api-key>",
"x-rr-apitoken": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-rr-apikey': '<api-key>',
'x-rr-apitoken': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
idempotencyKey: 'unique-key-per-request',
courier: 'yunexpress',
service: {productCode: 'HKMUZXR'},
label: {format: 'PDF'},
units: {weight: 'KG', dimension: 'CM'},
order: {
customerOrderNumber: 'N-2026-05-27-TEST-03',
orderNumbers: {
platformOrderNumber: 'platform-order-number',
referenceNumbers: ['ref-number-1', 'ref-number-2']
}
},
shipment: {
shipTo: {
contact: {
firstName: 'Alex',
lastName: 'Smith',
phone: 8554377467,
email: '[email protected]'
},
address: {
streetLines: ['18 Distribution Blvd'],
city: 'Edison',
state: 'New jersey',
postalCode: 8817,
countryCode: 'US'
}
},
shipFrom: {
contact: {
firstName: 'John',
lastName: 'Doe',
phone: 886900676877,
email: '[email protected]'
},
address: {
streetLines: ['Habucho'],
city: 'Kishiwada-Shi',
state: 'Osaka',
postalCode: '596-0825',
countryCode: 'JP'
}
},
parcels: [
{
weight: 0.5,
dimension: {length: 30, width: 20, height: 10},
items: [
{
descriptionEn: 'Muji Ink pen',
descriptionLocal: '文具',
quantity: 1,
unitPrice: {amount: 29.99, currency: 'USD'},
unitWeight: 0.5
}
]
}
]
},
serviceOptions: [{code: 'V1', value: '云途预缴'}],
courierOptions: {yunexpress: {sourceCode: 'YT', sensitiveType: 'D'}}
})
};
fetch('https://api.flexforwardship.com/labels', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flexforwardship.com/labels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'idempotencyKey' => 'unique-key-per-request',
'courier' => 'yunexpress',
'service' => [
'productCode' => 'HKMUZXR'
],
'label' => [
'format' => 'PDF'
],
'units' => [
'weight' => 'KG',
'dimension' => 'CM'
],
'order' => [
'customerOrderNumber' => 'N-2026-05-27-TEST-03',
'orderNumbers' => [
'platformOrderNumber' => 'platform-order-number',
'referenceNumbers' => [
'ref-number-1',
'ref-number-2'
]
]
],
'shipment' => [
'shipTo' => [
'contact' => [
'firstName' => 'Alex',
'lastName' => 'Smith',
'phone' => 8554377467,
'email' => '[email protected]'
],
'address' => [
'streetLines' => [
'18 Distribution Blvd'
],
'city' => 'Edison',
'state' => 'New jersey',
'postalCode' => 8817,
'countryCode' => 'US'
]
],
'shipFrom' => [
'contact' => [
'firstName' => 'John',
'lastName' => 'Doe',
'phone' => 886900676877,
'email' => '[email protected]'
],
'address' => [
'streetLines' => [
'Habucho'
],
'city' => 'Kishiwada-Shi',
'state' => 'Osaka',
'postalCode' => '596-0825',
'countryCode' => 'JP'
]
],
'parcels' => [
[
'weight' => 0.5,
'dimension' => [
'length' => 30,
'width' => 20,
'height' => 10
],
'items' => [
[
'descriptionEn' => 'Muji Ink pen',
'descriptionLocal' => '文具',
'quantity' => 1,
'unitPrice' => [
'amount' => 29.99,
'currency' => 'USD'
],
'unitWeight' => 0.5
]
]
]
]
],
'serviceOptions' => [
[
'code' => 'V1',
'value' => '云途预缴'
]
],
'courierOptions' => [
'yunexpress' => [
'sourceCode' => 'YT',
'sensitiveType' => 'D'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-rr-apikey: <api-key>",
"x-rr-apitoken: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flexforwardship.com/labels"
payload := strings.NewReader("{\n \"idempotencyKey\": \"unique-key-per-request\",\n \"courier\": \"yunexpress\",\n \"service\": {\n \"productCode\": \"HKMUZXR\"\n },\n \"label\": {\n \"format\": \"PDF\"\n },\n \"units\": {\n \"weight\": \"KG\",\n \"dimension\": \"CM\"\n },\n \"order\": {\n \"customerOrderNumber\": \"N-2026-05-27-TEST-03\",\n \"orderNumbers\": {\n \"platformOrderNumber\": \"platform-order-number\",\n \"referenceNumbers\": [\n \"ref-number-1\",\n \"ref-number-2\"\n ]\n }\n },\n \"shipment\": {\n \"shipTo\": {\n \"contact\": {\n \"firstName\": \"Alex\",\n \"lastName\": \"Smith\",\n \"phone\": 8554377467,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"18 Distribution Blvd\"\n ],\n \"city\": \"Edison\",\n \"state\": \"New jersey\",\n \"postalCode\": 8817,\n \"countryCode\": \"US\"\n }\n },\n \"shipFrom\": {\n \"contact\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"phone\": 886900676877,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"Habucho\"\n ],\n \"city\": \"Kishiwada-Shi\",\n \"state\": \"Osaka\",\n \"postalCode\": \"596-0825\",\n \"countryCode\": \"JP\"\n }\n },\n \"parcels\": [\n {\n \"weight\": 0.5,\n \"dimension\": {\n \"length\": 30,\n \"width\": 20,\n \"height\": 10\n },\n \"items\": [\n {\n \"descriptionEn\": \"Muji Ink pen\",\n \"descriptionLocal\": \"文具\",\n \"quantity\": 1,\n \"unitPrice\": {\n \"amount\": 29.99,\n \"currency\": \"USD\"\n },\n \"unitWeight\": 0.5\n }\n ]\n }\n ]\n },\n \"serviceOptions\": [\n {\n \"code\": \"V1\",\n \"value\": \"云途预缴\"\n }\n ],\n \"courierOptions\": {\n \"yunexpress\": {\n \"sourceCode\": \"YT\",\n \"sensitiveType\": \"D\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-rr-apikey", "<api-key>")
req.Header.Add("x-rr-apitoken", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flexforwardship.com/labels")
.header("x-rr-apikey", "<api-key>")
.header("x-rr-apitoken", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"idempotencyKey\": \"unique-key-per-request\",\n \"courier\": \"yunexpress\",\n \"service\": {\n \"productCode\": \"HKMUZXR\"\n },\n \"label\": {\n \"format\": \"PDF\"\n },\n \"units\": {\n \"weight\": \"KG\",\n \"dimension\": \"CM\"\n },\n \"order\": {\n \"customerOrderNumber\": \"N-2026-05-27-TEST-03\",\n \"orderNumbers\": {\n \"platformOrderNumber\": \"platform-order-number\",\n \"referenceNumbers\": [\n \"ref-number-1\",\n \"ref-number-2\"\n ]\n }\n },\n \"shipment\": {\n \"shipTo\": {\n \"contact\": {\n \"firstName\": \"Alex\",\n \"lastName\": \"Smith\",\n \"phone\": 8554377467,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"18 Distribution Blvd\"\n ],\n \"city\": \"Edison\",\n \"state\": \"New jersey\",\n \"postalCode\": 8817,\n \"countryCode\": \"US\"\n }\n },\n \"shipFrom\": {\n \"contact\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"phone\": 886900676877,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"Habucho\"\n ],\n \"city\": \"Kishiwada-Shi\",\n \"state\": \"Osaka\",\n \"postalCode\": \"596-0825\",\n \"countryCode\": \"JP\"\n }\n },\n \"parcels\": [\n {\n \"weight\": 0.5,\n \"dimension\": {\n \"length\": 30,\n \"width\": 20,\n \"height\": 10\n },\n \"items\": [\n {\n \"descriptionEn\": \"Muji Ink pen\",\n \"descriptionLocal\": \"文具\",\n \"quantity\": 1,\n \"unitPrice\": {\n \"amount\": 29.99,\n \"currency\": \"USD\"\n },\n \"unitWeight\": 0.5\n }\n ]\n }\n ]\n },\n \"serviceOptions\": [\n {\n \"code\": \"V1\",\n \"value\": \"云途预缴\"\n }\n ],\n \"courierOptions\": {\n \"yunexpress\": {\n \"sourceCode\": \"YT\",\n \"sensitiveType\": \"D\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flexforwardship.com/labels")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-rr-apikey"] = '<api-key>'
request["x-rr-apitoken"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"idempotencyKey\": \"unique-key-per-request\",\n \"courier\": \"yunexpress\",\n \"service\": {\n \"productCode\": \"HKMUZXR\"\n },\n \"label\": {\n \"format\": \"PDF\"\n },\n \"units\": {\n \"weight\": \"KG\",\n \"dimension\": \"CM\"\n },\n \"order\": {\n \"customerOrderNumber\": \"N-2026-05-27-TEST-03\",\n \"orderNumbers\": {\n \"platformOrderNumber\": \"platform-order-number\",\n \"referenceNumbers\": [\n \"ref-number-1\",\n \"ref-number-2\"\n ]\n }\n },\n \"shipment\": {\n \"shipTo\": {\n \"contact\": {\n \"firstName\": \"Alex\",\n \"lastName\": \"Smith\",\n \"phone\": 8554377467,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"18 Distribution Blvd\"\n ],\n \"city\": \"Edison\",\n \"state\": \"New jersey\",\n \"postalCode\": 8817,\n \"countryCode\": \"US\"\n }\n },\n \"shipFrom\": {\n \"contact\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"phone\": 886900676877,\n \"email\": \"[email protected]\"\n },\n \"address\": {\n \"streetLines\": [\n \"Habucho\"\n ],\n \"city\": \"Kishiwada-Shi\",\n \"state\": \"Osaka\",\n \"postalCode\": \"596-0825\",\n \"countryCode\": \"JP\"\n }\n },\n \"parcels\": [\n {\n \"weight\": 0.5,\n \"dimension\": {\n \"length\": 30,\n \"width\": 20,\n \"height\": 10\n },\n \"items\": [\n {\n \"descriptionEn\": \"Muji Ink pen\",\n \"descriptionLocal\": \"文具\",\n \"quantity\": 1,\n \"unitPrice\": {\n \"amount\": 29.99,\n \"currency\": \"USD\"\n },\n \"unitWeight\": 0.5\n }\n ]\n }\n ]\n },\n \"serviceOptions\": [\n {\n \"code\": \"V1\",\n \"value\": \"云途预缴\"\n }\n ],\n \"courierOptions\": {\n \"yunexpress\": {\n \"sourceCode\": \"YT\",\n \"sensitiveType\": \"D\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "created",
"courier": "yunexpress",
"customerOrderNumber": "N-2026-05-27-TEST-03",
"courierOrderNumber": "YT2503010001",
"courierTrackingNumber": "YT2503010001CN",
"error": {
"code": "COURIER_ERROR",
"message": "YunExpress API returned HTTP 400: Bad request"
}
}{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "created",
"courier": "yunexpress",
"customerOrderNumber": "N-2026-05-27-TEST-03",
"courierOrderNumber": "YT2503010001",
"courierTrackingNumber": "YT2503010001CN",
"error": {
"code": "COURIER_ERROR",
"message": "YunExpress API returned HTTP 400: Bad request"
}
}{
"error": "Validation failed",
"details": [
{
"field": "service.productCode",
"message": "service.productCode is required"
}
]
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"error": "Shipping account not found",
"code": "COURIER_ERROR"
}{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "created",
"courier": "yunexpress",
"customerOrderNumber": "N-2026-05-27-TEST-03",
"courierOrderNumber": "YT2503010001",
"courierTrackingNumber": "YT2503010001CN",
"error": {
"code": "COURIER_ERROR",
"message": "YunExpress API returned HTTP 400: Bad request"
}
}请求体
创建配送标签的请求载荷。
创建配送标签的请求载荷。
客户端生成的唯一密钥,用于确保幂等标签创建。使用相同密钥重发请求将返回原始结果。
1 - 100"unique-key-per-request"
要使用的物流商代码。调用 GET /couriers 以列出您账户可用的有效物流商代码,然后传入其中一个返回的 code 值。
1"yunexpress"
物流商服务配置。
Show child attributes
Show child attributes
包含发件地、目的地及包裹的货件详情。
Show child attributes
Show child attributes
标签输出偏好设置。
Show child attributes
Show child attributes
重量与尺寸的计量单位。
Show child attributes
Show child attributes
订单参考信息。
Show child attributes
Show child attributes
跨境货件的报关信息。
Show child attributes
Show child attributes
以代码与值配对方式提供的额外服务选项。
Show child attributes
Show child attributes
危险品申报。
Show child attributes
Show child attributes
取件点配置。
Show child attributes
Show child attributes
物流商专属选项。
Show child attributes
Show child attributes
响应
标签创建请求的结果。
标签创建请求的结果。
唯一标签标识符。
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
标签创建结果 — created 或 failed。
created "created"
使用的物流商。
"yunexpress"
与此标签关联的客户订单编号。
"N-2026-05-27-TEST-03"
物流商分配的订单编号,失败时为 null。
"YT2503010001"
物流商分配的追踪编号,尚未获取时为 null。
"YT2503010001CN"
标签创建失败时的错误详情,否则为 null。
Show child attributes
Show child attributes