πŸš›Delivery FBS API

Complete FBS shipment lifecycle management and tracking

βœ… Implementation Complete
πŸš›

Carriage Management

Create, approve, and manage FBS shipments

πŸ“

Document Generation

PDF documents, acts, and waybills

πŸ“Š

Barcode System

Generate shipment and container barcodes

πŸ”

Status Tracking

Monitor shipment and document status

πŸ“±

Digital Acts

Digital waybill formation and retrieval

πŸ“š ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΠΈ πŸ“‘ ИндСкс API πŸš€ Быстрый старт ❓ FAQ

πŸ“‹ Methods Overview - 18 Endpoints

πŸš›
Carriage Management
7 methods
  • createCarriage - Create new FBS shipment
  • approveCarriage - Approve created shipment
  • cancelCarriage - Cancel existing shipment
  • getCarriage - Get carriage information
  • getCarriageDeliveryList - List delivery methods
  • setPostings - Modify carriage composition
  • getCarriageAvailableList - Available carriages
πŸ“
Documents & Acts
7 methods
  • createAct - Confirm shipment and create documents
  • checkActStatus - Check document status
  • getAct - Get PDF documents
  • getActPostings - Get postings list in act
  • getActList - Get acts list by shipments
  • checkDigitalActStatus - Check waybill status
  • getDigitalAct - Get digital shipment list PDF
πŸ“Š
Barcode & Labels
3 methods
  • getBarcode - Get shipment barcode image
  • getBarcodeText - Get barcode text value
  • getContainerLabels - Generate container labels
πŸ”§
Utility
1 method
  • splitPosting - Split order into separate postings

πŸ”„ Complete FBS Shipment Workflow

1

Create Carriage

Initialize new FBS shipment with delivery method and time window

2

Approve Carriage

Confirm carriage to change status to "Formed" and enable document generation

3

Create Act

Confirm shipment and initiate formation of transport waybill and barcode

4

Monitor Status

Check document formation status until all documents are ready

5

Get Documents & Barcode

Retrieve PDF documents, transport waybills, and barcode images

// Complete FBS Shipment Workflow
async function completeFbsShipmentWorkflow() {
  try {
    // Step 1: Create carriage
    const carriage = await deliveryFbsApi.createCarriage({
      delivery_method_id: 123,
      first_mile_from_time: '09:00',
      first_mile_to_time: '18:00'
    });
    
    const carriageId = carriage.result?.carriage_id;
    if (!carriageId) throw new Error('Failed to create carriage');
    
    // Step 2: Approve carriage
    const approved = await deliveryFbsApi.approveCarriage({
      carriage_id: carriageId
    });
    
    if (!approved.result) throw new Error('Failed to approve carriage');
    
    // Step 3: Create act and documents
    const act = await deliveryFbsApi.createAct({
      carriage_id: carriageId,
      posting_number: ['12345-0001-1', '12345-0002-1']
    });
    
    if (!act.result) throw new Error('Failed to create act');
    
    // Step 4: Wait for documents to be ready
    let status;
    do {
      await new Promise(resolve => setTimeout(resolve, 5000)); // Wait 5 seconds
      status = await deliveryFbsApi.checkActStatus({
        carriage_id: carriageId
      });
    } while (status.documents?.some(doc => doc.status === 'processing'));
    
    // Step 5: Get documents and barcode
    const [documents, barcode] = await Promise.all([
      deliveryFbsApi.getAct({
        carriage_id: carriageId,
        doc_type: 'act'
      }),
      deliveryFbsApi.getBarcode({
        carriage_id: carriageId
      })
    ]);
    
    console.log('FBS shipment workflow completed successfully');
    return {
      carriageId,
      actId: act.act_id,
      documents: documents.content,
      barcode: barcode.barcode
    };
    
  } catch (error) {
    console.error('FBS shipment workflow failed:', error);
    throw error;
  }
}

πŸ”‘ Key Method Examples

πŸš› Create and Approve Carriage

// Create new FBS carriage
const carriage = await deliveryFbsApi.createCarriage({
  delivery_method_id: 123,
  first_mile_from_time: '09:00',
  first_mile_to_time: '18:00'
});

if (carriage.result?.carriage_id) {
  console.log(`Carriage created: ${carriage.result.carriage_id}`);
  
  // Approve the carriage
  const approved = await deliveryFbsApi.approveCarriage({
    carriage_id: carriage.result.carriage_id
  });
  
  if (approved.result) {
    console.log('Carriage approved successfully');
    // Now you can get shipment list and barcode
  }
}

πŸ“ Document Management

// Create act and get documents
const act = await deliveryFbsApi.createAct({
  carriage_id: 12345,
  posting_number: ['12345-0001-1', '12345-0002-1']
});

// Check document status
const status = await deliveryFbsApi.checkActStatus({
  carriage_id: 12345
});

