An online store on 1C-Bitrix started selling to Europe and immediately hit a wall with DHL as the sole carrier. Standard calculators don't support international rates, and manual calculation by switching to the DHL site takes 10 minutes per order. We automated the process: integration through the DHL Express API cuts the time to 1-2 seconds and eliminates input errors. Payback for such an upgrade is typically 3-4 months due to reduced manual labor.
What problems we solve
Real-time cost calculation. The DHL API returns the price considering weight, dimensions, destination country, and additional options. Without integration, managers manually go to the DHL site — that takes 5-10 minutes per order, and with a hundred orders a day, hours. Our integration speeds up the process 20x and completely eliminates rounding errors.
Shipment creation with label printing. The API generates an AWB number and PDF file for printing. Manually, you need to export data to a DHL form, download, and attach to the order. Integration reduces this to 30 seconds and automatically attaches the label to the order.
Tracking for the buyer. Without integration, customers have to track the package via a link on the DHL site — inconvenient. Built-in tracking in the personal account increases trust and reduces support load.
Customs declarations. International shipments require HS codes and an export declaration. Errors lead to customs delays. Integration automatically transfers data from product properties, reducing error risk by 95% and speeding up border clearance.
How to automate DHL cost calculation?
We use PHP 8.1+ and the guzzlehttp/guzzle library for HTTP requests. The delivery class inherits from \Bitrix\Sale\Delivery\Services\Base. Parameters are stored in b_sale_delivery_service_params. Example API request:
$ratesRequest = [ 'customerDetails' => [ 'shipperDetails' => [ 'postalCode' => '220004', 'cityName' => 'Minsk', 'countryCode' => 'BY', ], 'receiverDetails' => [ 'postalCode' => '10115', 'cityName' => 'Berlin', 'countryCode' => 'DE', ], ], 'accounts' => [['typeCode' => 'shipper', 'number' => $accountNumber]], 'productCode' => 'P', 'localProductCode' => 'P', 'packages' => [[ 'weight' => $weightKg, 'dimensions' => ['length' => 30, 'width' => 20, 'height' => 15], ]], 'plannedShippingDateAndTime' => date('Y-m-d\TH:i:s \G\M\T+0000'), 'unitOfMeasurement' => 'metric', ]; The response contains an array products with prices. We select the desired service and pass totalPrice to the customer.
How to configure DHL Express authentication in Bitrix?
Authentication is Basic Auth. Username and password are taken from the delivery service settings. For each request, they are sent in the Authorization: Basic base64(username:password) header. We do not store them in code — use a .env file or module parameters. According to the DHL Express API documentation, authentication is done via Basic Auth.
Typical errors when working with the DHL API
Common errors: incorrect receiver address format, missing customs data for international shipping, exceeding weight limit. The DHL Express API returns an error code in the XML response. We log all requests to bx_event_log for debugging. For testing, we use the DHL sandbox with dummy data — this helps catch issues before production launch.
Work process
- Analysis — determine DHL products (Express/Parcel/eCommerce), gather requirements for customs data.
- Design — develop delivery class, product property mapping, AWB number storage scheme.
- Implementation — write code for calculation, shipment creation, tracking, and pickup. Use component 2.0 and D7 ORM.
- Testing — test on a DHL test account, emulate different scenarios (shipment cancellation, customs error). Important to handle errors: invalid index or missing HS code should return a clear message.
- Deployment — configure tagged caching, background processing agents, monitoring.
What is included in the work
- Development of the delivery service class with cost calculation and label printing.
- Integration of tracking into the buyer's personal account (
sale.personal.ordercomponent). - Configuration of customs declarations with HS code mapping.
- Operation documentation: description of settings, error codes, update procedure.
- Employee training: how to test shipments, where to view logs.
- 2 weeks of support after launch — fixing possible bugs.
Comparison of DHL integration vs manual process
| Feature | Manual Work | DHL API Integration |
|---|---|---|
| Cost calculation time | 5–10 min | 1–2 sec |
| Shipment processing time | 10–15 min | 30–60 sec |
| Customs data errors | High probability | Automatic control |
| Customer tracking | Via link to DHL site | Built into personal account |
| Courier pickup request | Separate phone call | Button in admin panel |
Why choose us
We are a team with 10+ years of experience in Bitrix development. Completed over 50 integrations with DHL and other international carriers (including DHL Parcel). We use certified approaches: PHP 8.1, tagged caching, database migrations. We guarantee stable operation — every API request is logged, error monitoring is configured. Logistics cost savings can reach 30% through automation, and project payback is 3-4 months.
Estimated timelines
| Scope | Components | Time |
|---|---|---|
| Basic | Cost calculation + shipment creation + label printing | from 4 to 6 days |
| Extended | + Customs declarations with HS codes and Commercial Invoice | + 2–3 days |
| Full | + Tracking in buyer's personal account + automatic courier pickup request | + 2–3 days |
The cost is calculated individually for each task. Get a consultation on DHL integration for your store — contact us by email or Telegram. Tell us about your current processes — we'll advise which additional modules (1C exchange, fiscalization) are needed for full automation.

