Create Shipping Label
Create a shipping label for a specific carrier and contract. The response includes the label in base64-encoded PDF and/or ZPL format, along with shipment details.
POST /shipping/create
Request
Headers
| Header | Value |
|---|---|
Authorization | Bearer <your_api_token> |
Content-Type | application/json |
Body Parameters
| Field | Type | Required | Description |
|---|---|---|---|
carrierCode | string | Yes | Carrier identifier (from /shipping/rates) |
contractCode | string | Yes | Contract code (from /shipping/rates) |
packages | Package[] | Yes | Array of package dimensions and weight |
shipFrom | Address | Yes | Sender address |
shipTo | Address | Yes | Recipient address |
notes | string | Yes | Shipment notes |
insuranceValue | number | Yes | Insurance value (use 0 for none) |
codValue | number | Yes | Cash-on-delivery value (use 0 for none) |
accessoriServices | object[] | Yes | Additional services (use [] for none) |
label_format | string | No | Label format: "PDF" or "ZPL" (default: "PDF") |
Package Object
| Field | Type | Required | Description |
|---|---|---|---|
length | number | Yes | Length in cm |
width | number | Yes | Width in cm |
height | number | Yes | Height in cm |
weight | number | Yes | Weight in kg |
Address Object
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Full name |
company | string | Yes | Company name |
street1 | string | Yes | Primary address line |
street2 | string | Yes | Secondary address line (can be empty string) |
city | string | Yes | City |
state | string | Yes | State/Province code |
postalCode | string | Yes | Postal/ZIP code |
country | string | Yes | 2-letter ISO country code (e.g. IT) |
phone | any | No | Phone number |
email | string | Yes | Email address |
Example
Request
{
"carrierCode": "brt",
"contractCode": "brt-Test",
"label_format": "PDF",
"packages": [
{
"length": 17,
"width": 25,
"height": 26,
"weight": 3
}
],
"shipFrom": {
"name": "Antonio Esposito",
"company": "Spedisci.Online",
"street1": "via guglielmo sanfelice 8",
"street2": "",
"city": "Napoli",
"state": "NA",
"postalCode": "80134",
"country": "IT",
"phone": null,
"email": "email@example.com"
},
"shipTo": {
"name": "Mario Rossi",
"company": "",
"street1": "Via Roma 2",
"street2": "",
"city": "Telese Terme",
"state": "BN",
"postalCode": "82037",
"country": "IT",
"phone": null,
"email": "email@example.com"
},
"notes": "test api",
"insuranceValue": 0,
"codValue": 0,
"accessoriServices": []
}Response Fields
| Field | Type | Description |
|---|---|---|
shipmentId | integer | Internal shipment identifier |
trackingNumber | string | Carrier tracking number |
shipmentCost | string | Total cost charged for the shipment |
packages | object[] | Array of package details |
packages[].pack_number | integer | Package sequence number |
packages[].reference | string|null | Package reference (nullable) |
labelData | string | Base64-encoded PDF label |
labelZPL | string | ZPL-format label string (for thermal printers) |
Using the Label
Node.js
const fs = require('fs')
// labelData is the base64 string from the API response
const pdfBuffer = Buffer.from(labelData, 'base64')
fs.writeFileSync('label.pdf', pdfBuffer)Use the carrierCode and contractCode values returned by Get Shipping Rates to select the desired carrier. Save the shipmentId — it is required to delete a label if needed.
Error Codes
| Code | Description |
|---|---|
200 | Successful operation — label created |
400 | Invalid order / bad request |
Last updated on