B2B Shipment Lifecycle
B2B (Business to Business) shipments differ from B2C in several key ways. This guide covers the differences and walks through the full B2B flow.
B2C vs B2B Comparison
Section titled “B2C vs B2B Comparison”| | B2C | B2B |
||—|—|
| Order method | createOrder({ segment_type: 'domestic_b2c' }) | createOrder({ segment_type: 'domestic_b2b' }) |
| Manifest method | placeOrder | placeOrder |
| segment_type | 'domestic_b2c' | 'domestic_b2b' |
| ewaybill_number | Optional | Required |
| ewaybill_document_file | Optional | Required |
| totalNumOfBoxes | Must be 1 | Can be > 1 |
| Track by | trackOrder(orderId) | trackOrder(orderId) |
Imports
Section titled “Imports”import { BigshipClient, isSuccessResponse, isFailedResponse, ShipmentDataType,} from '@agamya/bigship-sdk';Full B2B Example
Section titled “Full B2B Example”Create B2B Order
Section titled “Create B2B Order”B2B orders require segment_type: 'domestic_b2b', an e-waybill number, and the e-waybill document. They can also have multiple boxes.
const order = await client.createOrder({ segment_type: 'domestic_b2b', MasterOrderPickUpLocation: 123456, MasterOrderReturnLocation: 123456, MasterOrderDate: new Date().toISOString().replace('T', ' ').substring(0, 19), MasterOrderPaymentMode: 1, OrderInvoiceNo: `B2B-${Date.now()}`, MasterOrderInvoiceAmount: 50000, totalNumOfBoxes: 2, ewaybill_number: '281012345678', ewaybill_document_file: 'data:application/pdf;base64,JVBERi0xLjQKJ...', MasterOrderShippingName: 'Priya Patel', MasterOrderShippingMobileNo: '9123456789', MasterOrderShippingEmail: 'priya@techcorp.com', MasterOrderShippingAddress: 'Tower B 5th Floor DLF Cyber City', MasterOrderShippingZipCode: '122002', MasterOrderShippingCity: 'DELHI', MasterOrderShippingState: 'DELHI', MasterOrderShippingCountry: 'India', boxes: [{ weight_unit: 'kg', dimension_unit: 'cm', noOfBoxes: 1, dimensions: [{ length: 40, breadth: 30, height: 25, weight: 5 }], products: [{ productName: 'Server Motherboard', qty: '1', amount: '25000', totalAmount: 25000, collectableAmount: 0, categoryId: '4', }], }, { weight_unit: 'kg', dimension_unit: 'cm', noOfBoxes: 1, dimensions: [{ length: 30, breadth: 20, height: 15, weight: 3 }], products: [{ productName: 'Network Switch', qty: '2', amount: '12500', totalAmount: 25000, collectableAmount: 0, categoryId: '4', }], }], invoice_document_file: 'data:application/pdf;base64,JVBERi0xLjQKJ...',});Manifest B2B Order
Section titled “Manifest B2B Order”Use placeOrder to manifest the order with a courier.
await client.placeOrder({ MasterCustomOrderId: orderId, courierId: 25, riskTypeId: '2', // Owner Risk});Get AWB and Label
Section titled “Get AWB and Label”Retrieve AWB and label using getOrderDetail and downloadDocument.
const details = await client.getOrderDetail(orderId);if (isSuccessResponse(details) && details.data) { console.log('AWB:', details.data.getOrderDetails.AwbNumber); console.log('Courier:', details.data.getOrderDetails.CourierName);}
const label = await client.downloadDocument(orderId, 'label');if (isSuccessResponse(label) && label.data) { console.log('Label URL:', label.data.AttachmentData);}Track by Order ID
Section titled “Track by Order ID”B2B shipments are tracked by trackOrder(orderId).
const tracking = await client.trackOrder(orderId);if (isSuccessResponse(tracking)) { console.log('Status:', tracking.data);}Cancel B2B Shipment
Section titled “Cancel B2B Shipment”await client.cancelOrder(orderId);Convenience: All-in-One
Section titled “Convenience: All-in-One”Use ShipmentWorkflow.execute() to create, manifest, and get documents in a single call:
const result = await ShipmentWorkflow.execute(client, { order: b2bOrderPayload, courierId: 25,});
console.log(result.orderId);