{
  "info": {
    "name": "Kontrum Universal Integration API 2.0",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api.kontrum.kz"
    },
    {
      "key": "connectorToken",
      "value": ""
    },
    {
      "key": "commandId",
      "value": ""
    },
    {
      "key": "accessToken",
      "value": ""
    },
    {
      "key": "warehouseId",
      "value": ""
    },
    {
      "key": "productVariantId",
      "value": ""
    },
    {
      "key": "warehouseDocumentId",
      "value": ""
    },
    {
      "key": "warehouseDocumentVersion",
      "value": "1"
    },
    {
      "key": "warehouseDocumentLineId",
      "value": ""
    },
    {
      "key": "reservationId",
      "value": ""
    },
    {
      "key": "orderId",
      "value": ""
    },
    {
      "key": "installationId",
      "value": ""
    },
    {
      "key": "snapshotId",
      "value": ""
    },
    {
      "key": "warehouseExternalId",
      "value": "wh-postman-001"
    },
    {
      "key": "productVariantExternalId",
      "value": "variant-postman-001"
    }
  ],
  "item": [
    {
      "name": "Schema",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v2/schema"
      }
    },
    {
      "name": "Register profile",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{connectorToken}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"protocolVersion\": \"2.0\",\n  \"adapter\": {\"name\":\"Kontrum Adapter\",\"version\":\"1.0.0\",\"platform\":\"1C:Enterprise\",\"configurationName\":\"Configuration\"},\n  \"entities\": {\"order\": {\"read\":true,\"write\":true,\"realtime\":true,\"fields\":[\"status\",\"comment\"]}},\n  \"features\": {\"callback\":true,\"polling\":true,\"batch\":true}\n}"
        },
        "url": "{{baseUrl}}/api/v2/connectors/profile"
      }
    },
    {
      "name": "Send batch",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{connectorToken}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"batchId\": \"test-1\",\n  \"items\": [{\"schemaVersion\":\"1.0\",\"entity\":\"order\",\"externalId\":\"Document.Order:uuid\",\"version\":0,\"data\":{\"number\":\"1\",\"date\":\"2026-08-04T10:00:00Z\",\"channel\":\"Site\",\"status\":\"New\"}}]\n}"
        },
        "url": "{{baseUrl}}/api/v2/connectors/entities/batch"
      }
    },
    {
      "name": "Get commands",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{connectorToken}}"
          }
        ],
        "url": "{{baseUrl}}/api/v2/connectors/commands?limit=50"
      }
    },
    {
      "name": "Command result",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{connectorToken}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"status\": \"completed\",\n  \"newVersion\": 2\n}"
        },
        "url": "{{baseUrl}}/api/v2/connectors/commands/{{commandId}}/result"
      }
    },
    {
      "name": "Warehouse — user API",
      "description": "Работа со складом из кабинета. Выполняйте запросы сверху вниз: коллекция автоматически сохраняет warehouseId, productVariantId, documentId и reservationId.",
      "item": [
        {
          "name": "1. Access and settings",
          "item": [
            {
              "name": "Check warehouse access",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Доступ к складу получен\", () => pm.expect(pm.response.code).to.eql(200));",
                      "const j=pm.response.json(); const d=j.data||j; if(d.installationId) pm.collectionVariables.set(\"installationId\", d.installationId);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "description": "Показывает источник данных: ручной режим или интеграция 1С.",
                "url": "{{baseUrl}}/api/v1/warehouse/access"
              },
              "response": []
            },
            {
              "name": "Get warehouse settings",
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/settings"
              },
              "response": []
            },
            {
              "name": "Update warehouse settings",
              "request": {
                "method": "PATCH",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"allowNegativeStock\": false\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/settings"
              },
              "response": []
            }
          ]
        },
        {
          "name": "2. Warehouses and stock",
          "item": [
            {
              "name": "List warehouses",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = (d.items && d.items[0] && d.items[0].id) || (Array.isArray(d) && d[0] && d[0].id);",
                      "if (value) pm.collectionVariables.set('warehouseId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/warehouses?page=1&limit=50"
              },
              "response": []
            },
            {
              "name": "Create warehouse (manual mode)",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = d.id || (d.warehouse && d.warehouse.id);",
                      "if (value) pm.collectionVariables.set('warehouseId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"name\": \"Основной склад\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/warehouses"
              },
              "response": []
            },
            {
              "name": "List product variants",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = (d.items && d.items[0] && d.items[0].id) || (Array.isArray(d) && d[0] && d[0].id);",
                      "if (value) pm.collectionVariables.set('productVariantId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/product-variants?page=1&limit=50"
              },
              "response": []
            },
            {
              "name": "Manual stock import",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = (d.items && d.items[0] && (d.items[0].productVariantId || d.items[0].id)) || d.productVariantId;",
                      "if (value) pm.collectionVariables.set('productVariantId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"warehouseId\": \"{{warehouseId}}\",\n  \"rows\": [\n    {\n      \"sku\": \"SKU-001\",\n      \"name\": \"Товар\",\n      \"unit\": \"шт\",\n      \"quantity\": 12\n    }\n  ]\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/manual-import"
              },
              "response": []
            },
            {
              "name": "List balances",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = (d.items && d.items[0] && d.items[0].productVariantId) || (Array.isArray(d) && d[0] && d[0].productVariantId);",
                      "if (value) pm.collectionVariables.set('productVariantId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/balances?page=1&limit=50&warehouseId={{warehouseId}}"
              },
              "response": []
            },
            {
              "name": "Check availability",
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/availability?warehouseId={{warehouseId}}&productVariantId={{productVariantId}}&quantity=1"
              },
              "response": []
            }
          ]
        },
        {
          "name": "3. Movements",
          "item": [
            {
              "name": "Create stock adjustment",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"warehouseId\": \"{{warehouseId}}\",\n  \"productVariantId\": \"{{productVariantId}}\",\n  \"movementType\": \"adjustment\",\n  \"quantityDelta\": 1,\n  \"sourceType\": \"postman\",\n  \"sourceId\": \"movement-{{$timestamp}}\",\n  \"metadata\": {\n    \"note\": \"Postman example\"\n  }\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/movements"
              },
              "response": []
            },
            {
              "name": "List movements",
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/movements?page=1&limit=50&warehouseId={{warehouseId}}"
              },
              "response": []
            }
          ]
        },
        {
          "name": "4. Reservations",
          "item": [
            {
              "name": "List reservations",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = (d.items && d.items[0] && d.items[0].id) || (Array.isArray(d) && d[0] && d[0].id);",
                      "if (value) pm.collectionVariables.set('reservationId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/reservations?page=1&limit=50"
              },
              "response": []
            },
            {
              "name": "Create reservation",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = d.id || (d.reservation && d.reservation.id);",
                      "if (value) pm.collectionVariables.set('reservationId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "description": "Перед запуском задайте orderId существующего заказа UUID.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"orderId\": \"{{orderId}}\",\n  \"lineKey\": \"1\",\n  \"warehouseId\": \"{{warehouseId}}\",\n  \"productVariantId\": \"{{productVariantId}}\",\n  \"quantity\": 1,\n  \"reason\": \"order_created\",\n  \"metadata\": {\n    \"source\": \"postman\"\n  }\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/reservations"
              },
              "response": []
            },
            {
              "name": "Adjust reservation",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"quantity\": 2,\n  \"reason\": \"postman_adjustment\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/reservations/{{reservationId}}/adjust"
              },
              "response": []
            },
            {
              "name": "Consume reservation",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"order_fulfilled\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/reservations/{{reservationId}}/consume"
              },
              "response": []
            },
            {
              "name": "Release reservation",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"order_cancelled\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/reservations/{{reservationId}}/release"
              },
              "response": []
            },
            {
              "name": "Expire reservation",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"reservation_timeout\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/reservations/{{reservationId}}/expire"
              },
              "response": []
            }
          ]
        },
        {
          "name": "5. Documents",
          "item": [
            {
              "name": "List warehouse documents",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                      "const j = pm.response.json(); const d = j.data || j;",
                      "const value = (d.items && d.items[0] && d.items[0].id) || (Array.isArray(d) && d[0] && d[0].id);",
                      "if (value) pm.collectionVariables.set('warehouseDocumentId', value);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/documents?page=1&limit=50"
              },
              "response": []
            },
            {
              "name": "Create goods receipt",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "pm.test(\"Документ создан\", () => pm.expect(pm.response.code).to.be.oneOf([200,201]));",
                      "const j=pm.response.json(); const d=j.data||j; const doc=d.document||d;",
                      "if(doc.id) pm.collectionVariables.set(\"warehouseDocumentId\",doc.id);",
                      "if(doc.version!==undefined) pm.collectionVariables.set(\"warehouseDocumentVersion\",doc.version);",
                      "if(doc.lines&&doc.lines[0]) pm.collectionVariables.set(\"warehouseDocumentLineId\",doc.lines[0].id||doc.lines[0].lineId);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"documentType\": \"goods_receipt\",\n  \"number\": \"POSTMAN-{{$timestamp}}\",\n  \"destinationWarehouseId\": \"{{warehouseId}}\",\n  \"reason\": \"Postman example\",\n  \"metadata\": {\n    \"source\": \"postman\"\n  },\n  \"lines\": [\n    {\n      \"lineKey\": \"1\",\n      \"productVariantId\": \"{{productVariantId}}\",\n      \"quantity\": 5,\n      \"metadata\": {}\n    }\n  ]\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/documents"
              },
              "response": []
            },
            {
              "name": "Get warehouse document",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "type": "text/javascript",
                    "exec": [
                      "const j=pm.response.json(); const d=j.data||j; const doc=d.document||d; if(doc.version!==undefined) pm.collectionVariables.set(\"warehouseDocumentVersion\",doc.version); if(doc.lines&&doc.lines[0]) pm.collectionVariables.set(\"warehouseDocumentLineId\",doc.lines[0].id||doc.lines[0].lineId);"
                    ]
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/documents/{{warehouseDocumentId}}"
              },
              "response": []
            },
            {
              "name": "Receive document",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"goods_received\",\n  \"lines\": [\n    {\n      \"lineId\": \"{{warehouseDocumentLineId}}\",\n      \"quantity\": 5\n    }\n  ]\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/documents/{{warehouseDocumentId}}/receive"
              },
              "response": []
            },
            {
              "name": "Count document",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"inventory_count\",\n  \"lines\": [\n    {\n      \"lineId\": \"{{warehouseDocumentLineId}}\",\n      \"quantity\": 5\n    }\n  ]\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/documents/{{warehouseDocumentId}}/count"
              },
              "response": []
            },
            {
              "name": "Dispatch document",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"goods_dispatched\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/documents/{{warehouseDocumentId}}/dispatch"
              },
              "response": []
            },
            {
              "name": "Post document",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"post_document\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/documents/{{warehouseDocumentId}}/post"
              },
              "response": []
            },
            {
              "name": "Reverse document",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"reason\": \"reverse_document\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/documents/{{warehouseDocumentId}}/reverse"
              },
              "response": []
            }
          ]
        },
        {
          "name": "6. Maintenance and 1C sync",
          "item": [
            {
              "name": "Warehouse reconciliation",
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  }
                ],
                "url": "{{baseUrl}}/api/v1/warehouse/reconcile"
              },
              "response": []
            },
            {
              "name": "Import baseline",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/baseline/import"
              },
              "response": []
            },
            {
              "name": "Rebuild warehouse projections",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/warehouse/rebuild"
              },
              "response": []
            },
            {
              "name": "Request full sync from 1C",
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "Authorization",
                    "value": "Bearer {{accessToken}}",
                    "type": "text"
                  },
                  {
                    "key": "Idempotency-Key",
                    "value": "postman-{{$guid}}",
                    "type": "text"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json",
                    "type": "text"
                  }
                ],
                "description": "Создаёт команду полной синхронизации для подключённого коннектора 1С.",
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"installationId\": \"{{installationId}}\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": "{{baseUrl}}/api/v1/sync/request-full"
              },
              "response": []
            }
          ]
        }
      ]
    },
    {
      "name": "Warehouse — connector API (1C)",
      "description": "Примеры выгрузки справочников складов, товаров, остатков, движений и документов из 1С. Для stockBalance сначала запустите snapshot.",
      "item": [
        {
          "name": "Register warehouse connector profile",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"protocolVersion\": \"2.0\",\n  \"adapter\": {\n    \"name\": \"Kontrum 1C Warehouse Adapter\",\n    \"version\": \"1.0.0\",\n    \"platform\": \"1C:Enterprise\",\n    \"configurationName\": \"Configuration\"\n  },\n  \"entities\": {\n    \"warehouse\": {\n      \"read\": true,\n      \"write\": true\n    },\n    \"productVariant\": {\n      \"read\": true,\n      \"write\": true\n    },\n    \"stockBalance\": {\n      \"read\": true,\n      \"write\": true\n    },\n    \"stockMovement\": {\n      \"read\": true,\n      \"write\": true\n    },\n    \"warehouseDocument\": {\n      \"read\": true,\n      \"write\": true\n    }\n  },\n  \"features\": {\n    \"callback\": true,\n    \"polling\": true,\n    \"batch\": true,\n    \"snapshot\": true\n  }\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/profile"
          },
          "response": []
        },
        {
          "name": "Start warehouse snapshot",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Успешный ответ\", () => pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]));",
                  "const j = pm.response.json(); const d = j.data || j;",
                  "const value = d.snapshotId || d.id;",
                  "if (value) pm.collectionVariables.set('snapshotId', value);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"snapshotKey\": \"warehouse-{{$timestamp}}\",\n  \"scopes\": [\n    \"warehouse\",\n    \"productVariant\",\n    \"stockBalance\"\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/snapshots/start"
          },
          "response": []
        },
        {
          "name": "Warehouses",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"batchId\": \"postman-warehouses-{{$timestamp}}\",\n  \"schemaVersion\": \"1.1\",\n  \"snapshotId\": \"{{snapshotId}}\",\n  \"items\": [\n    {\n      \"schemaVersion\": \"1.1\",\n      \"entity\": \"warehouse\",\n      \"externalId\": \"{{warehouseExternalId}}\",\n      \"sourceRevision\": \"{{$timestamp}}\",\n      \"version\": 1,\n      \"data\": {\n        \"organizationExternalId\": \"\",\n        \"name\": \"Склад 1С\",\n        \"active\": true,\n        \"metadata\": {\n          \"source\": \"postman\"\n        }\n      }\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/entities/batch"
          },
          "response": []
        },
        {
          "name": "Product variants",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"batchId\": \"postman-product-variants-{{$timestamp}}\",\n  \"schemaVersion\": \"1.1\",\n  \"snapshotId\": \"{{snapshotId}}\",\n  \"items\": [\n    {\n      \"schemaVersion\": \"1.1\",\n      \"entity\": \"productVariant\",\n      \"externalId\": \"{{productVariantExternalId}}\",\n      \"sourceRevision\": \"{{$timestamp}}\",\n      \"version\": 1,\n      \"data\": {\n        \"organizationExternalId\": \"\",\n        \"productExternalId\": \"product-postman-001\",\n        \"sku\": \"SKU-001\",\n        \"name\": \"Товар из 1С\",\n        \"unit\": \"шт\",\n        \"metadata\": {\n          \"source\": \"postman\"\n        }\n      }\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/entities/batch"
          },
          "response": []
        },
        {
          "name": "Stock balances",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"batchId\": \"postman-stock-balances-{{$timestamp}}\",\n  \"schemaVersion\": \"1.1\",\n  \"snapshotId\": \"{{snapshotId}}\",\n  \"items\": [\n    {\n      \"schemaVersion\": \"1.1\",\n      \"entity\": \"stockBalance\",\n      \"externalId\": \"balance-postman-001\",\n      \"sourceRevision\": \"{{$timestamp}}\",\n      \"version\": 1,\n      \"data\": {\n        \"warehouseExternalId\": \"{{warehouseExternalId}}\",\n        \"productVariantExternalId\": \"{{productVariantExternalId}}\",\n        \"quantity\": 12\n      }\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/entities/batch"
          },
          "response": []
        },
        {
          "name": "Stock movements",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"batchId\": \"postman-stock-movements-{{$timestamp}}\",\n  \"schemaVersion\": \"1.1\",\n  \"snapshotId\": \"{{snapshotId}}\",\n  \"items\": [\n    {\n      \"schemaVersion\": \"1.1\",\n      \"entity\": \"stockMovement\",\n      \"externalId\": \"movement-postman-{{$timestamp}}\",\n      \"sourceRevision\": \"{{$timestamp}}\",\n      \"version\": 1,\n      \"data\": {\n        \"warehouseExternalId\": \"{{warehouseExternalId}}\",\n        \"productVariantExternalId\": \"{{productVariantExternalId}}\",\n        \"movementType\": \"receipt\",\n        \"quantityDelta\": 5,\n        \"sourceId\": \"1c-postman-{{$timestamp}}\",\n        \"metadata\": {\n          \"source\": \"postman\"\n        }\n      }\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/entities/batch"
          },
          "response": []
        },
        {
          "name": "Warehouse documents (mirror)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"batchId\": \"postman-warehouse-documents-mirror--{{$timestamp}}\",\n  \"schemaVersion\": \"1.1\",\n  \"snapshotId\": \"{{snapshotId}}\",\n  \"items\": [\n    {\n      \"schemaVersion\": \"1.1\",\n      \"entity\": \"warehouseDocument\",\n      \"externalId\": \"document-postman-{{$timestamp}}\",\n      \"sourceRevision\": \"{{$timestamp}}\",\n      \"version\": 1,\n      \"data\": {\n        \"documentType\": \"goods_receipt\",\n        \"number\": \"1C-001\",\n        \"state\": \"posted\",\n        \"lines\": []\n      }\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/entities/batch"
          },
          "response": []
        },
        {
          "name": "Resume snapshot",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"processedCount\": 3\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/snapshots/{{snapshotId}}/resume"
          },
          "response": []
        },
        {
          "name": "Complete snapshot",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"processedCount\": 3,\n  \"itemCounts\": {\n    \"warehouse\": 1,\n    \"productVariant\": 1,\n    \"stockBalance\": 1\n  },\n  \"checksum\": \"postman-example\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/snapshots/{{snapshotId}}/complete"
          },
          "response": []
        },
        {
          "name": "Reconcile warehouse snapshot",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{connectorToken}}",
                "type": "text"
              },
              {
                "key": "Idempotency-Key",
                "value": "postman-{{$guid}}",
                "type": "text"
              },
              {
                "key": "Content-Type",
                "value": "application/json",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"applyAdjustments\": false,\n  \"reason\": \"postman_reconciliation\",\n  \"expectedChecksum\": \"postman-example\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": "{{baseUrl}}/api/v2/connectors/snapshots/{{snapshotId}}/warehouse/reconcile"
          },
          "response": []
        }
      ]
    }
  ]
}
