Integration of 1C-Bitrix with Dostavista delivery service
Dostavista is a crowdsourcing courier delivery service for the "last mile". Couriers operate in real time: requests are accepted within minutes, delivery is completed within hours. The API is open with Russian documentation. Used for stores with fast delivery: food, flowers, pharmaceuticals, electronics.
How Dostavista API works
Dostavista provides a REST API. Authorization is by token in the X-Authorizationtoken header. Main methods:
-
POST /api/business/v1/orders— create a delivery request -
GET /api/business/v1/orders/{id}— get request status -
DELETE /api/business/v1/orders/{id}— cancel request -
GET /api/business/v1/couriers/{id}/location— courier coordinates
The request contains route points (array points): point 0 — where to pick up (warehouse/store), points 1..N — customer delivery addresses. One Dostavista order can contain multiple delivery points — convenient for batch shipments.
Delivery module in Bitrix
A delivery service is connected via a class inheriting from \Bitrix\Sale\Delivery\Services\Base. Key methods:
-
calculateConcrete()— calculates delivery cost. CallsPOST /api/business/v1/orders/calculate-pricewith from/to address and weight. -
createDelivery()— creates an actual request when the order is confirmed by manager or automatically when status changes. -
OnSaleStatusOrderhandler — hook for order status change inb_sale_order.
Module parameters are stored in b_sale_delivery_service_params: API_TOKEN, SHOP_POINT_ADDRESS (warehouse address), AUTO_CREATE (create request automatically).
Delivery cost calculation
$response = $httpClient->post(
'https://robot.dostavista.ru/api/business/v1/orders/calculate-price',
[
'matter' => 'Product from store',
'weight_kg' => $weightKg,
'points' => [
['address' => $shopAddress],
[
'address' => $deliveryAddress,
'contact_person' => ['phone' => $phone],
],
],
],
['X-Authorizationtoken' => $apiToken]
);
$price = $response['order']['payment_amount'];
The response contains payment_amount — amount to pay in rubles (or local currency). If the address is not determined or is outside the coverage area, the API returns an error — we handle it as "delivery unavailable".
Creating a request when placing an order
The request is created either automatically when the customer selects the delivery method and confirms the order, or manually by the manager from the admin panel. The second option is preferable for stores where inventory verification is needed before sending.
In b_sale_order_props we save DOSTAVISTA_ORDER_ID — the identifier of the request in the Dostavista system. It is needed for:
- tracking the request status (polling or webhook)
- canceling the request when the order is canceled in Bitrix
- providing the customer with a link for courier tracking
Statuses and synchronization
Dostavista supports webhooks: when the request status changes, the system makes a POST request to the specified URL. Configured in the personal account. On the Bitrix side we create a handler that maps Dostavista statuses to order statuses:
| Dostavista Status | Bitrix Order Status |
|---|---|
awaiting_executor |
Sent for delivery |
active |
Courier in transit |
completed |
Delivered |
canceled |
Canceled |
failed |
Delivery failed |
If webhooks are unavailable (no white IP), we implement polling: Bitrix agent queries the status of active requests every 5–10 minutes via GET /api/business/v1/orders/{id}.
Courier tracking
Dostavista returns the courier.latitude/courier.longitude fields in the request during active delivery. For stores that need to show customers the courier's position on a map, we implement an AJAX endpoint on the Bitrix side — it proxies the request to the Dostavista API and returns coordinates.
Timeline
| Scope | Composition | Timeline |
|---|---|---|
| Basic integration | Cost calculation + request creation | 3–4 days |
| + Auto-creation + statuses | Status hook + mapping + polling | 5–6 days |
| + Courier tracking | AJAX endpoint + widget on site | +2 days |







