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