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"
}
}Create a shipping label
Creates a shipping label for the specified courier and shipment details. Supports idempotent creation — replaying a request with the same idempotencyKey returns the original result with HTTP 200 instead of creating a duplicate.
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"
}
}Body
Request payload for creating a shipping label.
Request payload for creating a shipping label.
Client-generated unique key to ensure idempotent label creation. Replaying a request with the same key returns the original result.
1 - 100"unique-key-per-request"
Courier code to use. Call GET /couriers to list valid courier codes available to your account, then pass one of the returned code values.
1"yunexpress"
Courier service configuration.
Show child attributes
Show child attributes
Shipment details including origin, destination, and parcels.
Show child attributes
Show child attributes
Label output preferences.
Show child attributes
Show child attributes
Measurement units for weight and dimensions.
Show child attributes
Show child attributes
Order reference information.
Show child attributes
Show child attributes
Customs declaration information for cross-border shipments.
Show child attributes
Show child attributes
Additional service options as code-value pairs.
Show child attributes
Show child attributes
Dangerous goods declaration.
Show child attributes
Show child attributes
Pickup point configuration.
Show child attributes
Show child attributes
Courier-specific options.
Show child attributes
Show child attributes
Response
Result of a label creation request.
Result of a label creation request.
Unique label identifier.
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
Label creation outcome — created or failed.
created "created"
Courier service used.
"yunexpress"
Customer order number associated with this label.
"N-2026-05-27-TEST-03"
Order number assigned by the courier, or null on failure.
"YT2503010001"
Tracking number assigned by the courier, or null if not yet available.
"YT2503010001CN"
Error details if the label creation failed, otherwise null.
Show child attributes
Show child attributes