MoySklad Integration with Website
MoySklad is a cloud system for managing goods, orders, and warehouse. Popular among small and medium businesses as alternative to 1C: simpler to configure, has convenient REST API, and doesn't require local server. Integration allows synchronizing catalog, stock, and orders.
MoySklad API
MoySklad provides REST API (JSON API 1.2). Authorization via Bearer token (Personal Access Token). Base URL: https://api.moysklad.ru/api/remap/1.2/.
$client = Http::withToken(env('MOYSKLAD_TOKEN'))
->baseUrl('https://api.moysklad.ru/api/remap/1.2/');
Product Synchronization
// Get product list with stock
$products = $client->get('entity/product', [
'limit' => 100,
'offset' => 0,
'expand' => 'productFolder,images'
])->json()['rows'];
foreach ($products as $p) {
Product::updateOrCreate(
['moysklad_id' => $p['id']],
[
'name' => $p['name'],
'sku' => $p['article'] ?? null,
'price' => $p['salePrices'][0]['value'] / 100, // MoySklad stores in kopecks
'category' => $p['productFolder']['name'] ?? null
]
);
}
Stock via Report
// Stock by warehouses
$stock = $client->get('report/stock/all', [
'stockMode' => 'positiveOnly'
])->json()['rows'];
foreach ($stock as $item) {
Product::where('moysklad_id', $item['meta']['href'])
->update(['stock' => $item['stock']]);
}
Creating Order in MoySklad
$order = $client->post('entity/customerorder', [
'organization' => ['meta' => [
'href' => "https://api.moysklad.ru/api/remap/1.2/entity/organization/{$orgId}",
'type' => 'organization'
]],
'agent' => ['meta' => [
'href' => "https://api.moysklad.ru/api/remap/1.2/entity/counterparty/{$agentId}",
'type' => 'counterparty'
]],
'positions' => array_map(fn($item) => [
'quantity' => $item->quantity,
'price' => $item->unit_price, // in kopecks
'assortment' => ['meta' => [
'href' => "https://api.moysklad.ru/api/remap/1.2/entity/product/{$item->moysklad_id}",
'type' => 'product'
]]
], $order->items->toArray())
])->json();
MoySklad Webhook
MoySklad supports webhooks on document changes (order updated, shipped). Subscribe via API:
$client->post('entity/webhook', [
'url' => 'https://yoursite.ru/webhooks/moysklad',
'action' => 'UPDATE',
'entityType' => 'customerorder'
]);
Ready Libraries
MoySklad has no official PHP SDK, but there are community libraries. Recommended to write thin wrapper over HTTP client — official API is well documented and rarely changes.
Integration Time: 4–7 days for bidirectional product, stock, and order synchronization.







