{
    "openapi": "3.0.3",
    "info": {
        "title": "ShipPickup API",
        "version": "v1",
        "description": "Публичный API ShipPickup. Источник правды по форматам: этот файл (по нему же строится консоль API в кабинете).\n\n**Аутентификация.** Заголовок `Authorization: Bearer <ключ>`. Ключ `sk_test_...` работает только в песочнице\n(тестовый режим, баланс не списывается), `sk_live_...` только в боевом режиме. Ключ создаётся в кабинете и\nпоказывается один раз; к нему можно привязать права и список разрешённых IP.\n\n**Формат ответов.** Успех: `{\"data\": ..., \"meta\": {...}}`. Ошибка: `{\"error\": {\"code\": \"...\", \"message\": \"...\", \"details\": {...}}}`.\nПоле `code` стабильно и предназначено для программ, `message` для людей. HTTP-статус всегда отражает результат.\nВ каждом ответе есть заголовки `X-Request-Id` (сообщайте его в поддержку) и, для запросов с ключом, `X-RateLimit-Limit` / `X-RateLimit-Remaining`.\n\n**Версии и устаревание.** Версия в адресе (`/api/v1`). Внутри версии мы только добавляем поля и методы, поведение существующих не меняем.\nНесовместимые изменения выходят в новой версии. Устаревшая версия получает заголовки `Deprecation` и `Sunset` (дата отключения)\nне меньше чем за 6 месяцев; после даты отключения версия и её код удаляются полностью, старого кода мы не держим.\n"
    },
    "servers": [
        {
            "url": "https://api.shippickup.com/v1"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "paths": {
        "/ping": {
            "get": {
                "operationId": "get_ping",
                "summary": "Проверка доступности",
                "security": [],
                "responses": {
                    "200": {
                        "description": "Сервис работает",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Ping"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/balance": {
            "get": {
                "operationId": "get_balance",
                "summary": "Баланс",
                "description": "Нужно право `balance:read`.",
                "responses": {
                    "200": {
                        "description": "Текущий баланс",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BalanceResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/rates": {
            "post": {
                "operationId": "get_shipping_rates",
                "summary": "Тарифы",
                "description": "Нужно право `rates:read`. Возвращает предложения для маршрута и посылки, отсортированные по цене.\nЦена `price_cents` это то, что заплатит клиент. Для создания лейбла передаётся `rate_id` (действует 15 минут,\nпривязан к цене и сервису, подделать нельзя).\n",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/RatesRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Список тарифов",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/RatesResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "description": "Ошибка в полях запроса (`error.details` содержит поле и причину)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/shipments": {
            "post": {
                "operationId": "create_shipment",
                "summary": "Купить лейбл",
                "description": "Нужно право `labels:create`, только боевой ключ (тестовый получит 403 `test_key_cannot_buy`).\nОбязателен заголовок `Idempotency-Key` (16–64 символа `A-Za-z0-9_-`): повтор запроса с тем же ключом возвращает тот же заказ и не списывает деньги второй раз.\n`rate_id` берётся из `POST /rates` и годится только для той же посылки и маршрута, действует 15 минут.\nСумма списывается с баланса заранее; если лейбл создать не удалось, деньги возвращаются автоматически.\n",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ShipmentCreateRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Заказ создан (200, если это повтор с тем же Idempotency-Key)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ShipmentResponse"
                                }
                            }
                        }
                    },
                    "402": {
                        "description": "Недостаточно средств на балансе (`insufficient_funds`)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Тариф устарел (`rate_expired`) или конфликт",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Ошибка в полях запроса",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Поставщик не создал лейбл, деньги возвращены (`provider_error`)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "get": {
                "operationId": "list_shipments",
                "summary": "Список заказов",
                "description": "Право `labels:read`. Новые первыми. Фильтры сочетаются: `status`, `carrier`, `created_from` / `created_to` (дата или время ISO 8601, UTC),\n`updated_since` (изменённые с указанного времени), `tracking_number`, `reference` (ваш номер заказа, переданный при создании).\nПостранично: курсором (`cursor` из `meta.next_cursor`, рекомендуется) или `offset`; `limit` до 100.\n",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Например label_ready, in_transit, delivered, cancelled"
                    },
                    {
                        "name": "carrier",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Перевозчик, как в поле carrier заказа (без учёта регистра)"
                    },
                    {
                        "name": "created_from",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date-time"
                        }
                    },
                    {
                        "name": "created_to",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date-time"
                        }
                    },
                    {
                        "name": "updated_since",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date-time"
                        }
                    },
                    {
                        "name": "tracking_number",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "reference",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "maxLength": 64
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "default": 0
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Список заказов",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ShipmentListResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shipments/{id}": {
            "get": {
                "operationId": "get_shipment",
                "summary": "Заказ",
                "description": "Право `labels:read`. `id` это номер заказа или трек-номер.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Заказ",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ShipmentResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Заказ не найден",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shipments/{id}/cancel": {
            "post": {
                "operationId": "cancel_shipment",
                "summary": "Отменить заказ",
                "description": "Право `labels:cancel`. Отменить можно заказ, пока посылка не передана перевозчику. Повторная отмена безопасна (идемпотентна): ответ 200 с `meta.already_cancelled = true`, деньги второй раз не возвращаются.\nВозврат: деньги за лейбл возвращаются на баланс через `meta.refund_delay_days` дней после отмены (дата в `meta.refund_due_at`); пока возврат не выплачен, `meta.refund_cents` равно 0.\nВозврат всегда полный и выполняется один раз (одна проводка на заказ). Отменить сразу несколько заказов: `POST /shipments/cancel`.\n",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "reason": {
                                        "type": "string",
                                        "maxLength": 255
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Заказ с новым статусом; `meta.refund_cents` сколько возвращено",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ShipmentResponse"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Заказ уже нельзя отменить",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shipments/{id}/tracking": {
            "get": {
                "operationId": "get_tracking",
                "summary": "Отслеживание",
                "description": "Право `tracking:read`. Заказ и события пути, новые первыми.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Заказ с полем events",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ShipmentTrackingResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Заказ не найден",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shipments/{id}/pickup_slots": {
            "get": {
                "operationId": "get_pickup_slots",
                "summary": "Даты и окна забора",
                "description": "Право `labels:read`. Доступные даты забора курьером у перевозчика, на котором куплен заказ (кэш несколько минут). `meta.fee_cents` стоимость забора для вас в USD (0 = бесплатно).",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Список дней, в каждом окна с `id` (его передают в POST /pickup)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "date": {
                                                        "type": "string",
                                                        "format": "date"
                                                    },
                                                    "windows": {
                                                        "type": "array",
                                                        "items": {
                                                            "type": "object",
                                                            "properties": {
                                                                "id": {
                                                                    "type": "string"
                                                                },
                                                                "from": {
                                                                    "type": "string"
                                                                },
                                                                "to": {
                                                                    "type": "string"
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Забор для этого заказа недоступен",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Перевозчик не ответил",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shipments/{id}/pickup": {
            "post": {
                "operationId": "schedule_pickup",
                "summary": "Заказать забор",
                "description": "Право `labels:create`, только боевым ключом (плата за забор списывается с баланса). Заказывает забор у перевозчика заказа; один заказ - один действующий забор.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "slot_id"
                                ],
                                "properties": {
                                    "slot_id": {
                                        "type": "string",
                                        "description": "id окна из GET /pickup_slots"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Заказ с полем `pickup` (status, date, window_from, window_to, reference, fee_cents)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ShipmentResponse"
                                }
                            }
                        }
                    },
                    "402": {
                        "description": "Не хватает денег на оплату забора",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Забор уже заказан или заказ не готов",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Этого окна больше нет",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "Перевозчик не принял заявку, деньги за забор возвращены",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shipments/{id}/pickup/cancel": {
            "post": {
                "operationId": "cancel_pickup",
                "summary": "Отменить забор",
                "description": "Право `labels:cancel`. Отменяет забор у перевозчика и возвращает плату за него на баланс. Сам заказ (лейбл) остаётся.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Заказ с полем `pickup`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ShipmentResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Действующего забора нет",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Перевозчик не принял отмену",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shipments/cancel": {
            "post": {
                "operationId": "post_shipments_cancel",
                "summary": "Отменить несколько заказов",
                "description": "Право `labels:cancel`. Обязателен `Idempotency-Key`. До 50 номеров заказов за запрос. Ответ всегда 200, итог по каждому заказу в `data[].result`:\n`cancelled` (отменён), `already_cancelled` (был отменён раньше), `cannot_cancel` (нельзя отменить, причина в `reason`), `not_found` (заказа нет среди заказов аккаунта), `failed` (временный сбой, повторите позже).\nВозврат денег идёт через общий механизм отмены: деньги за отменённый клиентом лейбл возвращаются на баланс через `meta.refund_delay_days` дней (поле `refund_due_at` у каждого отменённого заказа).\n",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/CancelBatchRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Результат по каждому заказу",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/CancelBatchResponse"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/shipments/{id}/label": {
            "get": {
                "operationId": "get_shipments_id_label",
                "summary": "Скачать лейбл (PDF)",
                "description": "Право `labels:read`. Отдаёт PDF лейбла своего заказа (`Content-Type: application/pdf`). Лейбл есть у заказа, пока `label_available` равно true и заказ не отменён.\nЕсли лейбл ещё не готов или заказ отменён, ответ 409 `conflict`. `id` это номер заказа.\n",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "PDF лейбла",
                        "content": {
                            "application/pdf": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    }
                }
            }
        },
        "/deposits": {
            "post": {
                "operationId": "post_deposits",
                "summary": "Создать счёт на пополнение баланса (USDT TRC20)",
                "description": "Право `deposits:create`, только боевой ключ (тестовый получит 403 `test_key_cannot_buy`). Обязателен `Idempotency-Key`: повтор с тем же ключом возвращает тот же счёт.\nСчёт содержит адрес кошелька и ТОЧНУЮ сумму перевода в USDT (сеть TRC20): переводите ровно эту сумму одним платежом. Деньги зачисляются только автоматически, когда перевод найден в блокчейне;\nчерез API зачислить деньги нельзя. Срок жизни счёта указан в `expires_at`. Одновременно открыто не больше 5 счетов. Пределы суммы возвращает ошибка 422 (`min_cents`, `max_cents`).\nО зачислении приходит событие вебхука `balance.topup`.\n",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/DepositCreateRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Счёт создан (200 для повтора с тем же Idempotency-Key)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DepositResponse"
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    },
                    "503": {
                        "description": "Приём пополнений временно недоступен (`provider_unavailable`)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "get": {
                "operationId": "get_deposits",
                "summary": "Список счетов на пополнение",
                "description": "Право `deposits:read`. Новые первыми, постранично (`limit` до 100, `cursor` из `meta.next_cursor`). Фильтр `status`.",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "pending",
                                "credited",
                                "expired",
                                "failed"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Список счетов",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DepositListResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/deposits/{id}": {
            "get": {
                "operationId": "get_deposits_id",
                "summary": "Статус счёта на пополнение",
                "description": "Право `deposits:read`. Статусы `pending` (ждём перевод), `credited` (зачислен, есть `tx_hash` и `received_cents`), `expired` (срок истёк), `failed` (отклонён).",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Счёт",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DepositResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/addresses": {
            "get": {
                "operationId": "get_addresses",
                "summary": "Адресная книга",
                "description": "Право `addresses:read`. Только адреса вашего аккаунта. Фильтр `kind` (`sender` или `recipient`; общие адреса `both` попадают в оба), поиск `q`, постранично.",
                "parameters": [
                    {
                        "name": "kind",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "sender",
                                "recipient"
                            ]
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "maxLength": 100
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "default": 0
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Список адресов",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AddressListResponse"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "post_addresses",
                "summary": "Добавить адрес",
                "description": "Право `addresses:write`. Обязателен `Idempotency-Key`. Поля проверяются так же, как в кабинете (индекс и штат для страны, длины полей перевозчиков).",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/AddressInput"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Адрес создан",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AddressResponse"
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            }
        },
        "/addresses/{id}": {
            "get": {
                "operationId": "get_addresses_id",
                "summary": "Адрес",
                "description": "Право `addresses:read`. Чужой или удалённый адрес даёт 404.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Адрес",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AddressResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            },
            "put": {
                "operationId": "put_addresses_id",
                "summary": "Изменить адрес",
                "description": "Право `addresses:write`. Полная замена полей (как при создании). Обязателен `Idempotency-Key`.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/AddressInput"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Адрес обновлён",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AddressResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            },
            "delete": {
                "operationId": "delete_addresses_id",
                "summary": "Удалить адрес",
                "description": "Право `addresses:write`. Адрес пропадает из списков (старые заказы хранят свою копию). Повторное удаление даёт 404.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Адрес удалён",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "string"
                                                },
                                                "deleted": {
                                                    "type": "boolean"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/team": {
            "get": {
                "operationId": "get_team",
                "summary": "Участники команды",
                "description": "Право `team:read`. Участники рабочего пространства, роли (`owner`, `admin`, `staff`) и статус.",
                "responses": {
                    "200": {
                        "description": "Список участников",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TeamListResponse"
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    }
                }
            }
        },
        "/team/invitations": {
            "get": {
                "operationId": "get_team_invitations",
                "summary": "Действующие приглашения",
                "description": "Право `team:read`. Приглашения, которые ещё не приняты и не истекли.",
                "responses": {
                    "200": {
                        "description": "Список приглашений",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/InvitationListResponse"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "post_team_invitations",
                "summary": "Пригласить сотрудника",
                "description": "Право `team:manage`, только боевой ключ, созданный владельцем аккаунта. Обязателен `Idempotency-Key`. Приглашение уходит на почту, ссылка действует 7 дней.\nРоль `owner` через API назначить нельзя. Действие записывается в журнал аудита, владельцу приходит уведомление. Лимит 20 запросов в минуту на команду.\n",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/InvitationRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Приглашение создано",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/InvitationResponse"
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            }
        },
        "/team/invitations/{id}": {
            "delete": {
                "operationId": "delete_team_invitations_id",
                "summary": "Отозвать приглашение",
                "description": "Право `team:manage`, ключ владельца. Ссылка из приглашения перестаёт работать.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Приглашение отозвано",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "string"
                                                },
                                                "revoked": {
                                                    "type": "boolean"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/team/{id}": {
            "patch": {
                "operationId": "patch_team_id",
                "summary": "Сменить роль участника",
                "description": "Право `team:manage`, ключ владельца. Допустимые роли: `admin`, `staff`. Владельца понизить нельзя, повысить до `owner` через API нельзя.\nОбязателен `Idempotency-Key`.\n",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/RoleRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Роль изменена",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/TeamMemberResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            },
            "delete": {
                "operationId": "delete_team_id",
                "summary": "Убрать участника",
                "description": "Право `team:manage`, ключ владельца. Владельца убрать нельзя; последнего владельца аккаунта убрать нельзя.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Участник убран",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "string"
                                                },
                                                "removed": {
                                                    "type": "boolean"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    }
                }
            }
        },
        "/webhooks": {
            "get": {
                "operationId": "get_webhooks",
                "summary": "Список вебхуков",
                "description": "Право `webhooks:read`. Секрет подписи не возвращается.",
                "responses": {
                    "200": {
                        "description": "Список вебхуков",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookListResponse"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "post_webhooks",
                "summary": "Создать вебхук",
                "description": "Право `webhooks:write`. Обязателен `Idempotency-Key`. Адрес только `https`, внутренние адреса запрещены. До 10 вебхуков на аккаунт.\nСекрет подписи `secret` показывается один раз, в этом ответе; повтор запроса с тем же Idempotency-Key вернёт тот же вебхук без секрета.\n",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookCreateRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Вебхук создан, `data.secret` показан один раз",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookResponse"
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            }
        },
        "/webhooks/{id}": {
            "get": {
                "operationId": "get_webhooks_id",
                "summary": "Вебхук",
                "description": "Право `webhooks:read`.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Вебхук",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            },
            "patch": {
                "operationId": "patch_webhooks_id",
                "summary": "Изменить вебхук",
                "description": "Право `webhooks:write`. Можно изменить `url`, `events`, `active` (передавайте только изменяемые поля). Обязателен `Idempotency-Key`.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookUpdateRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Вебхук обновлён",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            },
            "delete": {
                "operationId": "delete_webhooks_id",
                "summary": "Удалить вебхук",
                "description": "Право `webhooks:write`. Вместе с вебхуком удаляется журнал его доставок.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Вебхук удалён",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "integer"
                                                },
                                                "deleted": {
                                                    "type": "boolean"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/webhooks/{id}/test": {
            "post": {
                "operationId": "post_webhooks_id_test",
                "summary": "Отправить тестовое событие",
                "description": "Право `webhooks:write`. На адрес вебхука уходит событие `ping`, подписанное секретом. В ответе итог отправки (`delivered`, `pending` или `failed`).",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Итог отправки",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookDeliveryResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/webhooks/{id}/rotate_secret": {
            "post": {
                "operationId": "post_webhooks_id_rotate_secret",
                "summary": "Заменить секрет подписи",
                "description": "Право `webhooks:write`. Обязателен `Idempotency-Key`. Новый секрет показывается один раз, старый перестаёт действовать сразу.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Новый секрет в `data.secret`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/webhooks/{id}/deliveries": {
            "get": {
                "operationId": "get_webhooks_id_deliveries",
                "summary": "Журнал доставок вебхука",
                "description": "Право `webhooks:read`. Новые первыми, постранично (`limit` до 100, `cursor`). Фильтр `status`. Тело события в журнал ответа не входит.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "pending",
                                "delivered",
                                "failed"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    },
                    {
                        "name": "cursor",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Список доставок",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookDeliveryListResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/webhooks/{id}/deliveries/{delivery_id}/resend": {
            "post": {
                "operationId": "post_webhooks_id_deliveries_delivery_id_resend",
                "summary": "Повторить доставку",
                "description": "Право `webhooks:write`. Отправляет то же событие (с тем же `id`) ещё раз и возвращает итог.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "delivery_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Итог отправки",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookDeliveryResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "responses": {
            "Unauthorized": {
                "description": "Нет или неверный ключ (`unauthenticated`, `invalid_key`)",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "Forbidden": {
                "description": "Нет права у ключа (`insufficient_scope`) или IP не разрешён (`ip_not_allowed`)",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "RateLimited": {
                "description": "Превышен лимит запросов ключа (`rate_limited`), заголовок `Retry-After` в секундах",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "NotFound": {
                "description": "Объект не найден среди объектов вашего аккаунта (`not_found`)",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "Conflict": {
                "description": "Действие сейчас невозможно (`conflict`), причина в `error.message`",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "Validation": {
                "description": "Ошибка в полях запроса (`validation_failed`, `error.details` содержит поле и причину) или неверный Idempotency-Key (`idempotency_key_required`, `idempotency_key_reused`)",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "object",
                        "required": [
                            "code",
                            "message"
                        ],
                        "properties": {
                            "code": {
                                "type": "string",
                                "example": "validation_failed"
                            },
                            "message": {
                                "type": "string"
                            },
                            "details": {
                                "type": "object",
                                "additionalProperties": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "Ping": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "status": {
                                "type": "string",
                                "example": "ok"
                            },
                            "version": {
                                "type": "string",
                                "example": "v1"
                            }
                        }
                    }
                }
            },
            "BalanceResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "currency": {
                                "type": "string",
                                "example": "USD"
                            },
                            "balance_cents": {
                                "type": "integer",
                                "example": 124860
                            },
                            "balance": {
                                "type": "string",
                                "example": "1248.60"
                            }
                        }
                    }
                }
            },
            "Address": {
                "type": "object",
                "required": [
                    "country",
                    "postal_code"
                ],
                "properties": {
                    "country": {
                        "type": "string",
                        "description": "ISO 3166-1 alpha-2",
                        "example": "DE"
                    },
                    "postal_code": {
                        "type": "string",
                        "example": "10117"
                    },
                    "city": {
                        "type": "string"
                    },
                    "line1": {
                        "type": "string"
                    },
                    "state": {
                        "type": "string"
                    }
                }
            },
            "Parcel": {
                "type": "object",
                "required": [
                    "weight_g",
                    "length_mm",
                    "width_mm",
                    "height_mm"
                ],
                "properties": {
                    "weight_g": {
                        "type": "integer",
                        "minimum": 1,
                        "description": "Вес в граммах",
                        "example": 2400
                    },
                    "length_mm": {
                        "type": "integer",
                        "minimum": 1,
                        "example": 300
                    },
                    "width_mm": {
                        "type": "integer",
                        "minimum": 1,
                        "example": 200
                    },
                    "height_mm": {
                        "type": "integer",
                        "minimum": 1,
                        "example": 150
                    }
                }
            },
            "RatesRequest": {
                "type": "object",
                "required": [
                    "from",
                    "to",
                    "parcel"
                ],
                "properties": {
                    "from": {
                        "$ref": "#/components/schemas/Address"
                    },
                    "to": {
                        "$ref": "#/components/schemas/Address"
                    },
                    "parcel": {
                        "$ref": "#/components/schemas/Parcel"
                    },
                    "declared_value_cents": {
                        "type": "integer",
                        "minimum": 0
                    }
                }
            },
            "Rate": {
                "type": "object",
                "properties": {
                    "rate_id": {
                        "type": "string",
                        "description": "Непрозрачный идентификатор тарифа, действует 15 минут"
                    },
                    "carrier": {
                        "type": "string",
                        "example": "UPS"
                    },
                    "service": {
                        "type": "string",
                        "example": "Express Saver"
                    },
                    "price_cents": {
                        "type": "integer",
                        "example": 4120
                    },
                    "price": {
                        "type": "string",
                        "example": "41.20"
                    },
                    "currency": {
                        "type": "string",
                        "example": "USD"
                    },
                    "eta_days_min": {
                        "type": "integer",
                        "nullable": true
                    },
                    "eta_days_max": {
                        "type": "integer",
                        "nullable": true
                    },
                    "pickup_supported": {
                        "type": "boolean"
                    },
                    "chargeable_weight_g": {
                        "type": "integer",
                        "description": "Вес, по которому считается тариф (больший из фактического и объёмного)"
                    }
                }
            },
            "ShipmentItem": {
                "type": "object",
                "required": [
                    "description",
                    "quantity",
                    "unit_value_cents"
                ],
                "properties": {
                    "description": {
                        "type": "string",
                        "example": "T-shirts"
                    },
                    "quantity": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "unit_value_cents": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Цена единицы в центах"
                    },
                    "category": {
                        "type": "string",
                        "example": "Одежда"
                    },
                    "hs_code": {
                        "type": "string",
                        "description": "Код ТН ВЭД (необязательно)"
                    },
                    "origin_country": {
                        "type": "string",
                        "example": "US"
                    }
                }
            },
            "ShipmentAddress": {
                "type": "object",
                "required": [
                    "name",
                    "line1",
                    "city",
                    "country",
                    "postal_code"
                ],
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "company": {
                        "type": "string"
                    },
                    "line1": {
                        "type": "string"
                    },
                    "line2": {
                        "type": "string"
                    },
                    "city": {
                        "type": "string"
                    },
                    "state": {
                        "type": "string"
                    },
                    "postal_code": {
                        "type": "string"
                    },
                    "country": {
                        "type": "string",
                        "example": "DE"
                    },
                    "phone": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    }
                }
            },
            "ShipmentCreateRequest": {
                "type": "object",
                "required": [
                    "rate_id",
                    "from",
                    "to",
                    "parcel"
                ],
                "properties": {
                    "rate_id": {
                        "type": "string"
                    },
                    "from": {
                        "$ref": "#/components/schemas/ShipmentAddress"
                    },
                    "to": {
                        "$ref": "#/components/schemas/ShipmentAddress"
                    },
                    "parcel": {
                        "$ref": "#/components/schemas/Parcel"
                    },
                    "items": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ShipmentItem"
                        },
                        "description": "Для международной отправки обязательно"
                    },
                    "declared_value_cents": {
                        "type": "integer",
                        "description": "По умолчанию сумма содержимого"
                    },
                    "services": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Коды дополнительных услуг"
                    },
                    "reference": {
                        "type": "string",
                        "maxLength": 64,
                        "description": "Ваш номер заказа (необязательно). Уникален в пределах аккаунта: повтор с другим Idempotency-Key даёт 409"
                    }
                }
            },
            "Shipment": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "reference": {
                        "type": "string",
                        "nullable": true,
                        "description": "Ваш номер заказа"
                    },
                    "status": {
                        "type": "string",
                        "example": "label_ready"
                    },
                    "carrier": {
                        "type": "string"
                    },
                    "service": {
                        "type": "string"
                    },
                    "tracking_number": {
                        "type": "string",
                        "nullable": true
                    },
                    "price_cents": {
                        "type": "integer"
                    },
                    "currency": {
                        "type": "string",
                        "example": "USD"
                    },
                    "from": {
                        "$ref": "#/components/schemas/ShipmentAddress"
                    },
                    "to": {
                        "$ref": "#/components/schemas/ShipmentAddress"
                    },
                    "declared_value_cents": {
                        "type": "integer"
                    },
                    "chargeable_weight_g": {
                        "type": "integer",
                        "nullable": true
                    },
                    "label_available": {
                        "type": "boolean"
                    },
                    "eta_from": {
                        "type": "string",
                        "format": "date",
                        "nullable": true
                    },
                    "eta_to": {
                        "type": "string",
                        "format": "date",
                        "nullable": true
                    },
                    "source": {
                        "type": "string",
                        "enum": [
                            "web",
                            "api"
                        ]
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "delivered_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "cancelled_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    }
                }
            },
            "ShipmentResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Shipment"
                    },
                    "meta": {
                        "type": "object"
                    }
                }
            },
            "ShipmentListResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Shipment"
                        }
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "total": {
                                "type": "integer"
                            },
                            "limit": {
                                "type": "integer"
                            },
                            "offset": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "ShipmentTrackingResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "allOf": [
                            {
                                "$ref": "#/components/schemas/Shipment"
                            },
                            {
                                "type": "object",
                                "properties": {
                                    "events": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "time": {
                                                    "type": "string",
                                                    "format": "date-time"
                                                },
                                                "status": {
                                                    "type": "string",
                                                    "nullable": true
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            },
            "RatesResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Rate"
                        }
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "count": {
                                "type": "integer"
                            },
                            "partial": {
                                "type": "boolean",
                                "description": "true, если часть тарифов недоступна"
                            }
                        }
                    }
                }
            },
            "WebhookEnvelope": {
                "type": "object",
                "description": "Тело запроса вебхука. Поле `data` зависит от `type`",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "evt_9f1c2a7b3d4e5f60",
                        "description": "Номер события, повторы приходят с тем же значением"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "shipment.created",
                            "shipment.status_changed",
                            "shipment.delivered",
                            "shipment.cancelled",
                            "extra_charge.created",
                            "balance.topup",
                            "ping"
                        ]
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "WebhookShipmentEvent": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "data": {
                                "description": "Заказ в том же виде, что в `GET /shipments/{id}`, без поля `pickup`",
                                "allOf": [
                                    {
                                        "$ref": "#/components/schemas/Shipment"
                                    }
                                ]
                            }
                        }
                    }
                ]
            },
            "WebhookStatusChangedEvent": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "data": {
                                "allOf": [
                                    {
                                        "$ref": "#/components/schemas/Shipment"
                                    },
                                    {
                                        "type": "object",
                                        "properties": {
                                            "previous_status": {
                                                "type": "string",
                                                "description": "Статус до изменения",
                                                "example": "label_ready"
                                            }
                                        }
                                    }
                                ]
                            }
                        }
                    }
                ]
            },
            "WebhookExtraChargeEvent": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "integer",
                                        "description": "Номер доплаты"
                                    },
                                    "shipment_id": {
                                        "type": "string",
                                        "description": "Номер заказа, как в API"
                                    },
                                    "amount_cents": {
                                        "type": "integer",
                                        "description": "Сумма к оплате с баланса, как в разделе «Доплаты» кабинета"
                                    },
                                    "currency": {
                                        "type": "string",
                                        "example": "USD"
                                    },
                                    "reason": {
                                        "type": "string"
                                    },
                                    "status": {
                                        "type": "string",
                                        "example": "new"
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "WebhookTopupEvent": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "object",
                                "properties": {
                                    "amount_cents": {
                                        "type": "integer"
                                    },
                                    "currency": {
                                        "type": "string",
                                        "example": "USD"
                                    },
                                    "balance_cents": {
                                        "type": "integer",
                                        "description": "Баланс сразу после пополнения"
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "CancelBatchRequest": {
                "type": "object",
                "required": [
                    "ids"
                ],
                "properties": {
                    "ids": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 50,
                        "items": {
                            "type": "string"
                        }
                    },
                    "reason": {
                        "type": "string",
                        "maxLength": 255
                    }
                }
            },
            "CancelBatchResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "string"
                                },
                                "result": {
                                    "type": "string",
                                    "enum": [
                                        "cancelled",
                                        "already_cancelled",
                                        "cannot_cancel",
                                        "not_found",
                                        "failed"
                                    ]
                                },
                                "reason": {
                                    "type": "string",
                                    "description": "Только для cannot_cancel и failed"
                                },
                                "refund_due_at": {
                                    "type": "string",
                                    "format": "date-time",
                                    "nullable": true
                                }
                            }
                        }
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "cancelled": {
                                "type": "integer"
                            },
                            "already_cancelled": {
                                "type": "integer"
                            },
                            "cannot_cancel": {
                                "type": "integer"
                            },
                            "not_found": {
                                "type": "integer"
                            },
                            "failed": {
                                "type": "integer"
                            },
                            "refund_delay_days": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "DepositCreateRequest": {
                "type": "object",
                "required": [
                    "amount_cents"
                ],
                "properties": {
                    "amount_cents": {
                        "type": "integer",
                        "minimum": 1,
                        "description": "Сумма пополнения в центах USD",
                        "example": 10000
                    }
                }
            },
            "Deposit": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "credited",
                            "expired",
                            "failed"
                        ]
                    },
                    "method": {
                        "type": "string",
                        "example": "usdt_trc20"
                    },
                    "network": {
                        "type": "string",
                        "example": "TRC20"
                    },
                    "amount_cents": {
                        "type": "integer",
                        "description": "Запрошенная сумма в центах USD"
                    },
                    "amount_usdt": {
                        "type": "string",
                        "description": "Точная сумма перевода в USDT",
                        "example": "100.017000"
                    },
                    "address": {
                        "type": "string",
                        "description": "Адрес кошелька для перевода"
                    },
                    "expires_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "received_cents": {
                        "type": "integer",
                        "nullable": true,
                        "description": "Сколько зачислено на баланс (когда status = credited)"
                    },
                    "tx_hash": {
                        "type": "string",
                        "nullable": true
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "credited_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    }
                }
            },
            "DepositResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Deposit"
                    }
                }
            },
            "DepositListResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Deposit"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/CursorMeta"
                    }
                }
            },
            "CursorMeta": {
                "type": "object",
                "properties": {
                    "limit": {
                        "type": "integer"
                    },
                    "has_more": {
                        "type": "boolean"
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true
                    }
                }
            },
            "AddressInput": {
                "type": "object",
                "required": [
                    "name",
                    "line1",
                    "city",
                    "postal_code",
                    "country",
                    "phone",
                    "email"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "readOnly": true
                    },
                    "label": {
                        "type": "string",
                        "maxLength": 100
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "both",
                            "sender",
                            "recipient"
                        ],
                        "default": "both"
                    },
                    "name": {
                        "type": "string",
                        "maxLength": 22
                    },
                    "company": {
                        "type": "string",
                        "maxLength": 27
                    },
                    "line1": {
                        "type": "string",
                        "maxLength": 35
                    },
                    "line2": {
                        "type": "string",
                        "maxLength": 35
                    },
                    "city": {
                        "type": "string",
                        "maxLength": 100
                    },
                    "state": {
                        "type": "string",
                        "maxLength": 100
                    },
                    "postal_code": {
                        "type": "string",
                        "maxLength": 20
                    },
                    "country": {
                        "type": "string",
                        "description": "ISO 3166-1 alpha-2"
                    },
                    "phone": {
                        "type": "string",
                        "maxLength": 40
                    },
                    "email": {
                        "type": "string",
                        "maxLength": 190
                    },
                    "is_default": {
                        "type": "boolean",
                        "default": false
                    }
                }
            },
            "AddressResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/AddressInput"
                    }
                }
            },
            "AddressListResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/AddressInput"
                        }
                    },
                    "meta": {
                        "type": "object",
                        "properties": {
                            "total": {
                                "type": "integer"
                            },
                            "limit": {
                                "type": "integer"
                            },
                            "offset": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "TeamMember": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    },
                    "role": {
                        "type": "string",
                        "enum": [
                            "owner",
                            "admin",
                            "staff"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "example": "active"
                    },
                    "joined_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "last_login_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    }
                }
            },
            "TeamListResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/TeamMember"
                        }
                    }
                }
            },
            "TeamMemberResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/TeamMember"
                    }
                }
            },
            "InvitationRequest": {
                "type": "object",
                "required": [
                    "email"
                ],
                "properties": {
                    "email": {
                        "type": "string"
                    },
                    "role": {
                        "type": "string",
                        "enum": [
                            "admin",
                            "staff"
                        ],
                        "default": "staff"
                    }
                }
            },
            "Invitation": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    },
                    "role": {
                        "type": "string",
                        "enum": [
                            "admin",
                            "staff"
                        ]
                    },
                    "expires_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "InvitationResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Invitation"
                    }
                }
            },
            "InvitationListResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Invitation"
                        }
                    }
                }
            },
            "RoleRequest": {
                "type": "object",
                "required": [
                    "role"
                ],
                "properties": {
                    "role": {
                        "type": "string",
                        "enum": [
                            "admin",
                            "staff"
                        ]
                    }
                }
            },
            "Webhook": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "url": {
                        "type": "string"
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "active": {
                        "type": "boolean"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "secret": {
                        "type": "string",
                        "description": "Только в ответах создания и rotate_secret, показывается один раз"
                    }
                }
            },
            "WebhookResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/Webhook"
                    }
                }
            },
            "WebhookListResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Webhook"
                        }
                    }
                }
            },
            "WebhookCreateRequest": {
                "type": "object",
                "required": [
                    "url",
                    "events"
                ],
                "properties": {
                    "url": {
                        "type": "string",
                        "example": "https://example.com/shipto/webhook"
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "example": [
                            "shipment.status_changed",
                            "shipment.tracking_updated"
                        ]
                    }
                }
            },
            "WebhookUpdateRequest": {
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string"
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "active": {
                        "type": "boolean"
                    }
                }
            },
            "WebhookDelivery": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "event": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "delivered",
                            "failed"
                        ]
                    },
                    "attempts": {
                        "type": "integer"
                    },
                    "response_code": {
                        "type": "integer",
                        "nullable": true
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "delivered_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "next_attempt_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    }
                }
            },
            "WebhookDeliveryResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                    }
                }
            },
            "WebhookDeliveryListResponse": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/WebhookDelivery"
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/CursorMeta"
                    }
                }
            },
            "WebhookTrackingEvent": {
                "type": "object",
                "description": "Новые контрольные точки перевозчика по заказу (только те, которых клиент ещё не получал)",
                "properties": {
                    "shipment_id": {
                        "type": "string"
                    },
                    "tracking_number": {
                        "type": "string",
                        "nullable": true
                    },
                    "reference": {
                        "type": "string",
                        "nullable": true
                    },
                    "status": {
                        "type": "string",
                        "description": "Статус заказа после этих точек"
                    },
                    "checkpoints": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "status": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "description": {
                                    "type": "string"
                                },
                                "location": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "time": {
                                    "type": "string",
                                    "format": "date-time",
                                    "nullable": true
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}