{
    "openapi": "3.1.0",
    "info": {
        "title": "vats.cloud API",
        "version": "1.0.0",
        "description": "Публичный API облачной АТС vats.cloud.\n\nАвторизация: `Authorization: Bearer vc_live_…` (ключ создаёт администратор в «Интеграциях»; ключ определяет компанию и права).\nЛимит: 60 запросов в минуту на ключ. Ошибки: RFC 9457 (`application/problem+json`). Даты: ISO 8601 с часовым поясом компании.\n\nWebhooks: POST JSON на ваш https-адрес; подпись `X-Vats-Signature: sha256=HMAC-SHA256(secret, X-Vats-Timestamp + \".\" + body)`, тайм-аут 10 с, повторы через 1 мин, 5 мин, 30 мин, 2 ч, 6 ч; после суток неудач подписка отключается."
    },
    "servers": [
        {
            "url": "https://api.vats.cloud/v1"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "scheme": "bearer",
                "description": "Права: calls:read, calls:write, recordings:read, ai:read, extensions:read, extensions:write, users:read, queues:read, numbers:read, webhooks:read, webhooks:write, notifications:read, notifications:write"
            }
        },
        "responses": {
            "Problem": {
                "description": "Ошибка (RFC 9457)",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "$ref": "#/components/schemas/Problem"
                        }
                    }
                }
            }
        },
        "schemas": {
            "Problem": {
                "type": "object",
                "required": [
                    "type",
                    "title",
                    "status"
                ],
                "properties": {
                    "type": {
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "status": {
                        "type": "integer"
                    },
                    "detail": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "CallStatus": {
                "enum": [
                    "ringing",
                    "in_progress",
                    "answered",
                    "missed",
                    "busy",
                    "failed",
                    "voicemail"
                ]
            },
            "Call": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "examples": [
                            "cl_01J8Z…"
                        ]
                    },
                    "direction": {
                        "enum": [
                            "inbound",
                            "outbound",
                            "internal"
                        ]
                    },
                    "from": {
                        "type": "string"
                    },
                    "to": {
                        "type": "string"
                    },
                    "from_extension": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "extension": {
                                "type": "string"
                            },
                            "user_id": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            }
                        }
                    },
                    "answered_by": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "properties": {
                            "extension": {
                                "type": "string"
                            },
                            "user_id": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            }
                        }
                    },
                    "status": {
                        "$ref": "#/components/schemas/CallStatus"
                    },
                    "started_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "answered_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "ended_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "duration_sec": {
                        "type": [
                            "integer",
                            "null"
                        ]
                    },
                    "talk_sec": {
                        "type": "integer"
                    },
                    "hangup_cause": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "has_recording": {
                        "type": "boolean"
                    }
                }
            },
            "CallPage": {
                "type": "object",
                "required": [
                    "data",
                    "next_cursor"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Call"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "ClickToCall": {
                "type": "object",
                "required": [
                    "extension",
                    "to"
                ],
                "properties": {
                    "extension": {
                        "type": "string",
                        "description": "Внутренний номер сотрудника, которому звоним первым",
                        "examples": [
                            "201"
                        ]
                    },
                    "to": {
                        "type": "string",
                        "description": "Кому звонить после ответа сотрудника: внутренний номер или внешний (E.164 или национальный формат AZ, например 0501234567). Внешний — только при оплаченной подписке (иначе 422 subscription-inactive) и подключённом SIP-транке; правила исходящих и лимиты антифрода проверяются до соединения, отказ приходит событием call.ended со status=failed",
                        "examples": [
                            "202",
                            "+994501234567"
                        ]
                    }
                }
            },
            "ClickToCallQueued": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "status": {
                        "const": "queued"
                    },
                    "extension": {
                        "type": "string"
                    },
                    "to": {
                        "type": "string"
                    }
                }
            },
            "Extension": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "number": {
                        "type": "string"
                    },
                    "user_id": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "sip_username": {
                        "type": "string"
                    },
                    "sip_server": {
                        "type": "string"
                    },
                    "recording_policy": {
                        "enum": [
                            "inherit",
                            "always",
                            "never"
                        ]
                    },
                    "allow_udp": {
                        "type": "boolean"
                    },
                    "online": {
                        "type": "object",
                        "properties": {
                            "phone": {
                                "type": "boolean"
                            },
                            "browser": {
                                "type": "boolean"
                            }
                        }
                    }
                }
            },
            "ExtensionPage": {
                "type": "object",
                "required": [
                    "data",
                    "next_cursor"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Extension"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "ExtensionCreate": {
                "type": "object",
                "properties": {
                    "number": {
                        "type": "integer",
                        "minimum": 200,
                        "maximum": 9999
                    },
                    "user_id": {
                        "type": "string"
                    }
                }
            },
            "ExtensionUpdate": {
                "type": "object",
                "properties": {
                    "recording_policy": {
                        "enum": [
                            "inherit",
                            "always",
                            "never"
                        ]
                    },
                    "allow_udp": {
                        "type": "boolean"
                    }
                }
            },
            "User": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    },
                    "role": {
                        "enum": [
                            "tenant_admin",
                            "supervisor",
                            "agent"
                        ]
                    },
                    "extension": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "UserPage": {
                "type": "object",
                "required": [
                    "data",
                    "next_cursor"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/User"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "Queue": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "q_01J…"
                    },
                    "name": {
                        "type": "string"
                    },
                    "strategy": {
                        "enum": [
                            "ringall",
                            "leastrecent",
                            "fewestcalls",
                            "rrmemory",
                            "linear",
                            "random"
                        ]
                    },
                    "ring_sec": {
                        "type": "integer"
                    },
                    "wrapup_sec": {
                        "type": "integer"
                    },
                    "members": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                }
            },
            "QueuePage": {
                "type": "object",
                "required": [
                    "data",
                    "next_cursor"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Queue"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "Number": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "num_01J…"
                    },
                    "number": {
                        "type": "string",
                        "example": "+994124040000"
                    },
                    "label": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "route": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "trunk": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "NumberPage": {
                "type": "object",
                "required": [
                    "data",
                    "next_cursor"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Number"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "NotificationStatus": {
                "enum": [
                    "queued",
                    "calling",
                    "answered",
                    "no_answer",
                    "busy",
                    "failed"
                ],
                "description": "queued/calling — в работе; answered, no_answer, busy, failed — итог"
            },
            "NotificationCreate": {
                "type": "object",
                "required": [
                    "action",
                    "to"
                ],
                "properties": {
                    "action": {
                        "type": "string",
                        "description": "Ключ action из панели («Оповещения»): определяет аудиофайл, повторы и CallerID",
                        "examples": [
                            "order_ready"
                        ]
                    },
                    "to": {
                        "type": "string",
                        "description": "Номер E.164 или национальный формат AZ (0501234567). Только при оплаченной подписке (иначе 422 subscription-inactive). Правила исходящих и лимиты антифрода проверяются перед каждым звонком",
                        "examples": [
                            "+994501234567"
                        ]
                    },
                    "metadata": {
                        "type": "object",
                        "maxProperties": 20,
                        "additionalProperties": {
                            "type": [
                                "string",
                                "number",
                                "boolean",
                                "null"
                            ]
                        },
                        "description": "Ваши данные (до 2 КБ), возвращаются в ответах и webhook"
                    }
                }
            },
            "Notification": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "examples": [
                            "ntf_01J…"
                        ]
                    },
                    "action": {
                        "type": "string"
                    },
                    "to": {
                        "type": "string"
                    },
                    "status": {
                        "$ref": "#/components/schemas/NotificationStatus"
                    },
                    "reason": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Причина последнего неуспеха: no_answer, busy, outbound_denied, fraud_per_hour, trunk_unavailable…"
                    },
                    "attempts": {
                        "type": "integer"
                    },
                    "max_attempts": {
                        "type": "integer"
                    },
                    "next_attempt_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "answered_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "talk_sec": {
                        "type": "integer"
                    },
                    "listened_full": {
                        "type": "boolean",
                        "description": "Сообщение проиграно нужное число раз до конца"
                    },
                    "call_id": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Звонок последней попытки (GET /calls/{id})"
                    },
                    "metadata": {
                        "type": "object"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "completed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    }
                }
            },
            "NotificationPage": {
                "type": "object",
                "required": [
                    "data",
                    "next_cursor"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Notification"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "Analysis": {
                "type": "object",
                "properties": {
                    "call_id": {
                        "type": "string"
                    },
                    "language": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "summary": {
                        "type": "string"
                    },
                    "topic": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "sentiment": {
                        "enum": [
                            "positive",
                            "neutral",
                            "negative"
                        ]
                    },
                    "outcome": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "next_step": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "score": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "description": "% выполненных пунктов чек-листа"
                    },
                    "checklist": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "item": {
                                    "type": "string"
                                },
                                "passed": {
                                    "type": "boolean"
                                },
                                "evidence": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "tags": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "transcript": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "speaker": {
                                    "enum": [
                                        "client",
                                        "agent"
                                    ]
                                },
                                "start": {
                                    "type": "number"
                                },
                                "end": {
                                    "type": "number"
                                },
                                "text": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "EmptyPage": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "Webhook": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "enum": [
                                "call.started",
                                "call.answered",
                                "call.ended",
                                "call.missed",
                                "recording.ready",
                                "analysis.ready",
                                "voicemail.received",
                                "notification.completed"
                            ]
                        }
                    },
                    "is_active": {
                        "type": "boolean"
                    },
                    "disabled_at": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "created_at": {
                        "type": "string"
                    }
                }
            },
            "WebhookPage": {
                "type": "object",
                "required": [
                    "data",
                    "next_cursor"
                ],
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Webhook"
                        }
                    },
                    "next_cursor": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "WebhookCreate": {
                "type": "object",
                "required": [
                    "url",
                    "events"
                ],
                "properties": {
                    "url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Публичный https-адрес"
                    },
                    "events": {
                        "type": "array",
                        "items": {
                            "enum": [
                                "call.started",
                                "call.answered",
                                "call.ended",
                                "call.missed",
                                "recording.ready",
                                "analysis.ready",
                                "voicemail.received",
                                "notification.completed"
                            ]
                        },
                        "minItems": 1
                    }
                }
            },
            "WebhookCreated": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Webhook"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "secret": {
                                "type": "string",
                                "description": "Секрет подписи, показывается один раз"
                            }
                        }
                    }
                ]
            }
        }
    },
    "paths": {
        "/calls": {
            "get": {
                "summary": "История звонков с фильтрами (cursor-пагинация)",
                "operationId": "get_calls",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "calls:read",
                "parameters": [
                    {
                        "name": "cursor",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date-time"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date-time"
                        }
                    },
                    {
                        "name": "direction",
                        "in": "query",
                        "schema": {
                            "enum": [
                                "inbound",
                                "outbound",
                                "internal"
                            ]
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "$ref": "#/components/schemas/CallStatus"
                        }
                    },
                    {
                        "name": "number",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/CallPage"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            },
            "post": {
                "summary": "Click-to-call: сначала звонит сотруднику, затем второй стороне",
                "operationId": "post_calls",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "calls:write",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "schema": {
                            "type": "string",
                            "maxLength": 128
                        },
                        "description": "Повтор запроса с тем же ключом и телом вернёт сохранённый ответ (24 часа)"
                    }
                ],
                "responses": {
                    "202": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClickToCallQueued"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ClickToCall"
                            }
                        }
                    }
                }
            }
        },
        "/calls/{id}": {
            "get": {
                "summary": "Карточка звонка",
                "operationId": "get_calls_id",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "calls:read",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Call"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/calls/{id}/analysis": {
            "get": {
                "summary": "AI-анализ: расшифровка, резюме, тональность, оценка по чек-листу. 404 analysis-not-found с analysis_status (none | pending | processing | failed), если ещё не готов",
                "operationId": "get_calls_id_analysis",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "ai:read",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Analysis"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/calls/{id}/recording": {
            "get": {
                "summary": "Запись разговора (стерео Opus): 302 на временную ссылку (15 минут); скачивание пишется в аудит",
                "operationId": "get_calls_id_recording",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "recordings:read",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "302": {
                        "description": "OK"
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/extensions": {
            "get": {
                "summary": "Внутренние номера",
                "operationId": "get_extensions",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "extensions:read",
                "parameters": [
                    {
                        "name": "cursor",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ExtensionPage"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            },
            "post": {
                "summary": "Создать внутренний номер (с 201; 100–199 запрещены)",
                "operationId": "post_extensions",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "extensions:write",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "schema": {
                            "type": "string",
                            "maxLength": 128
                        },
                        "description": "Повтор запроса с тем же ключом и телом вернёт сохранённый ответ (24 часа)"
                    }
                ],
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Extension"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ExtensionCreate"
                            }
                        }
                    }
                }
            }
        },
        "/extensions/{id}": {
            "get": {
                "summary": "Внутренний номер",
                "operationId": "get_extensions_id",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "extensions:read",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Extension"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            },
            "patch": {
                "summary": "Изменить внутренний номер",
                "operationId": "patch_extensions_id",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "extensions:write",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Extension"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ExtensionUpdate"
                            }
                        }
                    }
                }
            },
            "delete": {
                "summary": "Удалить внутренний номер и его SIP-учётки",
                "operationId": "delete_extensions_id",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "extensions:write",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "204": {
                        "description": "OK"
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/notifications": {
            "get": {
                "summary": "Голосовые оповещения (cursor-пагинация; фильтры status, action, to)",
                "operationId": "get_notifications",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "notifications:read",
                "parameters": [
                    {
                        "name": "cursor",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "$ref": "#/components/schemas/NotificationStatus"
                        }
                    },
                    {
                        "name": "action",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/NotificationPage"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            },
            "post": {
                "summary": "Голосовое оповещение: звонок на номер и проигрывание аудио action; итог — webhook notification.completed",
                "operationId": "post_notifications",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "notifications:write",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "schema": {
                            "type": "string",
                            "maxLength": 128
                        },
                        "description": "Повтор запроса с тем же ключом и телом вернёт сохранённый ответ (24 часа)"
                    }
                ],
                "responses": {
                    "202": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Notification"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/NotificationCreate"
                            }
                        }
                    }
                }
            }
        },
        "/notifications/{id}": {
            "get": {
                "summary": "Статус голосового оповещения",
                "operationId": "get_notifications_id",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "notifications:read",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Notification"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/numbers": {
            "get": {
                "summary": "Внешние номера (DID)",
                "operationId": "get_numbers",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "numbers:read",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/NumberPage"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/queues": {
            "get": {
                "summary": "Очереди",
                "operationId": "get_queues",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "queues:read",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/QueuePage"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/queues/{id}/stats": {
            "get": {
                "summary": "Статистика очереди",
                "operationId": "get_queues_id_stats",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "queues:read",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/users": {
            "get": {
                "summary": "Сотрудники",
                "operationId": "get_users",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "users:read",
                "parameters": [
                    {
                        "name": "cursor",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/UserPage"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        },
        "/webhooks": {
            "get": {
                "summary": "Подписки на события",
                "operationId": "get_webhooks",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "webhooks:read",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookPage"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            },
            "post": {
                "summary": "Создать подписку; секрет подписи возвращается один раз",
                "operationId": "post_webhooks",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "webhooks:write",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "schema": {
                            "type": "string",
                            "maxLength": 128
                        },
                        "description": "Повтор запроса с тем же ключом и телом вернёт сохранённый ответ (24 часа)"
                    }
                ],
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/WebhookCreated"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/WebhookCreate"
                            }
                        }
                    }
                }
            }
        },
        "/webhooks/{id}": {
            "delete": {
                "summary": "Удалить подписку",
                "operationId": "delete_webhooks_id",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "x-required-scope": "webhooks:write",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Идентификатор с префиксом: cl_, ext_, wh_, ntf_"
                    }
                ],
                "responses": {
                    "204": {
                        "description": "OK"
                    },
                    "401": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "403": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "404": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "422": {
                        "$ref": "#/components/responses/Problem"
                    },
                    "429": {
                        "$ref": "#/components/responses/Problem"
                    }
                }
            }
        }
    },
    "webhooks": {
        "callEvent": {
            "post": {
                "summary": "События: call.started, call.answered, call.ended, call.missed, recording.ready, analysis.ready, voicemail.received, notification.completed. data — Call; для notification.completed — Notification; для analysis.ready — Analysis",
                "parameters": [
                    {
                        "name": "X-Vats-Signature",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Vats-Timestamp",
                        "in": "header",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "X-Vats-Event",
                        "in": "header",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string",
                                        "examples": [
                                            "evt_01J…"
                                        ]
                                    },
                                    "type": {
                                        "type": "string"
                                    },
                                    "created_at": {
                                        "type": "string",
                                        "format": "date-time"
                                    },
                                    "tenant": {
                                        "type": "string"
                                    },
                                    "data": {
                                        "oneOf": [
                                            {
                                                "$ref": "#/components/schemas/Call"
                                            },
                                            {
                                                "$ref": "#/components/schemas/Notification"
                                            },
                                            {
                                                "$ref": "#/components/schemas/Analysis"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Любой 2xx — доставлено"
                    }
                }
            }
        }
    }
}
