Label Order
Overview
The Label Printing Endpoint allows users to generate and print shipping labels (resis) for their orders. This feature supports both bulk printing and different label formats to accommodate various shipping and logistical needs.
Users can request labels for one or multiple orders by providing the order number(s). Additionally, they can specify the label format and page size based on their printer type and operational requirements.
Key Feature
✅ Orders Must Be Eligible → Only orders ready for shipment can have labels printed.
✅ Bulk Printing Supported → Multiple orders can be processed in a single request.
✅ Correct Page Format Required → Users must specify a valid page type for label generation.
Use Cases for Label Printing
✅ E-commerce Sellers → Quickly generate shipping labels for multiple orders.
✅ Warehouses & Fulfillment Centers → Automate bulk label printing.
✅ Courier Management → Standardize label formats for efficient logistics.
By using the Label Printing Endpoint, businesses can streamline their order processing, reduce manual errors, and improve shipping efficiency. 🚀
How it Works
Once an order is created and the pickup is successfully scheduled, the next critical step is to generate a shipping label — a document used by logistics partners to track, transport, and deliver the package. This is done through the POST /label-order endpoint.
From a business perspective, here’s how the process flows:
- Order Confirmation: A customer places an order through your platform. This order is recorded in the system using the store-order API.
- Pickup Scheduled: Once the order is confirmed, your system schedules a pickup with the selected logistics provider using the pickup-order endpoint. This ensures the courier knows when and where to collect the package.
- Label Generation: After the pickup is scheduled, the label-order endpoint is called to generate the shipping label. This label includes the AWB (Air Waybill) number and essential delivery details. It serves as a ticket for the courier to recognize and deliver the parcel.
- Download & Attach: The label is returned in PDF format and should be downloaded and printed. The merchant or warehouse team then attaches this label to the package before handing it over to the courier.
- Package Ready for Delivery: Once labeled, the package is fully ready for pickup and delivery, ensuring a smooth handoff to logistics and end-to-end traceability.
Why It Matters for Business
- Ensures traceability with valid AWB numbers.
- Reduces manual errors during order processing.
- Improves delivery reliability by aligning with logistics partner requirements.
- Keeps your operations scalable and automated.
Request Body
- cURL
- JavaScript
- PHP
- GoLang
- Node
curl --location --request POST 'https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/print-label?page=page_5&order_no=KOMXXXXXXXXXXXXXXXXX' \
--header 'x-api-key: inputapikey'
const myHeaders = new Headers();
myHeaders.append("x-api-key", "inputapikey");
const requestOptions = {
method: "POST",
headers: myHeaders,
redirect: "follow"
};
fetch("https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/print-label?page=page_5&order_no=KOMXXXXXXXXXXXXXXXXX", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/print-label?page=page_5&order_no=KOMXXXXXXXXXXXXXXXXX',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'x-api-key: inputapikey'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/print-label?page=page_5&order_no=KOMXXXXXXXXXXXXXXXXX"
method := "POST"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("x-api-key", "inputapikey")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
const axios = require('axios');
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api-sandbox.collaborator.komerce.id/order/api/v1/orders/print-label?page=page_5&order_no=KOMXXXXXXXXXXXXXXXXX',
headers: {
'x-api-key': 'inputapikey'
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Query Parameter
Headers
Key | Type | Description |
---|---|---|
x-api-key * | string | this Value contain an secret APIKEY identic for Shipping API. |
Query Param
Key | Type | Description |
---|---|---|
page * | string | The label format and page size for printing. Options include: page_1 (A4 size, 1 label per page), page_2 (A4 size, 2 labels per page), page_4 (A4 size, 4 labels per page (A6 format)), page_5 (Thermal size 10cm x 10cm), and page_6 (Thermal size 10cm x 15cm) |
order_no * | string | The order number(s) to generate labels for. Multiple orders can be specified using a comma separator (,). |
For each header and parameter that has a *
sign, it is a parameter that must be Required when making a request, otherwise there will be a system error that will warn the user regarding the request made.
Response
Response Structure
Key | Value (Description) |
---|---|
meta.message | Message indicating the result of the API request. |
meta.code | HTTP status code representing the request status. |
meta.status | Status of the API response (e.g., success or error). |
data.path | Order label storage location |
data.base_64 | Binary code to generate the label file |
Success Respons for Get Order Label
{
"meta": {
"message": "Generate Print Label success",
"code": 200,
"status": "success"
},
"data": {
"path": "/storage/label-DD-MM-YYY-00-00-00000000000.pdf",
"base_64": "{{ long_base_64 }}
}
}
If want to download shipping label request result file, you need to understand that it is necessary to add the /order
path before /storage/label-DD-MM-YYY-00-00-00000000000.pdf
.
Error Respons for Get Order Label
{
"meta": {
"message": "Generate Print Label failed",
"code": 500,
"status": "error"
},
"data": "order_no not found"
}
Error Code
Code | Status | Description | How to Fix |
---|---|---|---|
200 | Success | Success generate print label | |
401 | Unauthorized | API key invalid or missing from parameter | Make sure your API key is valid using your Account |
422 | Error | Generate print label failed | Ensure that the query parameters of the given request are appropriate |
500 | Generate print label failed | order_no not found | Make sure the order_no requested to generate the label matches the data you have. |
Tips to Avoid Error
- Ensure Pickup is Scheduled: Before generating a label, confirm that the pickup has been successfully scheduled using the POST /pickup-order endpoint.
- Use a Valid order_no: Verify that the order_no provided exists and corresponds to an order that has completed the pickup scheduling process.
- Avoid Duplicate Label Requests: Once a label has been generated for an order, refrain from making additional label generation requests for the same order to prevent duplication errors.
- Check Order Status: Labels can only be generated for orders that are in the appropriate status (e.g., “Pickup Scheduled”). Attempting to generate a label for an order in an incorrect status will result in an error.
- Validate API Token: Ensure that your API token is valid and has the necessary permissions to perform label generation operations.
- Handle Errors Gracefully: Implement error handling in your application to manage scenarios where label generation fails, such as displaying user-friendly messages or retrying the operation as appropriate.