{
  "openapi": "3.0.3",
  "info": {
    "title": "SUNTOOLS API",
    "version": "1.0.0-draft",
    "description": "Проект API для интеграции систем покупателя и исполнителя. Примеры используют условные данные и демонстрационные домены .example."
  },
  "servers": [
    {
      "url": "https://api.suntools.example",
      "description": "Условный адрес в примерах."
    }
  ],
  "tags": [
    {
      "name": "catalog",
      "description": "Поиск артикулов, предложения продавцов и согласование цен.",
      "x-title": "Каталог и КП"
    },
    {
      "name": "manufacturing",
      "description": "Файлы CAD, ревизии чертежей и расчёт инженера.",
      "x-title": "Изготовление деталей"
    },
    {
      "name": "orders",
      "description": "Размещение закупок, подтверждение, перенос и отмена.",
      "x-title": "Заказы и изменения"
    },
    {
      "name": "production",
      "description": "Этапы изготовления и готовность каждой детали.",
      "x-title": "Производство"
    },
    {
      "name": "fulfillment",
      "description": "Упаковочные листы, приёмка, недостача и довоз.",
      "x-title": "Поставки и приёмка"
    },
    {
      "name": "exchange",
      "description": "Выгрузка документов и синхронизация ERP по событиям.",
      "x-title": "Документы и события"
    }
  ],
  "paths": {
    "/v1/items": {
      "get": {
        "tags": [
          "catalog"
        ],
        "operationId": "listItems",
        "summary": "Найти исполнение",
        "description": "Найдите инструмент или готовую деталь по артикулу, серии или коду предприятия. Сохраните itemId для сравнения предложений.",
        "security": [
          {
            "clientCredentials": [
              "catalog.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Item"
                      },
                      "description": "Элементы страницы.",
                      "minItems": 0
                    },
                    "nextCursor": {
                      "type": "string",
                      "example": "c_next",
                      "description": "Курсор продолжения. В конце списка возвращается null.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "description": "Артикул исполнения.",
            "schema": {
              "type": "string",
              "example": "JYW-SPB5D0850",
              "description": "Артикул исполнения.",
              "minLength": 1
            }
          },
          {
            "name": "series",
            "in": "query",
            "required": false,
            "description": "Название серии.",
            "schema": {
              "type": "string",
              "example": "JYW-SPB5D",
              "description": "Название серии."
            }
          },
          {
            "name": "customerCode",
            "in": "query",
            "required": false,
            "description": "Код в справочнике покупателя.",
            "schema": {
              "type": "string",
              "example": "СВ-0850",
              "description": "Код в справочнике покупателя."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Курсор из предыдущей страницы.",
            "schema": {
              "type": "string",
              "example": "c_next",
              "description": "Курсор из предыдущей страницы."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, по умолчанию 25.",
            "schema": {
              "type": "integer",
              "example": 25,
              "description": "Размер страницы, по умолчанию 25.",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ]
      }
    },
    "/v1/items/{id}/offers": {
      "get": {
        "tags": [
          "catalog"
        ],
        "operationId": "listOffers",
        "summary": "Сравнить предложения",
        "description": "Сравните условия продавцов на нужное количество. Остаток приведён на момент обновления. Резерв создаётся при подтверждении заказа.",
        "security": [
          {
            "clientCredentials": [
              "catalog.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Offer"
                      },
                      "description": "Элементы страницы.",
                      "minItems": 0
                    },
                    "nextCursor": {
                      "type": "string",
                      "example": "c_next",
                      "description": "Курсор продолжения. В конце списка возвращается null.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "it_850",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "quantity",
            "in": "query",
            "required": true,
            "description": "Количество в штуках.",
            "schema": {
              "type": "integer",
              "example": 10,
              "description": "Количество в штуках.",
              "minimum": 1
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Курсор из предыдущей страницы.",
            "schema": {
              "type": "string",
              "example": "c_next",
              "description": "Курсор из предыдущей страницы."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, по умолчанию 25.",
            "schema": {
              "type": "integer",
              "example": 25,
              "description": "Размер страницы, по умолчанию 25.",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ]
      }
    },
    "/v1/quotes": {
      "post": {
        "tags": [
          "catalog"
        ],
        "operationId": "createQuote",
        "summary": "Запросить КП",
        "description": "Передайте состав закупки, место получения и способ отгрузки. Условия продавца появятся в карточке КП.",
        "security": [
          {
            "clientCredentials": [
              "quotes.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                },
                "example": {
                  "id": "qt_301",
                  "quoteVersion": 1,
                  "status": "pending",
                  "lines": [
                    {
                      "id": "ql_1",
                      "clientLineId": "10",
                      "quantity": 15,
                      "status": "needs_review"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "createQuote-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteDraft"
              },
              "example": {
                "externalRequestId": "ЗК-1842",
                "lines": [
                  {
                    "clientLineId": "10",
                    "sku": "JYW-SPB5D0850",
                    "quantity": 15,
                    "offerId": "of_18"
                  }
                ],
                "destination": "Самовывоз, Санкт-Петербург",
                "shipmentPolicy": "as_ready"
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "catalog"
        ],
        "operationId": "listQuotes",
        "summary": "Найти КП организации",
        "description": "Получите список запросов текущей организации. Фильтр принимает номер запроса из ERP.",
        "security": [
          {
            "clientCredentials": [
              "quotes.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Quote"
                      },
                      "description": "Элементы страницы.",
                      "minItems": 0
                    },
                    "nextCursor": {
                      "type": "string",
                      "example": "c_next",
                      "description": "Курсор продолжения. В конце списка возвращается null.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "qt_301",
                      "quoteVersion": 1,
                      "status": "pending",
                      "lines": [
                        {
                          "id": "ql_1",
                          "clientLineId": "10",
                          "quantity": 15,
                          "status": "needs_review"
                        }
                      ]
                    }
                  ],
                  "nextCursor": null
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "externalRequestId",
            "in": "query",
            "required": false,
            "description": "Номер спецификации.",
            "schema": {
              "type": "string",
              "example": "ЗК-1842",
              "description": "Номер спецификации."
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Курсор из предыдущей страницы.",
            "schema": {
              "type": "string",
              "example": "c_next",
              "description": "Курсор из предыдущей страницы."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, по умолчанию 25.",
            "schema": {
              "type": "integer",
              "example": 25,
              "description": "Размер страницы, по умолчанию 25.",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ]
      }
    },
    "/v1/quotes/{id}": {
      "get": {
        "tags": [
          "catalog"
        ],
        "operationId": "getQuote",
        "summary": "Получить условия КП",
        "description": "Сверьте статус строк, цену, налоговый режим, срок действия и версию перед размещением заказа. Для изготовления проверьте ревизию комплекта.",
        "security": [
          {
            "clientCredentials": [
              "quotes.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "qt_422",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/quotes/{id}/versions": {
      "post": {
        "tags": [
          "catalog"
        ],
        "operationId": "reviseQuote",
        "summary": "Пересмотреть состав КП",
        "description": "Передайте новый состав каталожной закупки до заказа. Решение покупателя по предыдущей версии сохраняется в истории.",
        "security": [
          {
            "clientCredentials": [
              "quotes.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                },
                "example": {
                  "id": "qt_301",
                  "quoteVersion": 2,
                  "status": "pending",
                  "lines": [
                    {
                      "id": "ql_1",
                      "clientLineId": "10",
                      "quantity": 15,
                      "status": "needs_review"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "qt_422",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "reviseQuote-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия ресурса, прочитанная перед записью.",
                    "minimum": 1
                  },
                  "specification": {
                    "$ref": "#/components/schemas/QuoteDraft"
                  }
                },
                "required": [
                  "expectedVersion",
                  "specification"
                ]
              },
              "example": {
                "expectedVersion": 1,
                "specification": {
                  "externalRequestId": "ЗК-1842",
                  "lines": [
                    {
                      "clientLineId": "10",
                      "sku": "JYW-SPB5D0850",
                      "quantity": 15,
                      "offerId": "of_18"
                    }
                  ],
                  "destination": "Самовывоз, Санкт-Петербург",
                  "shipmentPolicy": "as_ready"
                }
              }
            }
          }
        }
      }
    },
    "/v1/files": {
      "post": {
        "tags": [
          "manufacturing"
        ],
        "operationId": "uploadFile",
        "summary": "Загрузить чертёж или модель",
        "description": "Передайте оригинал для строки проекта. Допустимы PDF, DXF, DWG, STEP/STP и STL. На деталь можно передать одну 3D-модель. Лимит проекта в пилоте составляет 12 МиБ.",
        "security": [
          {
            "clientCredentials": [
              "drawings.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fileId": {
                      "type": "string",
                      "example": "file_pdf_b",
                      "description": "Идентификатор для привязки к детали."
                    },
                    "sizeBytes": {
                      "type": "integer",
                      "example": 524288,
                      "description": "Размер оригинала.",
                      "minimum": 0
                    },
                    "sha256": {
                      "type": "string",
                      "example": "a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4",
                      "description": "Контрольная сумма SHA-256."
                    }
                  },
                  "required": [
                    "fileId",
                    "sizeBytes",
                    "sha256"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "uploadFile-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Оригинал чертежа или модели."
                  }
                },
                "required": [
                  "file"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/files/{id}/content": {
      "get": {
        "tags": [
          "manufacturing"
        ],
        "operationId": "getDrawingFile",
        "summary": "Скачать оригинал детали",
        "description": "Покупатель или назначенный исполнитель скачивает оригинал по идентификатору файла из доступной заявки.",
        "security": [
          {
            "clientCredentials": [
              "drawings.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Байты исходного файла."
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "file_pdf_b",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/manufacturing-requests": {
      "post": {
        "tags": [
          "manufacturing"
        ],
        "operationId": "createManufacturingRequest",
        "summary": "Передать проект на расчёт",
        "description": "Зарегистрируйте комплект деталей с тиражами и файлами. При доработке складской втулки передайте sourceSku. Сложные требования передаются инженеру.",
        "security": [
          {
            "clientCredentials": [
              "drawings.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManufacturingRequest"
                },
                "example": {
                  "id": "mr_52",
                  "requestRevision": 1,
                  "status": "engineering_review",
                  "parts": [
                    {
                      "clientLineId": "10",
                      "name": "Втулка опорная",
                      "quantity": 10,
                      "drawingRevision": "A",
                      "sourceSku": "VT-20",
                      "material": "Д16Т",
                      "process": "turning",
                      "finish": "Без покрытия",
                      "inspection": "Контроль отверстия по чертежу",
                      "fileIds": [
                        "file_step_a",
                        "file_pdf_a"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "createManufacturingRequest-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "externalRequestId": {
                    "type": "string",
                    "example": "ТЗ-52",
                    "description": "Номер технического задания в ERP."
                  },
                  "parts": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Part"
                    },
                    "description": "Одна или несколько деталей проекта.",
                    "minItems": 1
                  },
                  "sourceOrderId": {
                    "type": "string",
                    "example": "ord_815",
                    "description": "Идентификатор заказа SUNTOOLS.",
                    "minLength": 1
                  }
                },
                "required": [
                  "externalRequestId",
                  "parts"
                ]
              },
              "example": {
                "externalRequestId": "ТЗ-52",
                "parts": [
                  {
                    "clientLineId": "10",
                    "name": "Втулка опорная",
                    "quantity": 10,
                    "drawingRevision": "A",
                    "sourceSku": "VT-20",
                    "material": "Д16Т",
                    "process": "turning",
                    "finish": "Без покрытия",
                    "inspection": "Контроль отверстия по чертежу",
                    "fileIds": [
                      "file_step_a",
                      "file_pdf_a"
                    ]
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/v1/manufacturing-requests/{id}": {
      "get": {
        "tags": [
          "manufacturing"
        ],
        "operationId": "getManufacturingRequest",
        "summary": "Открыть заявку инженеру",
        "description": "Получите актуальные детали, номер комплекта, состояние расчёта и идентификатор опубликованного КП.",
        "security": [
          {
            "clientCredentials": [
              "drawings.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManufacturingRequest"
                },
                "example": {
                  "id": "mr_52",
                  "requestRevision": 2,
                  "status": "quote_ready",
                  "parts": [
                    {
                      "clientLineId": "10",
                      "name": "Втулка опорная",
                      "quantity": 10,
                      "drawingRevision": "B",
                      "sourceSku": "VT-20",
                      "material": "Д16Т",
                      "process": "turning",
                      "finish": "Без покрытия",
                      "inspection": "Контроль отверстия по чертежу",
                      "fileIds": [
                        "file_step_b",
                        "file_pdf_b"
                      ]
                    }
                  ],
                  "quoteId": "qt_422"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "mr_52",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/manufacturing-requests/{id}/messages": {
      "post": {
        "tags": [
          "manufacturing"
        ],
        "operationId": "addEngineeringMessage",
        "summary": "Обсудить требования",
        "description": "Задайте вопрос или передайте ответ по конкретной строке и версии. Изменение геометрии оформляется новой версией комплекта.",
        "security": [
          {
            "clientCredentials": [
              "drawings.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messageId": {
                      "type": "string",
                      "example": "msg_18",
                      "description": "Номер сообщения."
                    },
                    "createdAt": {
                      "type": "string",
                      "example": "2026-12-03T10:00:00+03:00",
                      "description": "Дата и время с часовым поясом.",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "messageId",
                    "createdAt"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "mr_52",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "addEngineeringMessage-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "requestRevision": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия комплекта файлов и требований проекта.",
                    "minimum": 1
                  },
                  "clientLineId": {
                    "type": "string",
                    "example": "10",
                    "description": "Постоянный номер строки в системе покупателя.",
                    "minLength": 1
                  },
                  "text": {
                    "type": "string",
                    "example": "Уточните допуск отверстия.",
                    "description": "Текст сообщения."
                  }
                },
                "required": [
                  "requestRevision",
                  "clientLineId",
                  "text"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/manufacturing-requests/{id}/revisions": {
      "post": {
        "tags": [
          "manufacturing"
        ],
        "operationId": "reviseDrawings",
        "summary": "Передать новую ревизию",
        "description": "До оформления заказа загрузите новые оригиналы и передайте полный состав проекта. Предыдущее КП требует пересмотра. После запуска оформите связанный новый проект.",
        "security": [
          {
            "clientCredentials": [
              "drawings.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ManufacturingRequest"
                },
                "example": {
                  "id": "mr_52",
                  "requestRevision": 2,
                  "status": "engineering_review",
                  "parts": [
                    {
                      "clientLineId": "10",
                      "name": "Втулка опорная",
                      "quantity": 10,
                      "drawingRevision": "B",
                      "sourceSku": "VT-20",
                      "material": "Д16Т",
                      "process": "turning",
                      "finish": "Без покрытия",
                      "inspection": "Контроль отверстия по чертежу",
                      "fileIds": [
                        "file_step_b",
                        "file_pdf_b"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "mr_52",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "reviseDrawings-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedRevision": {
                    "type": "integer",
                    "example": 1,
                    "description": "Версия комплекта до изменения.",
                    "minimum": 1
                  },
                  "parts": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Part"
                    },
                    "description": "Одна или несколько деталей проекта.",
                    "minItems": 1
                  }
                },
                "required": [
                  "expectedRevision",
                  "parts"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/manufacturing-requests/{id}/quotes": {
      "post": {
        "tags": [
          "manufacturing"
        ],
        "operationId": "publishManufacturingQuote",
        "summary": "Выдать КП на изготовление",
        "description": "Инженер назначенного исполнителя фиксирует цены по каждой строке, срок изготовления и доставку для одной версии проекта.",
        "security": [
          {
            "clientCredentials": [
              "seller.quote"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "mr_52",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "publishManufacturingQuote-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "requestRevision": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия комплекта файлов и требований проекта.",
                    "minimum": 1
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "clientLineId": {
                          "type": "string",
                          "example": "10",
                          "description": "Постоянный номер строки в системе покупателя.",
                          "minLength": 1
                        },
                        "unitPriceMinor": {
                          "type": "integer",
                          "example": 61500,
                          "description": "Цена за штуку в копейках.",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "clientLineId",
                        "unitPriceMinor"
                      ]
                    },
                    "description": "Цена за штуку по каждой детали.",
                    "minItems": 1
                  },
                  "currency": {
                    "type": "string",
                    "example": "RUB",
                    "description": "Валюта расчёта.",
                    "enum": [
                      "RUB"
                    ]
                  },
                  "taxMode": {
                    "type": "string",
                    "example": "without_vat",
                    "description": "Как учтён НДС.",
                    "enum": [
                      "without_vat",
                      "vat_included"
                    ]
                  },
                  "shippingMinor": {
                    "type": "integer",
                    "example": 0,
                    "description": "Стоимость доставки в копейках.",
                    "minimum": 0
                  },
                  "leadBusinessDays": {
                    "type": "integer",
                    "example": 7,
                    "description": "Срок в рабочих днях.",
                    "minimum": 1
                  },
                  "validUntil": {
                    "type": "string",
                    "example": "2026-12-10T18:00:00+03:00",
                    "description": "Дата и время с часовым поясом.",
                    "format": "date-time"
                  }
                },
                "required": [
                  "requestRevision",
                  "lines",
                  "currency",
                  "taxMode",
                  "shippingMinor",
                  "leadBusinessDays",
                  "validUntil"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/orders": {
      "post": {
        "tags": [
          "orders"
        ],
        "operationId": "createOrder",
        "summary": "Разместить заказ",
        "description": "Примите действующую версию КП. Для изготовления обязательны manufacturingRequestId и requestRevision. Для каталога можно принять выбранные строки. Статус submitted означает регистрацию до решения продавца.",
        "security": [
          {
            "clientCredentials": [
              "orders.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                },
                "example": {
                  "id": "ord_815",
                  "externalOrderId": "ПЗ-1843",
                  "version": 1,
                  "status": "submitted",
                  "quoteId": "qt_422",
                  "quoteVersion": 3,
                  "requestRevision": 2,
                  "lines": [
                    {
                      "id": "ol_1",
                      "quoteLineId": "ql_bushing",
                      "quantity": 10,
                      "shipped": 0,
                      "receivedGood": 0,
                      "cancelled": 0
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Срок действия КП истёк. Запросите актуальные условия.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "quote_expired",
                  "message": "Срок действия КП истёк. Запросите актуальные условия.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "createOrder-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "externalOrderId": {
                    "type": "string",
                    "example": "ПЗ-1843",
                    "description": "Уникальный номер закупки в ERP.",
                    "minLength": 1
                  },
                  "quoteId": {
                    "type": "string",
                    "example": "qt_422",
                    "description": "Идентификатор КП.",
                    "minLength": 1
                  },
                  "quoteVersion": {
                    "type": "integer",
                    "example": 3,
                    "description": "Версия коммерческого предложения.",
                    "minimum": 1
                  },
                  "quoteLineIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "example": "ql_bushing",
                      "description": ""
                    },
                    "description": "Принимаемые строки. Для изготовления нужен весь состав КП.",
                    "minItems": 1
                  },
                  "manufacturingRequestId": {
                    "type": "string",
                    "example": "mr_52",
                    "description": "Заявка на изготовление.",
                    "minLength": 1
                  },
                  "requestRevision": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия комплекта файлов и требований проекта.",
                    "minimum": 1
                  },
                  "approvalRef": {
                    "type": "string",
                    "example": "СОГЛ-61",
                    "description": "Решение сотрудника, если требуется правилами покупателя."
                  }
                },
                "required": [
                  "externalOrderId",
                  "quoteId",
                  "quoteVersion",
                  "quoteLineIds"
                ]
              },
              "example": {
                "externalOrderId": "ПЗ-1843",
                "quoteId": "qt_422",
                "quoteVersion": 3,
                "quoteLineIds": [
                  "ql_bushing"
                ],
                "manufacturingRequestId": "mr_52",
                "requestRevision": 2,
                "approvalRef": "СОГЛ-61"
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "orders"
        ],
        "operationId": "listOrders",
        "summary": "Найти заказ в реестре",
        "description": "Найдите заказ покупателя по его внешнему номеру или состоянию.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Order"
                      },
                      "description": "Элементы страницы.",
                      "minItems": 0
                    },
                    "nextCursor": {
                      "type": "string",
                      "example": "c_next",
                      "description": "Курсор продолжения. В конце списка возвращается null.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "externalOrderId",
            "in": "query",
            "required": false,
            "description": "Номер закупки в ERP.",
            "schema": {
              "type": "string",
              "example": "ПЗ-1843",
              "description": "Номер закупки в ERP."
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Состояние заказа.",
            "schema": {
              "type": "string",
              "example": "submitted",
              "description": "Состояние заказа.",
              "enum": [
                "submitted",
                "confirmed",
                "rejected",
                "cancelled",
                "in_progress",
                "completed"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Курсор из предыдущей страницы.",
            "schema": {
              "type": "string",
              "example": "c_next",
              "description": "Курсор из предыдущей страницы."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, по умолчанию 25.",
            "schema": {
              "type": "integer",
              "example": 25,
              "description": "Размер страницы, по умолчанию 25.",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ]
      }
    },
    "/v1/orders/{id}": {
      "get": {
        "tags": [
          "orders"
        ],
        "operationId": "getOrder",
        "summary": "Проверить состояние заказа",
        "description": "Прочитайте зафиксированные условия и баланс каждой строки. При изменении используйте актуальную версию заказа.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                },
                "example": {
                  "id": "ord_815",
                  "externalOrderId": "ПЗ-1843",
                  "version": 2,
                  "status": "confirmed",
                  "quoteId": "qt_422",
                  "quoteVersion": 3,
                  "requestRevision": 2,
                  "lines": [
                    {
                      "id": "ol_1",
                      "quoteLineId": "ql_bushing",
                      "quantity": 10,
                      "shipped": 0,
                      "receivedGood": 0,
                      "cancelled": 0
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/orders/{id}/decisions": {
      "post": {
        "tags": [
          "orders"
        ],
        "operationId": "decideOrder",
        "summary": "Подтвердить или отклонить заказ",
        "description": "Продавец проверяет резерв или производственную возможность. При отказе укажите причину.",
        "security": [
          {
            "clientCredentials": [
              "seller.fulfill"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                },
                "example": {
                  "id": "ord_815",
                  "externalOrderId": "ПЗ-1843",
                  "version": 3,
                  "status": "confirmed",
                  "quoteId": "qt_422",
                  "quoteVersion": 3,
                  "requestRevision": 2,
                  "lines": [
                    {
                      "id": "ol_1",
                      "quoteLineId": "ql_bushing",
                      "quantity": 10,
                      "shipped": 0,
                      "receivedGood": 0,
                      "cancelled": 0
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "decideOrder-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия ресурса, прочитанная перед записью.",
                    "minimum": 1
                  },
                  "decision": {
                    "type": "string",
                    "example": "confirmed",
                    "description": "Решение исполнителя.",
                    "enum": [
                      "confirmed",
                      "rejected"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "example": "Подтверждена загрузка участка",
                    "description": "Основание решения."
                  }
                },
                "required": [
                  "expectedVersion",
                  "decision"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/orders/{id}/change-requests": {
      "post": {
        "tags": [
          "orders"
        ],
        "operationId": "requestChange",
        "summary": "Запросить изменение или отмену",
        "description": "Прежние условия действуют до решения продавца. Для изготовления исполнитель дополнительно проверяет начатые работы и понесённые расходы.",
        "security": [
          {
            "clientCredentials": [
              "orders.write"
            ]
          }
        ],
        "responses": {
          "202": {
            "description": "Запрос принят на рассмотрение",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangeRequest"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "requestChange-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия ресурса, прочитанная перед записью.",
                    "minimum": 1
                  },
                  "type": {
                    "type": "string",
                    "example": "cancel_remaining",
                    "description": "Вид изменения.",
                    "enum": [
                      "reschedule",
                      "change_destination",
                      "cancel_remaining"
                    ]
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "orderLineId": {
                          "type": "string",
                          "example": "ol_1",
                          "description": "Строка заказа.",
                          "minLength": 1
                        },
                        "quantity": {
                          "type": "integer",
                          "example": 3,
                          "description": "Открытое количество для отмены.",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "orderLineId"
                      ]
                    },
                    "description": "Затронутые строки.",
                    "minItems": 1
                  },
                  "requestedDate": {
                    "type": "string",
                    "example": "2026-12-15",
                    "description": "Обязательна для переноса.",
                    "format": "date"
                  },
                  "destination": {
                    "type": "string",
                    "example": "Склад покупателя",
                    "description": "Обязателен для смены адреса."
                  },
                  "reason": {
                    "type": "string",
                    "example": "Изменился план участка",
                    "description": "Причина изменения."
                  }
                },
                "required": [
                  "expectedVersion",
                  "type",
                  "lines",
                  "reason"
                ]
              },
              "example": {
                "expectedVersion": 2,
                "type": "cancel_remaining",
                "lines": [
                  {
                    "orderLineId": "ol_1",
                    "quantity": 3
                  }
                ],
                "reason": "Изменился план участка"
              }
            }
          }
        }
      }
    },
    "/v1/orders/{id}/change-requests/{requestId}": {
      "get": {
        "tags": [
          "orders"
        ],
        "operationId": "getChange",
        "summary": "Проверить решение по изменению",
        "description": "Проверьте итог по номеру запроса. При отказе вернётся основание.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangeRequest"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "requestId",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "chg_7",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/orders/{id}/change-requests/{requestId}/decisions": {
      "post": {
        "tags": [
          "orders"
        ],
        "operationId": "decideChange",
        "summary": "Согласовать изменение заказа",
        "description": "Исполнитель повторно сверяет открытое количество и согласует изменение или передаёт мотивированный отказ.",
        "security": [
          {
            "clientCredentials": [
              "seller.fulfill"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangeRequest"
                },
                "example": {
                  "id": "chg_7",
                  "orderId": "ord_815",
                  "status": "applied",
                  "reason": "Остаток ещё не отправлен"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "requestId",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "chg_7",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "decideChange-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия ресурса, прочитанная перед записью.",
                    "minimum": 1
                  },
                  "decision": {
                    "type": "string",
                    "example": "applied",
                    "description": "Решение по запросу.",
                    "enum": [
                      "applied",
                      "rejected"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "example": "Остаток ещё не отправлен",
                    "description": "Основание решения."
                  }
                },
                "required": [
                  "expectedVersion",
                  "decision",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/orders/{id}/production": {
      "get": {
        "tags": [
          "production"
        ],
        "operationId": "getProduction",
        "summary": "Проверить готовность деталей",
        "description": "Возвращает стадию и план готовности по каждой строке заказа на изготовление.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orderId": {
                      "type": "string",
                      "example": "ord_815",
                      "description": "Идентификатор заказа SUNTOOLS.",
                      "minLength": 1
                    },
                    "lines": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ProductionLine"
                      },
                      "description": "Этапы деталей.",
                      "minItems": 0
                    }
                  },
                  "required": [
                    "orderId",
                    "lines"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/orders/{id}/production-events": {
      "post": {
        "tags": [
          "production"
        ],
        "operationId": "recordProduction",
        "summary": "Передать этап изготовления",
        "description": "Производственная система отмечает последовательные переходы от очереди к работе и готовности по строке утверждённой ревизии.",
        "security": [
          {
            "clientCredentials": [
              "seller.fulfill"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "recordProduction-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expectedVersion": {
                    "type": "integer",
                    "example": 2,
                    "description": "Версия ресурса, прочитанная перед записью.",
                    "minimum": 1
                  },
                  "orderLineId": {
                    "type": "string",
                    "example": "ol_1",
                    "description": "Строка заказа.",
                    "minLength": 1
                  },
                  "drawingRevision": {
                    "type": "string",
                    "example": "B",
                    "description": "Ревизия чертежа отдельной детали.",
                    "minLength": 1
                  },
                  "stage": {
                    "type": "string",
                    "example": "ready",
                    "description": "Очередь производства, в работе или готово.",
                    "enum": [
                      "queued",
                      "in_progress",
                      "ready"
                    ]
                  },
                  "occurredAt": {
                    "type": "string",
                    "example": "2026-12-03T10:00:00+03:00",
                    "description": "Дата и время с часовым поясом.",
                    "format": "date-time"
                  },
                  "externalEventId": {
                    "type": "string",
                    "example": "MES-190",
                    "description": "Номер факта в системе исполнителя."
                  }
                },
                "required": [
                  "expectedVersion",
                  "orderLineId",
                  "drawingRevision",
                  "stage",
                  "occurredAt",
                  "externalEventId"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/orders/{id}/shipments": {
      "post": {
        "tags": [
          "fulfillment"
        ],
        "operationId": "createShipment",
        "summary": "Зарегистрировать отправление",
        "description": "Передайте фактический состав упаковочного листа. Для довоза укажите claimId и исходную строку отправления.",
        "security": [
          {
            "clientCredentials": [
              "seller.fulfill"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Shipment"
                },
                "example": {
                  "id": "sh_901",
                  "orderId": "ord_814",
                  "packingNumber": "УЛ-901",
                  "carrier": "Самовывоз",
                  "lines": [
                    {
                      "shipmentLineId": "sl_1",
                      "orderLineId": "ol_drill",
                      "quantity": 12
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_814",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "createShipment-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "packingNumber": {
                    "type": "string",
                    "example": "УЛ-901",
                    "description": "Номер упаковочного листа."
                  },
                  "carrier": {
                    "type": "string",
                    "example": "Самовывоз",
                    "description": "Способ доставки."
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "orderLineId": {
                          "type": "string",
                          "example": "ol_1",
                          "description": "Строка заказа.",
                          "minLength": 1
                        },
                        "quantity": {
                          "type": "integer",
                          "example": 10,
                          "description": "Количество в штуках.",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "orderLineId",
                        "quantity"
                      ]
                    },
                    "description": "Отправленные позиции.",
                    "minItems": 1
                  },
                  "claimId": {
                    "type": "string",
                    "example": "cl_508",
                    "description": "Обращение для довоза."
                  },
                  "sourceShipmentLineId": {
                    "type": "string",
                    "example": "sl_1",
                    "description": "Строка исходной отправки для довоза."
                  }
                },
                "required": [
                  "packingNumber",
                  "carrier",
                  "lines"
                ]
              },
              "example": {
                "packingNumber": "УЛ-901",
                "carrier": "Самовывоз",
                "lines": [
                  {
                    "orderLineId": "ol_drill",
                    "quantity": 12
                  }
                ]
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "fulfillment"
        ],
        "operationId": "listShipments",
        "summary": "Найти партии заказа",
        "description": "Получите обычные и корректирующие отправления одного заказа.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Shipment"
                      },
                      "description": "Элементы страницы.",
                      "minItems": 0
                    },
                    "nextCursor": {
                      "type": "string",
                      "example": "c_next",
                      "description": "Курсор продолжения. В конце списка возвращается null.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                },
                "example": {
                  "items": [
                    {
                      "id": "sh_901",
                      "orderId": "ord_814",
                      "packingNumber": "УЛ-901",
                      "carrier": "Самовывоз",
                      "lines": [
                        {
                          "shipmentLineId": "sl_1",
                          "orderLineId": "ol_drill",
                          "quantity": 12
                        }
                      ]
                    }
                  ],
                  "nextCursor": null
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_814",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Курсор из предыдущей страницы.",
            "schema": {
              "type": "string",
              "example": "c_next",
              "description": "Курсор из предыдущей страницы."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, по умолчанию 25.",
            "schema": {
              "type": "integer",
              "example": 25,
              "description": "Размер страницы, по умолчанию 25.",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ]
      }
    },
    "/v1/shipments/{id}": {
      "get": {
        "tags": [
          "fulfillment"
        ],
        "operationId": "getShipment",
        "summary": "Открыть упаковочный лист",
        "description": "Сверьте перевозчика, фактическое количество и идентификаторы строк перед приёмкой.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Shipment"
                },
                "example": {
                  "id": "sh_901",
                  "orderId": "ord_814",
                  "packingNumber": "УЛ-901",
                  "carrier": "Самовывоз",
                  "lines": [
                    {
                      "shipmentLineId": "sl_1",
                      "orderLineId": "ol_drill",
                      "quantity": 12
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "sh_901",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/shipments/{id}/receipts": {
      "post": {
        "tags": [
          "fulfillment"
        ],
        "operationId": "receiveShipment",
        "summary": "Зарегистрировать приёмку",
        "description": "Склад передаёт все строки листа по одному разу. Сумма годных, повреждённых, недостающих и отклонённых изделий равна количеству по листу. Для расхождения укажите причину.",
        "security": [
          {
            "clientCredentials": [
              "receipts.write"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                },
                "example": {
                  "id": "rc_417",
                  "shipmentId": "sh_901",
                  "claimIds": [
                    "cl_508"
                  ],
                  "lines": [
                    {
                      "shipmentLineId": "sl_1",
                      "good": 11,
                      "damaged": 0,
                      "missing": 1
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Распределите всё количество по строке упаковочного листа.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "quantity_mismatch",
                  "message": "Распределите всё количество по строке упаковочного листа.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "sh_901",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "receiveShipment-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ReceiptLine"
                    },
                    "description": "Результат по строкам.",
                    "minItems": 1
                  },
                  "note": {
                    "type": "string",
                    "example": "По листу 12 свёрл, в коробке 11.",
                    "description": "Причина расхождения."
                  }
                },
                "required": [
                  "lines"
                ]
              },
              "example": {
                "lines": [
                  {
                    "shipmentLineId": "sl_1",
                    "good": 11,
                    "damaged": 0,
                    "missing": 1
                  }
                ],
                "note": "По листу 12 свёрл, в коробке 11."
              }
            }
          }
        }
      }
    },
    "/v1/shipments/{id}/receipt": {
      "get": {
        "tags": [
          "fulfillment"
        ],
        "operationId": "getReceipt",
        "summary": "Получить результат приёмки",
        "description": "Верните исходную приёмку и идентификаторы обращений, зарегистрированных по листу.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                },
                "example": {
                  "id": "rc_417",
                  "shipmentId": "sh_901",
                  "claimIds": [
                    "cl_508"
                  ],
                  "lines": [
                    {
                      "shipmentLineId": "sl_1",
                      "good": 11,
                      "damaged": 0,
                      "missing": 1
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "sh_901",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/claims/{id}": {
      "get": {
        "tags": [
          "fulfillment"
        ],
        "operationId": "getClaim",
        "summary": "Проверить расхождение",
        "description": "Прочитайте причину и открытое количество. Довоз закрывает обращение по факту приёмки годных изделий.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Claim"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "cl_508",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/claims/{id}/resolutions": {
      "post": {
        "tags": [
          "fulfillment"
        ],
        "operationId": "resolveClaim",
        "summary": "Записать решение по обращению",
        "description": "Укажите способ урегулирования и подтверждающий документ. Фактический довоз оформляется отдельным отправлением.",
        "security": [
          {
            "clientCredentials": [
              "seller.fulfill"
            ]
          }
        ],
        "responses": {
          "201": {
            "description": "Ресурс зарегистрирован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Claim"
                },
                "example": {
                  "id": "cl_508",
                  "shipmentId": "sh_901",
                  "shipmentLineId": "sl_1",
                  "kind": "missing",
                  "openQuantity": 1,
                  "status": "in_resolution"
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "409": {
            "description": "Данные изменились. Прочитайте актуальную версию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "version_conflict",
                  "message": "Данные изменились. Прочитайте актуальную версию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "422": {
            "description": "Проверьте указанные поля и количество.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "validation_error",
                  "message": "Проверьте указанные поля и количество.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "cl_508",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Уникальный ключ команды. При повторе отправьте то же тело и ключ.",
            "schema": {
              "type": "string",
              "example": "resolveClaim-001",
              "description": "Ключ команды."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "example": "resupply",
                    "description": "Согласованное действие.",
                    "enum": [
                      "resupply",
                      "replace",
                      "credit"
                    ]
                  },
                  "quantity": {
                    "type": "integer",
                    "example": 1,
                    "description": "Количество по решению.",
                    "minimum": 1
                  },
                  "reference": {
                    "type": "string",
                    "example": "РЕШ-17",
                    "description": "Основание или номер документа."
                  }
                },
                "required": [
                  "type",
                  "quantity",
                  "reference"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/orders/{id}/documents": {
      "get": {
        "tags": [
          "exchange"
        ],
        "operationId": "listDocuments",
        "summary": "Получить документы заказа",
        "description": "Получите перечень версий документов продавца, упаковочных листов и протоколов контроля.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Document"
                      },
                      "description": "Элементы страницы.",
                      "minItems": 0
                    },
                    "nextCursor": {
                      "type": "string",
                      "example": "c_next",
                      "description": "Курсор продолжения. В конце списка возвращается null.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "ord_815",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Курсор из предыдущей страницы.",
            "schema": {
              "type": "string",
              "example": "c_next",
              "description": "Курсор из предыдущей страницы."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, по умолчанию 25.",
            "schema": {
              "type": "integer",
              "example": 25,
              "description": "Размер страницы, по умолчанию 25.",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ]
      }
    },
    "/v1/documents/{id}/content": {
      "get": {
        "tags": [
          "exchange"
        ],
        "operationId": "downloadDocument",
        "summary": "Скачать документ",
        "description": "Вернёт содержимое выбранной версии документа по правам организации.",
        "security": [
          {
            "clientCredentials": [
              "orders.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Байты исходного файла."
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "404": {
            "description": "Объект не найден в доступной области.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "not_found",
                  "message": "Объект не найден в доступной области.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор в пути запроса.",
            "schema": {
              "type": "string",
              "example": "doc_81",
              "description": "Идентификатор ресурса.",
              "minLength": 1
            }
          }
        ]
      }
    },
    "/v1/events": {
      "get": {
        "tags": [
          "exchange"
        ],
        "operationId": "readEvents",
        "summary": "Прочитать события организации",
        "description": "Сохраняйте курсор после обработки страницы. Исключайте дубли по eventId. При 410 получите новый стартовый курсор, сверьте ресурсы и дочитайте изменения.",
        "security": [
          {
            "clientCredentials": [
              "events.read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Event"
                      },
                      "description": "Элементы страницы.",
                      "minItems": 0
                    },
                    "nextCursor": {
                      "type": "string",
                      "example": "c_next",
                      "description": "Курсор продолжения. В конце списка возвращается null.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "items",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Токен отсутствует или истёк.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "unauthorized",
                  "message": "Токен отсутствует или истёк.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "403": {
            "description": "У учётной записи нет права на операцию.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "forbidden",
                  "message": "У учётной записи нет права на операцию.",
                  "requestId": "req_901"
                }
              }
            }
          },
          "410": {
            "description": "Курсор истёк. Требуется сверка ресурсов.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "cursor_expired",
                  "message": "Курсор истёк. Требуется сверка ресурсов.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "X-Start-Cursor": {
                "description": "Точка, с которой дочитывают события после полной сверки.",
                "schema": {
                  "type": "string",
                  "example": "c_restart",
                  "description": "Курсор."
                }
              }
            }
          },
          "429": {
            "description": "Превышен лимит запросов. Повторите после интервала Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "code": "rate_limited",
                  "message": "Превышен лимит запросов. Повторите после интервала Retry-After.",
                  "requestId": "req_901"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Секунды до следующего запроса.",
                "schema": {
                  "type": "integer",
                  "example": 30,
                  "description": "Секунды.",
                  "minimum": 0
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Курсор из предыдущей страницы.",
            "schema": {
              "type": "string",
              "example": "c_next",
              "description": "Курсор из предыдущей страницы."
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Размер страницы, по умолчанию 25.",
            "schema": {
              "type": "integer",
              "example": 25,
              "description": "Размер страницы, по умолчанию 25.",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Item": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string",
            "example": "it_850",
            "description": "Идентификатор исполнения.",
            "minLength": 1
          },
          "sku": {
            "type": "string",
            "example": "JYW-SPB5D0850",
            "description": "Артикул исполнения.",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "example": "Сверло 8,5 мм",
            "description": "Название исполнения."
          },
          "kind": {
            "type": "string",
            "example": "tool",
            "description": "Инструмент или готовая деталь.",
            "enum": [
              "tool",
              "finished_part"
            ]
          },
          "series": {
            "type": "string",
            "example": "JYW-SPB5D",
            "description": "Серия каталога."
          },
          "documentIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "doc_passport",
              "description": ""
            },
            "description": "Паспорт и CAD при наличии.",
            "minItems": 0
          }
        },
        "required": [
          "itemId",
          "sku",
          "name",
          "kind"
        ]
      },
      "Offer": {
        "type": "object",
        "properties": {
          "offerId": {
            "type": "string",
            "example": "of_18",
            "description": "Предложение продавца.",
            "minLength": 1
          },
          "sellerId": {
            "type": "string",
            "example": "seller_1",
            "description": "Продавец."
          },
          "currency": {
            "type": "string",
            "example": "RUB",
            "description": "Валюта.",
            "enum": [
              "RUB"
            ]
          },
          "unitPriceMinor": {
            "type": "integer",
            "example": 246000,
            "description": "Цена за штуку в копейках.",
            "minimum": 0
          },
          "taxMode": {
            "type": "string",
            "example": "vat_included",
            "description": "Как учтён НДС.",
            "enum": [
              "vat_included",
              "without_vat"
            ]
          },
          "stock": {
            "type": "integer",
            "example": 12,
            "description": "Количество на складе.",
            "minimum": 0
          },
          "minimum": {
            "type": "integer",
            "example": 1,
            "description": "Минимальная партия.",
            "minimum": 1
          },
          "step": {
            "type": "integer",
            "example": 1,
            "description": "Шаг заказа.",
            "minimum": 1
          },
          "updatedAt": {
            "type": "string",
            "example": "2026-12-03T10:00:00+03:00",
            "description": "Дата и время с часовым поясом.",
            "format": "date-time"
          }
        },
        "required": [
          "offerId",
          "sellerId",
          "currency",
          "unitPriceMinor",
          "taxMode",
          "stock",
          "minimum",
          "step",
          "updatedAt"
        ]
      },
      "Part": {
        "type": "object",
        "properties": {
          "clientLineId": {
            "type": "string",
            "example": "10",
            "description": "Постоянный номер строки в системе покупателя.",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "example": "Втулка опорная",
            "description": "Наименование детали."
          },
          "quantity": {
            "type": "integer",
            "example": 10,
            "description": "Количество в штуках.",
            "minimum": 1
          },
          "drawingRevision": {
            "type": "string",
            "example": "B",
            "description": "Ревизия чертежа отдельной детали.",
            "minLength": 1
          },
          "sourceSku": {
            "type": "string",
            "example": "VT-20",
            "description": "Исходный складской артикул при доработке исполнения."
          },
          "material": {
            "type": "string",
            "example": "Д16Т",
            "description": "Материал по техническому заданию."
          },
          "process": {
            "type": "string",
            "example": "turning",
            "description": "Способ изготовления.",
            "enum": [
              "turning",
              "milling",
              "engineer_selects"
            ]
          },
          "finish": {
            "type": "string",
            "example": "Без покрытия",
            "description": "Требование к покрытию."
          },
          "inspection": {
            "type": "string",
            "example": "Контроль отверстия по чертежу",
            "description": "Контроль качества и допуски."
          },
          "fileIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "file_pdf_b",
              "description": "Идентификатор загруженного оригинала.",
              "minLength": 1
            },
            "description": "Файлы конкретной детали.",
            "minItems": 1
          }
        },
        "required": [
          "clientLineId",
          "name",
          "quantity",
          "drawingRevision",
          "fileIds"
        ]
      },
      "QuoteLine": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "ql_bushing",
            "description": "Идентификатор строки КП.",
            "minLength": 1
          },
          "clientLineId": {
            "type": "string",
            "example": "10",
            "description": "Постоянный номер строки в системе покупателя.",
            "minLength": 1
          },
          "quantity": {
            "type": "integer",
            "example": 10,
            "description": "Количество в штуках.",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "example": "offered",
            "description": "Готовность коммерческих условий.",
            "enum": [
              "offered",
              "needs_review"
            ]
          },
          "unitPriceMinor": {
            "type": "integer",
            "example": 61500,
            "description": "Цена за штуку в копейках.",
            "minimum": 0
          },
          "lineTotalMinor": {
            "type": "integer",
            "example": 615000,
            "description": "Стоимость партии в копейках.",
            "minimum": 0
          },
          "drawingRevision": {
            "type": "string",
            "example": "B",
            "description": "Ревизия чертежа отдельной детали.",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "clientLineId",
          "quantity",
          "status"
        ]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "qt_422",
            "description": "Идентификатор КП.",
            "minLength": 1
          },
          "quoteVersion": {
            "type": "integer",
            "example": 3,
            "description": "Версия коммерческого предложения.",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "example": "offered",
            "description": "Состояние КП.",
            "enum": [
              "offered",
              "pending",
              "needs_review",
              "expired"
            ]
          },
          "manufacturingRequestId": {
            "type": "string",
            "example": "mr_52",
            "description": "Заявка на изготовление.",
            "minLength": 1
          },
          "requestRevision": {
            "type": "integer",
            "example": 2,
            "description": "Версия комплекта файлов и требований проекта.",
            "minimum": 1
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteLine"
            },
            "description": "Предлагаемые позиции.",
            "minItems": 0
          },
          "totalMinor": {
            "type": "integer",
            "example": 615000,
            "description": "Стоимость с доставкой в копейках.",
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "example": "RUB",
            "description": "Валюта расчёта.",
            "enum": [
              "RUB"
            ]
          },
          "taxMode": {
            "type": "string",
            "example": "without_vat",
            "description": "Как учтён НДС.",
            "enum": [
              "without_vat",
              "vat_included"
            ]
          },
          "shippingMinor": {
            "type": "integer",
            "example": 0,
            "description": "Стоимость доставки в копейках.",
            "minimum": 0
          },
          "leadBusinessDays": {
            "type": "integer",
            "example": 7,
            "description": "Срок в рабочих днях.",
            "minimum": 1
          },
          "validUntil": {
            "type": "string",
            "example": "2026-12-10T18:00:00+03:00",
            "description": "Дата и время с часовым поясом.",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "quoteVersion",
          "status",
          "lines"
        ]
      },
      "QuoteDraft": {
        "type": "object",
        "properties": {
          "externalRequestId": {
            "type": "string",
            "example": "ЗК-1842",
            "description": "Номер спецификации в ERP."
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "clientLineId": {
                  "type": "string",
                  "example": "10",
                  "description": "Постоянный номер строки в системе покупателя.",
                  "minLength": 1
                },
                "sku": {
                  "type": "string",
                  "example": "JYW-SPB5D0850",
                  "description": "Артикул исполнения.",
                  "minLength": 1
                },
                "quantity": {
                  "type": "integer",
                  "example": 15,
                  "description": "Требуемое количество.",
                  "minimum": 1
                },
                "offerId": {
                  "type": "string",
                  "example": "of_18",
                  "description": "Предпочитаемое предложение."
                }
              },
              "required": [
                "clientLineId",
                "sku",
                "quantity"
              ]
            },
            "description": "Запрашиваемые позиции.",
            "minItems": 1
          },
          "destination": {
            "type": "string",
            "example": "Самовывоз, Санкт-Петербург",
            "description": "Способ и место получения."
          },
          "shipmentPolicy": {
            "type": "string",
            "example": "as_ready",
            "description": "По готовности или одной партией.",
            "enum": [
              "as_ready",
              "together"
            ]
          },
          "sourceOrderId": {
            "type": "string",
            "example": "ord_815",
            "description": "Идентификатор заказа SUNTOOLS.",
            "minLength": 1
          }
        },
        "required": [
          "lines",
          "destination",
          "shipmentPolicy"
        ]
      },
      "ManufacturingRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "mr_52",
            "description": "Заявка на изготовление.",
            "minLength": 1
          },
          "requestRevision": {
            "type": "integer",
            "example": 2,
            "description": "Версия комплекта файлов и требований проекта.",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "example": "engineering_review",
            "description": "Состояние проекта.",
            "enum": [
              "engineering_review",
              "quote_ready",
              "ordered"
            ]
          },
          "parts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Part"
            },
            "description": "Одна или несколько деталей проекта.",
            "minItems": 1
          },
          "quoteId": {
            "type": "string",
            "example": "qt_422",
            "description": "Идентификатор КП.",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "requestRevision",
          "status",
          "parts"
        ]
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "ord_815",
            "description": "Идентификатор заказа SUNTOOLS.",
            "minLength": 1
          },
          "externalOrderId": {
            "type": "string",
            "example": "ПЗ-1843",
            "description": "Уникальный номер закупки предприятия.",
            "minLength": 1
          },
          "version": {
            "type": "integer",
            "example": 2,
            "description": "Номер текущей версии.",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "example": "submitted",
            "description": "Состояние заказа.",
            "enum": [
              "submitted",
              "confirmed",
              "rejected",
              "cancelled",
              "in_progress",
              "completed"
            ]
          },
          "quoteId": {
            "type": "string",
            "example": "qt_422",
            "description": "Идентификатор КП.",
            "minLength": 1
          },
          "quoteVersion": {
            "type": "integer",
            "example": 3,
            "description": "Версия коммерческого предложения.",
            "minimum": 1
          },
          "requestRevision": {
            "type": "integer",
            "example": 2,
            "description": "Версия комплекта файлов и требований проекта.",
            "minimum": 1
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "ol_1",
                  "description": "Строка заказа.",
                  "minLength": 1
                },
                "quoteLineId": {
                  "type": "string",
                  "example": "ql_bushing",
                  "description": "Исходная строка КП."
                },
                "quantity": {
                  "type": "integer",
                  "example": 10,
                  "description": "Количество в штуках.",
                  "minimum": 1
                },
                "shipped": {
                  "type": "integer",
                  "example": 0,
                  "description": "Обычные отгрузки.",
                  "minimum": 0
                },
                "receivedGood": {
                  "type": "integer",
                  "example": 0,
                  "description": "Принято годных.",
                  "minimum": 0
                },
                "cancelled": {
                  "type": "integer",
                  "example": 0,
                  "description": "Отменено продавцом.",
                  "minimum": 0
                }
              },
              "required": [
                "id",
                "quoteLineId",
                "quantity",
                "shipped",
                "receivedGood",
                "cancelled"
              ]
            },
            "description": "Строки и баланс исполнения.",
            "minItems": 0
          }
        },
        "required": [
          "id",
          "externalOrderId",
          "version",
          "status",
          "quoteId",
          "quoteVersion",
          "lines"
        ]
      },
      "ProductionLine": {
        "type": "object",
        "properties": {
          "orderLineId": {
            "type": "string",
            "example": "ol_1",
            "description": "Строка заказа.",
            "minLength": 1
          },
          "drawingRevision": {
            "type": "string",
            "example": "B",
            "description": "Ревизия чертежа отдельной детали.",
            "minLength": 1
          },
          "stage": {
            "type": "string",
            "example": "ready",
            "description": "Очередь производства, в работе или готово.",
            "enum": [
              "queued",
              "in_progress",
              "ready"
            ]
          },
          "estimatedReadyAt": {
            "type": "string",
            "example": "2026-12-03T10:00:00+03:00",
            "description": "Дата и время с часовым поясом.",
            "format": "date-time"
          }
        },
        "required": [
          "orderLineId",
          "drawingRevision",
          "stage",
          "estimatedReadyAt"
        ]
      },
      "ShipmentLine": {
        "type": "object",
        "properties": {
          "shipmentLineId": {
            "type": "string",
            "example": "sl_1",
            "description": "Строка упаковочного листа."
          },
          "orderLineId": {
            "type": "string",
            "example": "ol_1",
            "description": "Строка заказа.",
            "minLength": 1
          },
          "quantity": {
            "type": "integer",
            "example": 12,
            "description": "Количество по листу.",
            "minimum": 1
          },
          "drawingRevision": {
            "type": "string",
            "example": "B",
            "description": "Ревизия чертежа отдельной детали.",
            "minLength": 1
          }
        },
        "required": [
          "shipmentLineId",
          "orderLineId",
          "quantity"
        ]
      },
      "Shipment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "sh_901",
            "description": "Идентификатор отправления.",
            "minLength": 1
          },
          "orderId": {
            "type": "string",
            "example": "ord_815",
            "description": "Идентификатор заказа SUNTOOLS.",
            "minLength": 1
          },
          "packingNumber": {
            "type": "string",
            "example": "УЛ-901",
            "description": "Номер упаковочного листа."
          },
          "carrier": {
            "type": "string",
            "example": "Самовывоз",
            "description": "Способ передачи."
          },
          "trackingNumber": {
            "type": "string",
            "example": "TRACK-901",
            "description": "Номер перевозчика, если выдан."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShipmentLine"
            },
            "description": "Позиции отправления.",
            "minItems": 1
          },
          "claimId": {
            "type": "string",
            "example": "cl_508",
            "description": "Исходное обращение для корректирующей поставки."
          }
        },
        "required": [
          "id",
          "orderId",
          "packingNumber",
          "carrier",
          "lines"
        ]
      },
      "ReceiptLine": {
        "type": "object",
        "properties": {
          "shipmentLineId": {
            "type": "string",
            "example": "sl_1",
            "description": "Строка листа."
          },
          "good": {
            "type": "integer",
            "example": 11,
            "description": "Годные.",
            "minimum": 0
          },
          "damaged": {
            "type": "integer",
            "example": 0,
            "description": "Повреждённые в пути.",
            "minimum": 0
          },
          "missing": {
            "type": "integer",
            "example": 1,
            "description": "Недостающие.",
            "minimum": 0
          },
          "nonconforming": {
            "type": "integer",
            "example": 0,
            "description": "Отклонены контролем качества. По умолчанию 0.",
            "minimum": 0
          },
          "inspectionFileIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "file_act_1",
              "description": ""
            },
            "description": "Акты и протоколы.",
            "minItems": 0
          }
        },
        "required": [
          "shipmentLineId",
          "good",
          "damaged",
          "missing"
        ]
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "rc_417",
            "description": "Номер приёмки."
          },
          "shipmentId": {
            "type": "string",
            "example": "sh_901",
            "description": "Идентификатор отправления.",
            "minLength": 1
          },
          "claimIds": {
            "type": "array",
            "items": {
              "type": "string",
              "example": "cl_508",
              "description": ""
            },
            "description": "Связанные обращения.",
            "minItems": 0
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReceiptLine"
            },
            "description": "Принятые строки.",
            "minItems": 1
          }
        },
        "required": [
          "id",
          "shipmentId",
          "claimIds",
          "lines"
        ]
      },
      "Claim": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "cl_508",
            "description": "Номер обращения."
          },
          "shipmentId": {
            "type": "string",
            "example": "sh_901",
            "description": "Идентификатор отправления.",
            "minLength": 1
          },
          "shipmentLineId": {
            "type": "string",
            "example": "sl_1",
            "description": "Строка исходного листа."
          },
          "kind": {
            "type": "string",
            "example": "missing",
            "description": "Причина обращения.",
            "enum": [
              "missing",
              "damaged",
              "nonconforming"
            ]
          },
          "openQuantity": {
            "type": "integer",
            "example": 1,
            "description": "Открытое количество.",
            "minimum": 0
          },
          "status": {
            "type": "string",
            "example": "open",
            "description": "Состояние обращения.",
            "enum": [
              "open",
              "in_resolution",
              "closed"
            ]
          }
        },
        "required": [
          "id",
          "shipmentId",
          "shipmentLineId",
          "kind",
          "openQuantity",
          "status"
        ]
      },
      "ChangeRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "chg_7",
            "description": "Номер запроса."
          },
          "orderId": {
            "type": "string",
            "example": "ord_815",
            "description": "Идентификатор заказа SUNTOOLS.",
            "minLength": 1
          },
          "status": {
            "type": "string",
            "example": "pending",
            "description": "Результат рассмотрения.",
            "enum": [
              "pending",
              "applied",
              "rejected"
            ]
          },
          "reason": {
            "type": "string",
            "example": "Ожидает решения склада",
            "description": "Комментарий к решению."
          }
        },
        "required": [
          "id",
          "orderId",
          "status"
        ]
      },
      "Event": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "example": "ev_100",
            "description": "Ключ для исключения повторов."
          },
          "type": {
            "type": "string",
            "example": "production.line_ready",
            "description": "Вид события."
          },
          "resourceId": {
            "type": "string",
            "example": "ord_815",
            "description": "Идентификатор заказа SUNTOOLS.",
            "minLength": 1
          },
          "resourceVersion": {
            "type": "integer",
            "example": 2,
            "description": "Номер текущей версии.",
            "minimum": 1
          },
          "occurredAt": {
            "type": "string",
            "example": "2026-12-03T10:00:00+03:00",
            "description": "Дата и время с часовым поясом.",
            "format": "date-time"
          }
        },
        "required": [
          "eventId",
          "type",
          "resourceId",
          "resourceVersion",
          "occurredAt"
        ]
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "doc_81",
            "description": "Идентификатор версии файла."
          },
          "type": {
            "type": "string",
            "example": "packing_list",
            "description": "Вид документа.",
            "enum": [
              "packing_list",
              "invoice",
              "inspection",
              "correction",
              "passport",
              "cad"
            ]
          },
          "number": {
            "type": "string",
            "example": "УЛ-901",
            "description": "Номер документа."
          },
          "version": {
            "type": "integer",
            "example": 2,
            "description": "Номер текущей версии.",
            "minimum": 1
          }
        },
        "required": [
          "id",
          "type",
          "number",
          "version"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "version_conflict",
            "description": "Машинный код."
          },
          "message": {
            "type": "string",
            "example": "Версия изменилась",
            "description": "Причина отказа."
          },
          "requestId": {
            "type": "string",
            "example": "req_901",
            "description": "Идентификатор для поддержки."
          },
          "lineId": {
            "type": "string",
            "example": "10",
            "description": "Проблемная строка, если определена."
          }
        },
        "required": [
          "code",
          "message",
          "requestId"
        ]
      }
    },
    "securitySchemes": {
      "clientCredentials": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://auth.suntools.example/oauth/token",
            "scopes": {
              "catalog.read": "Чтение каталога и предложений",
              "quotes.read": "Чтение коммерческих предложений",
              "quotes.write": "Запрос условий закупки",
              "drawings.write": "Передача технического комплекта",
              "drawings.read": "Чтение проектов и файлов",
              "seller.quote": "Выпуск КП исполнителем",
              "orders.write": "Управление заказами покупателя",
              "orders.read": "Чтение закупок организации",
              "seller.fulfill": "Подтверждения и факты исполнителя",
              "receipts.write": "Подтверждение складом покупателя",
              "events.read": "Чтение событий организации"
            }
          }
        }
      }
    }
  }
}
