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": "NJ",
"postalCode": "08817",
"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": "NJ",
"postalCode": "08817",
"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: 'NJ',
postalCode: '08817',
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' => 'NJ',
'postalCode' => '08817',
'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\": \"NJ\",\n \"postalCode\": \"08817\",\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\": \"NJ\",\n \"postalCode\": \"08817\",\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\": \"NJ\",\n \"postalCode\": \"08817\",\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": null,
"error": null
}配送ラベルを作成する
指定した配送業者と出荷詳細で配送ラベルを作成します。冪等な作成をサポート — 同じ idempotencyKey と同じリクエスト本文でリクエストを再送すると、重複を作成せずに HTTP 200 で元の結果が返されます。異なるリクエスト本文で idempotencyKey を再利用した場合は、最初の結果を再生する代わりに 409 IDEMPOTENCY_CONFLICT が返されます。
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": "NJ",
"postalCode": "08817",
"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": "NJ",
"postalCode": "08817",
"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: 'NJ',
postalCode: '08817',
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' => 'NJ',
'postalCode' => '08817',
'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\": \"NJ\",\n \"postalCode\": \"08817\",\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\": \"NJ\",\n \"postalCode\": \"08817\",\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\": \"NJ\",\n \"postalCode\": \"08817\",\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": null,
"error": null
}ボディ
配送ラベル作成リクエストのペイロード。
配送ラベル作成リクエストのペイロード。
冪等なラベル作成を保証するためのクライアント生成の一意キー。同じキーでリクエストを再送すると元の結果が返されます。
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
レスポンス
冪等リプレイです。idempotencyKey は同じリクエスト本文ですでに使用されているため、最初の試行で保存された結果が返され、配送業者には再度送信されません。最初の試行が配送業者に拒否されていた場合、レスポンス本文の status は "failed" になることがあります。HTTP ステータスではなく、status フィールドで分岐してください。異なるリクエスト本文で idempotencyKey がすでに使用されている場合は、代わりに 409 IDEMPOTENCY_CONFLICT が返されます。
ラベル作成の試行結果です。201(作成成功)、502(配送業者による拒否)、およびそのいずれかの冪等リプレイである 200 で返されます。
一意のラベル識別子。
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
ラベル作成の結果です。created は配送業者がラベルを発行したこと、failed は配送業者がリクエストを拒否し、その試行結果が保存されたことを示します。冪等リプレイ(HTTP 200)では、結果は HTTP ステータスではなくこのフィールドで判断してください。
created, failed "created"
使用した配送業者。
"yunexpress"
このラベルの顧客注文番号です。order.customerOrderNumber に指定した値、または指定がない場合はシステム生成値が使用されます。アカウントごとに一意である必要があります。
"N-2026-05-27-TEST-03"
配送業者が付与した注文番号。失敗時は null。
"YT2503010001"
配送業者が付与した追跡番号。未取得の場合は null。
"LMTN2503010001XY"
status が failed の場合の配送業者エラー詳細です。status が created の場合は常に null です。
Show child attributes
Show child attributes