Skip to content

Validation Errors

The SDK validates requests client-side before sending. A BigshipValidationError includes field-level error details:

import { BigshipValidationError } from "@agamya/bigship-sdk";
try {
await client.createOrder(orderPayload);
} catch (err) {
if (err instanceof BigshipValidationError) {
console.error("Validation failed:");
for (const [field, messages] of Object.entries(err.validationErrors)) {
console.error(` ${field}: ${messages.join(", ")}`);
}
}
}

B2B shipments require invoice_document_file and ewaybill_number. Omitting either triggers a validation error:

// ❌ Missing fields for B2B
await client.createOrder({
segment_type: "domestic_b2b",
// invoice_document_file: "...", // required for B2B
// ewaybill_number: "...", // required for B2B
// ...other fields
});

Ensure required fields are present for B2B orders.

Pincodes must be exactly 6 digits:

// ❌ Invalid
pincode: "11001" // 5 digits
pincode: "11001A" // contains letter
// ✅ Valid
pincode: "110001"

Duplicate Invoice ID → BigshipDuplicateInvoiceError

Section titled “Duplicate Invoice ID → BigshipDuplicateInvoiceError”

Reusing an invoice_id within the same account triggers BigshipDuplicateInvoiceError:

import { BigshipDuplicateInvoiceError } from "@agamya/bigship-sdk";
try {
await client.createOrder(orderPayload);
} catch (err) {
if (err instanceof BigshipDuplicateInvoiceError) {
console.error("Duplicate invoice:", err.message);
// Use a unique invoice_id
}
}

Generate unique invoice IDs (e.g., using uuid or a timestamp-based scheme).

For B2C orders, totalNumOfBoxes is restricted to 1:

// ❌ Invalid for B2C
await client.createOrder({
segment_type: "domestic_b2c",
totalNumOfBoxes: 3,
// ...
});
// ✅ Valid for B2C
await client.createOrder({
segment_type: "domestic_b2c",
totalNumOfBoxes: 1,
// ...
});

Prepaid Orders: collectableAmount Must Be 0

Section titled “Prepaid Orders: collectableAmount Must Be 0”

For prepaid orders, collectableAmount must be 0:

// ❌ Invalid for prepaid
await client.createOrder({
segment_type: "domestic_b2c",
MasterOrderPaymentMode: 1, // Prepaid
boxes: [{
products: [{
collectableAmount: 500,
// ...
}],
}],
});
// ✅ Valid for prepaid
await client.createOrder({
segment_type: "domestic_b2c",
MasterOrderPaymentMode: 1, // Prepaid
boxes: [{
products: [{
collectableAmount: 0,
// ...
}],
}],
});

For COD orders, set collectableAmount to the amount to collect from the customer.