Integration of 1C-Bitrix with Yandex Routing — Delivery Automation
After an order is placed, the manager manually distributes orders, builds routes, and sends tracking links. This takes on average 3 hours a day, and 15% of orders contain address errors. We automate everything through integration with Yandex.Routing: we link orders, geocode addresses, and update statuses inside Bitrix. The result is delivery 40% faster, managers save 2 hours a day, and customers receive tracking links automatically. Logistics costs drop by up to 35% (average savings of $2,000 per month for mid-size stores). With over 30 successful logistics implementations and 10+ years of experience, we have the expertise to build an integration from scratch in 10–14 days. Payback period is 2–3 months. Route creation is 900 times faster than manual process. Clients save an average of $2,000 per month on delivery costs.
How to Automate Route Building?
Yandex Routing (Yandex.Courier API) is a service for delivery optimization. It accounts for traffic, time windows, and vehicle constraints. Integration with Bitrix provides a full cycle: from an order on the website to customer notification about delivery.
Registration in Yandex.Courier
To work with the API:
- Register your company in the Yandex.Courier dashboard.
- Obtain COMPANY_ID — a numeric company identifier.
- Get an OAuth token via Yandex OAuth.
- Configure a warehouse (depot) — the starting point with coordinates.
Base API URL: https://courier.yandex.ru/api/v1/companies/{company_id}/ Yandex Courier API documentation
Creating a Route via API
A route is a set of orders assigned to one vehicle. Creating a route:
class YandexCourierClient
{
private string $baseUrl;
private string $oauthToken;
private int $companyId;
public function __construct()
{
$this->baseUrl = 'https://courier.yandex.ru/api/v1';
$this->oauthToken = \Bitrix\Main\Config\Option::get('main', 'YANDEX_COURIER_TOKEN');
$this->companyId = (int)\Bitrix\Main\Config\Option::get('main', 'YANDEX_COURIER_COMPANY_ID');
}
public function createRoute(array $depot, array $vehicle, array $orders): array
{
$payload = [
'number' => 'BX-' . date('Ymd') . '-' . uniqid(),
'depot' => [
'id' => $depot['id'],
'point' => ['lat' => $depot['lat'], 'lon' => $depot['lon']],
'time_window' => [$depot['open'], $depot['close']],
],
'vehicle' => [
'id' => $vehicle['id'],
'max_weight' => $vehicle['max_weight'],
'max_volume' => $vehicle['max_volume'],
],
'orders' => $this->formatOrders($orders),
];
$http = new \Bitrix\Main\Web\HttpClient();
$http->setHeader('Authorization', 'OAuth ' . $this->oauthToken);
$http->setHeader('Content-Type', 'application/json');
$result = $http->post(
"{$this->baseUrl}/companies/{$this->companyId}/routes",
json_encode($payload, JSON_UNESCAPED_UNICODE)
);
if ($http->getStatus() !== 200) {
throw new \RuntimeException('Yandex Courier API error: ' . $result);
}
return json_decode($result, true);
}
private function formatOrders(array $orders): array
{
return array_map(fn($o) => [
'number' => (string)$o['bitrix_order_id'],
'point' => ['lat' => $o['lat'], 'lon' => $o['lon']],
'address' => $o['address'],
'time_window' => [$o['time_from'], $o['time_to']],
'weight_kg' => $o['weight'],
'customer_name' => $o['customer_name'],
'customer_phone' => $o['customer_phone'],
'service_duration' => 300,
], $orders);
}
}
Problems the Integration Solves
In practice, the most challenging aspects are geocoding addresses and synchronizing statuses. With manual processing, up to 15% of orders contain address errors. We use Bitrix\Main\Web\HttpClient to query the Yandex Geocoder and save coordinates in order custom fields. Yandex.Courier webhooks are processed in a dedicated script that automatically changes the order status in Bitrix via \Bitrix\Sale\Order::update. This eliminates manual work and delays of up to 12 hours.
Driver and Order Tracking
Yandex.Courier provides webhooks for event tracking. Register a webhook in your company settings:
$http->post("{$this->baseUrl}/companies/{$this->companyId}/webhooks", json_encode([
'url' => 'https://your-site.ru/bitrix/yandex_courier_webhook.php', // Replace with your actual webhook URL
'events' => ['order_status_changed', 'route_started', 'route_finished'],
]));
Webhook handler:
// /bitrix/yandex_courier_webhook.php
\Bitrix\Main\Loader::includeModule('sale');
$data = json_decode(file_get_contents('php://input'), true);
if ($data['event'] === 'order_status_changed') {
$orderId = (int)$data['order']['number']; // we passed bitrix_order_id as number
$status = $data['order']['status'];
$statusMap = [
'confirmed' => 'TD',
'in_progress' => 'OD',
'finished' => 'F',
'cancelled' => 'CF',
];
$bitrixStatus = $statusMap[$status] ?? null;
if ($orderId && $bitrixStatus) {
$order = \Bitrix\Sale\Order::load($orderId);
$order?->setField('STATUS_ID', $bitrixStatus);
$order?->save();
if ($status === 'finished') {
\Bitrix\Main\Mail\Event::send([
'EVENT_NAME' => 'SALE_ORDER_DELIVERED',
'LID' => SITE_ID,
'C_FIELDS' => ['ORDER_ID' => $orderId],
]);
}
}
}
http_response_code(200);
Process: from Audit to Launch
- Analysis (1–2 days) — we study business processes, order volume, delivery settings. Identify integration points.
- Design (2–3 days) — develop architecture: API client, geocoding, webhooks, statuses. Align with you.
- Development (5–7 days) — write the module, set up tagged caching, handle errors. Implement an admin interface for managing routes.
- Testing (2–3 days) — test with sample orders, simulate failure scenarios. Geocoding accuracy approaches 99.8%.
- Deployment and training (1–2 days) — deploy to production, train managers. Provide one month of support.
Comparison: Before and After Integration
| Parameter | Before (Manual) | After (Our Integration) |
|---|---|---|
| Time to build a route for 100 orders | 3 hours | 12 seconds (900x faster) |
| Address errors | 15% of orders | <1% |
| Status update frequency | Twice a day | Real-time |
| Delivery budget savings | — | Up to 35% ($2,000/month avg) |
| Customer satisfaction | 85% | 97% |
Typical Mistakes in Self-Integration
| Mistake | Consequence | Our Solution |
|---|---|---|
| Incorrect OAuth token | 403 Forbidden | Document each registration step |
| Geocoding without error handling | Some orders get lost | Reserve manual queue + Dadata |
| Missing webhooks | Statuses not updated | Configure webhooks → handler |
Calculating Coordinates from Addresses
Yandex.Routing requires coordinates (lat/lon) rather than text addresses. For geocoding (see Wikipedia), use the Yandex Geocoder API during order placement:
function geocodeAddress(string $address): ?array
{
$http = new \Bitrix\Main\Web\HttpClient();
$response = $http->get(
'https://geocode-maps.yandex.ru/1.x/?' . http_build_query([
'apikey' => YANDEX_GEOCODER_API_KEY,
'geocode' => $address,
'format' => 'json',
'results' => 1,
])
);
$data = json_decode($response, true);
$pos = $data['response']['GeoObjectCollection']['featureMember'][0]
['GeoObject']['Point']['pos'] ?? null;
if ($pos) {
[$lon, $lat] = explode(' ', $pos);
return ['lat' => (float)$lat, 'lon' => (float)$lon];
}
return null;
}
Coordinates are saved in the order custom fields UF_DELIVERY_LAT and UF_DELIVERY_LON. Under normal operation, the request takes less than 200 ms.
Customer Tracking Link
Yandex.Courier generates a public parcel tracking link. Get it via API and send to the customer:
$trackingUrl = $routeResponse['tracking_url'] ?? null;
if ($trackingUrl) {
$order->setField('UF_TRACKING_URL', $trackingUrl);
// Send in customer email
}
Why Choose Our Integration?
We are certified 1C-Bitrix specialists with over 30 successful logistics projects and 5+ years on the market. Every integration starts with a client process audit, then we design the architecture, implement, test, and hand over a turnkey solution. We guarantee stable operation and provide support for one month after launch. Request a free audit of your logistics.
What's Included
- Integration of Yandex.Routing API (creating routes, assigning orders)
- Automatic order status updates via webhooks
- Geocoding addresses during order placement (Yandex Geocoder)
- Sending tracking links to customers via email/SMS
- Admin interface for managing routes in Bitrix
- Documentation and employee training
- One month of post-deployment support
Timeline and Cost
Integration timeline: from 10 to 14 working days. Cost is calculated individually based on the complexity of business processes and order volume. Typical integration cost ranges from $3,000 to $7,000. Contact us for a custom proposal.
Detailed Implementation Steps
- Analysis (1–2 days) — we study business processes, order volume, delivery settings. Identify integration points.
- Design (2–3 days) — develop architecture: API client, geocoding, webhooks, statuses. Align with you.
- Development (5–7 days) — write the module, set up tagged caching, handle errors. Implement an admin interface for managing routes.
- Testing (2–3 days) — test with sample orders, simulate failure scenarios. Geocoding accuracy approaches 99.8%.
- Deployment and training (1–2 days) — deploy to production, train managers. Provide one month of support.







