Skip to content

Documents

The Bigship API requires documents (invoices, e-waybills) to be submitted as base64 Data URIs. The SDK provides utilities to create and validate these strings.

Documents must be base64-encoded Data URIs in one of these formats:

data:application/pdf;base64,<base64-data>
data:image/jpeg;base64,<base64-data>
Document Field B2C B2B
Invoice invoice_document_file Required Required
E-Waybill ewaybill_document_file Not required Required
const order = await client.addSingleOrder({
// ...other fields
invoice_document_file: 'data:application/pdf;base64,JVBERi0xLjQK...',
});
const order = await client.addHeavyOrder({
// ...other fields
invoice_document_file: 'data:application/pdf;base64,JVBERi0xLjQK...',
ewaybill_number: '123456789012',
ewaybill_document_file: 'data:application/pdf;base64,JVBERi0xLjQK...',
});

In browser environments, convert a File object from a file input to a base64 Data URI:

const fileInput = document.querySelector<HTMLInputElement>('#invoice')!;
const file = fileInput.files[0];
const dataUri = await BigshipUtils.fileToBase64DataURI(file);
// "data:application/pdf;base64,..."
await client.addSingleOrder({
invoice_document_file: dataUri,
// ...other fields
});

Validate a string before sending it to the API:

const isValid = BigshipUtils.isValidBase64DataURI('data:application/pdf;base64,JVBERi0x...');
// true
const isInvalid = BigshipUtils.isValidBase64DataURI('not-a-data-uri');
// false

Use this to catch formatting errors early, especially when accepting user uploads.