Skip to content

Shipments

After creating an order, you need to manifest it (assign a courier) and then retrieve shipment documents.

import {
BigshipClient,
isSuccessResponse,
ShipmentDataType,
} from '@agamya/bigship-sdk';
await client.manifestSingle({
system_order_id: orderId,
courier_id: 5, // Delhivery Surface
});
await client.manifestHeavy({
system_order_id: orderId,
courier_id: 25,
});

Retrieve the AWB (Air Waybill) number for a manifested order.

const awb = await client.getAWB(orderId);
if (isSuccessResponse(awb) && awb.data && typeof awb.data !== 'string') {
console.log('AWB:', awb.data.master_awb); // "13090318586270"
console.log('Courier:', awb.data.courier_name); // "Delhivery"
}

Retrieve AWB, label, or manifest document by specifying a ShipmentDataType.

// Get AWB data
const awbResp = await client.getShipmentData(ShipmentDataType.AWB, orderId);
// Get label (base64 Data URI or URL)
const label = await client.getShipmentData(ShipmentDataType.LABEL, orderId);
if (isSuccessResponse(label) && typeof label.data === 'string') {
console.log('Label:', label.data.substring(0, 40) + '...');
}
// Get manifest document
const manifest = await client.getShipmentData(ShipmentDataType.MANIFEST, orderId);
if (isSuccessResponse(manifest) && typeof manifest.data === 'string') {
console.log('Manifest document available');
}
Value Description Return type
ShipmentDataType.AWB AWB number and courier info Object with master_awb, courier_name
ShipmentDataType.LABEL Shipping label Base64 Data URI string or URL
ShipmentDataType.MANIFEST Manifest document Base64 Data URI string or URL

Retrieve a shipment file (label or manifest) as a base64 string.

const labelFile = await client.getShipmentFile('label', orderId);
if (isSuccessResponse(labelFile) && typeof labelFile.data === 'string') {
console.log('Label file available');
}

Get All Shipment Details — getShipmentDetails

Section titled “Get All Shipment Details — getShipmentDetails”

Fetch AWB, label, and manifest in a single convenience call.

const details = await client.getShipmentDetails(orderId);
console.log(details.awb); // "13090318586270"
console.log(details.courierName); // "Delhivery"
console.log(details.labelData); // "data:application/pdf;base64,..."
console.log(details.manifestData); // "data:application/pdf;base64,..."

Manifest + AWB in One Call — manifestAndGetAWB

Section titled “Manifest + AWB in One Call — manifestAndGetAWB”

Manifest and retrieve the AWB number in a single call.

const { awb, courierName } = await client.manifestAndGetAWB(orderId, 5);
console.log(`AWB: ${awb}, Courier: ${courierName}`);

Create order, manifest, and get all documents with automatic AWB polling.

const result = await client.createAndFinalizeShipment({
order: orderPayload,
courierId: 5,
awbPollMaxAttempts: 5, // Poll up to 5 times (default: 5)
awbPollDelay: 3000, // Wait 3s between polls (default: 2000)
});
console.log(result.orderId);
console.log(result.awb);
console.log(result.courierName);
console.log(result.labelData);
console.log(result.manifestData);
const result = await client.workflow()
.create(orderPayload) // Create order
.withCourier(5) // Select courier
.manifest() // Manifest
.finalize(); // Get AWB + label + manifest
console.log(result.awb);
console.log(result.courierName);