console.log(`Carriage status: ${status.carriage_status}`);
console.log(`Barcode status: ${status.barcode_status}`);
status.documents?.forEach(doc => {
  console.log(`${doc.type}: ${doc.status}`);
});

// Get PDF documents when ready
if (status.documents?.every(doc => doc.status === 'ready')) {
  const documents = await deliveryFbsApi.getAct({
    carriage_id: 12345,
    doc_type: 'act'
  });
  
  if (documents.content) {
    // Save PDF file from base64
    const docBuffer = Buffer.from(documents.content, 'base64');
    console.log(`Document received: ${documents.filename}`);
  }
}

πŸ“Š Barcode Generation

// Get barcode image and text
const [barcode, barcodeText] = await Promise.all([
  deliveryFbsApi.getBarcode({ carriage_id: 12345 }),
  deliveryFbsApi.getBarcodeText({ carriage_id: 12345 })
]);

if (barcode.barcode) {
  // Save barcode image from base64
  const barcodeBuffer = Buffer.from(barcode.barcode, 'base64');
  console.log(`Barcode image: ${barcode.content_type}`);
}

if (barcodeText.barcode_text) {
  console.log(`Barcode text: ${barcodeText.barcode_text}`);
}

🎯 Best Practices

Error Handling

Always check for successful results and implement proper error handling for each step of the workflow.

async function robustCarriageOperation(carriageId: number) {
  try {
    const result = await deliveryFbsApi.approveCarriage({
      carriage_id: carriageId
    });
    
    if (!result.result) {
      throw new Error('Carriage approval failed');
    }
    
    return result;
  } catch (error) {
    if (error.message.includes('not found')) {
      console.error(`Carriage ${carriageId} not found`);
    } else if (error.message.includes('already approved')) {
      console.warn(`Carriage ${carriageId} already approved`);
    }
    throw error;
  }
}
Status Polling

Use intelligent polling with exponential backoff to monitor document formation status.

async function waitForDocumentReady(carriageId: number, maxAttempts = 30) {
  let attempts = 0;
  
  while (attempts < maxAttempts) {
    const status = await deliveryFbsApi.checkActStatus({
      carriage_id: carriageId
    });
    
    const allReady = status.documents?.every(doc => 
      doc.status === 'ready' || doc.status === 'error'
    );
    
    if (allReady) {
      return status;
    }
    
    attempts++;
    await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
  }
  
  throw new Error(`Documents not ready after ${maxAttempts} attempts`);
}
Batch Processing

Use batch operations with rate limiting for processing multiple carriages efficiently.

class DeliveryFbsManager {
  private readonly batchSize = 10;
  
  async processBatchOperations(carriageIds: number[]) {
    const batches = [];
    for (let i = 0; i < carriageIds.length; i += this.batchSize) {
      batches.push(carriageIds.slice(i, i + this.batchSize));
    }
    
    const results = [];
    for (const batch of batches) {
      const batchResults = await Promise.allSettled(
        batch.map(id => this.processCarriage(id))
      );
      results.push(...batchResults);
      
      // Rate limiting - wait between batches
      await new Promise(resolve => setTimeout(resolve, 1000));
    }
    
    return results;
  }
}

πŸ“Š API Endpoints Reference

Method Endpoint Description
πŸš› Carriage Management
POST createCarriage /v1/carriage/create Create new FBS shipment
POST approveCarriage /v1/carriage/approve Approve created shipment
POST cancelCarriage /v1/carriage/cancel Cancel existing shipment
POST getCarriage /v1/carriage/get Get carriage information
POST getCarriageDeliveryList /v1/carriage/delivery/list List delivery methods and carriages
POST setPostings /v1/carriage/set-postings Modify carriage composition
POST getCarriageAvailableList /v1/posting/carriage-available/list Get available carriages
πŸ“ Documents & Acts
POST createAct /v2/posting/fbs/act/create Create documents
POST checkActStatus /v2/posting/fbs/act/check-status Check document status
POST getAct /v2/posting/fbs/act/get-pdf Get PDF documents
POST getActPostings /v2/posting/fbs/act/get-postings Get postings in act
POST getActList /v2/posting/fbs/act/list Get acts list
POST checkDigitalActStatus /v2/posting/fbs/digital/act/check-status Check waybill status
POST getDigitalAct /v2/posting/fbs/digital/act/get-pdf Get digital waybill
πŸ“Š Barcodes & Labels
POST getBarcode /v2/posting/fbs/act/get-barcode Get barcode image
POST getBarcodeText /v2/posting/fbs/act/get-barcode/text Get barcode text
POST getContainerLabels /v2/posting/fbs/act/get-container-labels Get container labels
πŸ”§ Utilities
POST splitPosting /v1/posting/fbs/split Split posting