{
  "openapi": "3.1.0",
  "info": {
    "title": "Meliora API",
    "version": "v1",
    "summary": "Чтение кампаний, лидов, переписки и событий Meliora.",
    "description": "Публичный API Meliora, версия v1. Ранний доступ: только чтение по ключу организации. Документация: https://docs.melioralab.io",
    "contact": {
      "name": "Поддержка Meliora",
      "url": "https://t.me/meliora_support"
    }
  },
  "servers": [
    {
      "url": "https://api.melioralab.io/v1",
      "description": "Рабочий сервер"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Контекст ключа",
      "description": "Проверка ключа и его настроек."
    },
    {
      "name": "Пространства",
      "description": "Рабочие области кабинета."
    },
    {
      "name": "Кампании",
      "description": "Цепочки сообщений."
    },
    {
      "name": "Лиды",
      "description": "Участия контактов в кампаниях."
    },
    {
      "name": "Переписка",
      "description": "Сохраненные сообщения с лидом."
    },
    {
      "name": "События",
      "description": "Лента событий для опроса."
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "Контекст ключа"
        ],
        "summary": "Получить сведения о ключе",
        "description": "Возвращает организацию, права, охват и лимиты ключа. Первый запрос для проверки подключения. Доступен ключу с любым набором прав.",
        "x-permission": null,
        "x-weight": 1,
        "parameters": [],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiContext"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "api_context",
                      "key_id": "9b1e7c42-5a6d-4f83-9e0b-2d7c4a8f1e65",
                      "organization": {
                        "id": "2c8f4a61-7d3e-4b9a-8f21-6a0d5e9c3b17",
                        "name": "Пример"
                      },
                      "scopes": [
                        "campaigns:read",
                        "events:read",
                        "leads:read",
                        "messages:read"
                      ],
                      "scope": {
                        "workspace_mode": "all",
                        "workspace_ids": [],
                        "workspace_include_future": true,
                        "campaign_mode": "all",
                        "campaign_ids": [],
                        "campaign_include_future": true,
                        "scope_version": 1
                      },
                      "api_version": "v1",
                      "expires_at": null,
                      "limits": {
                        "key_second": 5,
                        "key_minute": 300,
                        "org_second": 10,
                        "org_minute": 600,
                        "key_concurrent": 5,
                        "org_concurrent": 10,
                        "max_response_bytes": 1048576,
                        "mode": "normal"
                      },
                      "collection": {
                        "state": "running",
                        "enabled_at": "2026-10-20T08:00:00.000Z",
                        "pause_pending": false
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    },
    "/workspaces": {
      "get": {
        "operationId": "listWorkspaces",
        "tags": [
          "Пространства"
        ],
        "summary": "Список пространств",
        "description": "Пространства в охвате ключа, от старых к новым. Доступен ключу с любым набором прав.",
        "x-permission": null,
        "x-weight": 1,
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Сколько объектов вернуть на странице.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Значение `next_cursor` из предыдущего ответа. Остальные фильтры должны совпадать с первым запросом.",
            "schema": {
              "type": "string",
              "maxLength": 8192
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceList"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "list",
                      "data": [
                        {
                          "object": "workspace",
                          "id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                          "name": "Основное пространство",
                          "created_at": "2026-09-01T12:00:00.000Z"
                        },
                        {
                          "object": "workspace",
                          "id": "7a2c5e81-3d9f-4b6a-8c40-1e5f7a9b2d68",
                          "name": "Тестовые рассылки",
                          "created_at": "2026-10-02T09:30:00.000Z"
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`, `cursor_mismatch`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter",
              "cursor_mismatch"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "410": {
            "description": "Ошибка: `cursor_expired`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:cursor_expired",
                  "title": "Cursor expired",
                  "status": 410,
                  "detail": "Курсор истек. Список начните заново без cursor. Для ленты событий отметьте разрыв, получите start=now, сверьте кампании и лиды, затем продолжите ленту",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "cursor_expired",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "cursor_expired"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    },
    "/campaigns": {
      "get": {
        "operationId": "listCampaigns",
        "tags": [
          "Кампании"
        ],
        "summary": "Список кампаний",
        "description": "Кампании в охвате ключа, от старых к новым по `created_at`.",
        "x-permission": "campaigns:read",
        "x-weight": 2,
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Сколько объектов вернуть на странице.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Значение `next_cursor` из предыдущего ответа. Остальные фильтры должны совпадать с первым запросом.",
            "schema": {
              "type": "string",
              "maxLength": 8192
            }
          },
          {
            "name": "workspace_id",
            "in": "query",
            "required": false,
            "description": "Только объекты этого пространства.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Только кампании с этим статусом.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "scheduled",
                "active",
                "paused",
                "stopped",
                "completed",
                "archived",
                "launching",
                "failed",
                "paused_no_credits",
                "unknown"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CampaignList"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "list",
                      "data": [
                        {
                          "object": "campaign",
                          "id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                          "workspace_id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                          "name": "Пример кампании",
                          "status": "active",
                          "first_message_mode": "template",
                          "accepts_api_leads": false,
                          "reason": {
                            "reason_code": "none",
                            "reason_observed_at": null,
                            "next_attempt_at": null,
                            "requires_customer_action": null
                          },
                          "created_at": "2026-10-20T08:00:00.000Z",
                          "observed_at": "2026-10-27T09:15:42.000Z"
                        },
                        {
                          "object": "campaign",
                          "id": "6e3a9c15-2b7d-4f80-9a64-3c1d8e5f7b29",
                          "workspace_id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                          "name": "Повторное касание",
                          "status": "paused",
                          "first_message_mode": "template",
                          "accepts_api_leads": false,
                          "reason": {
                            "reason_code": "campaign_paused",
                            "reason_observed_at": "2026-10-25T16:40:00.000Z",
                            "next_attempt_at": null,
                            "requires_customer_action": true
                          },
                          "created_at": "2026-10-22T11:15:00.000Z",
                          "observed_at": "2026-10-27T09:15:42.000Z"
                        }
                      ],
                      "has_more": true,
                      "next_cursor": "v1.k1.Qm9hcmRfMWZ4.c3RyaWN0bHlfb3BhcXVl.dGFnX2V4YW1wbGU.bWFjX2V4YW1wbGVfdmFsdWU"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`, `cursor_mismatch`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter",
              "cursor_mismatch"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "410": {
            "description": "Ошибка: `cursor_expired`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:cursor_expired",
                  "title": "Cursor expired",
                  "status": 410,
                  "detail": "Курсор истек. Список начните заново без cursor. Для ленты событий отметьте разрыв, получите start=now, сверьте кампании и лиды, затем продолжите ленту",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "cursor_expired",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "cursor_expired"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    },
    "/campaigns/{id}": {
      "get": {
        "operationId": "getCampaign",
        "tags": [
          "Кампании"
        ],
        "summary": "Получить кампанию",
        "description": "Одна кампания по идентификатору. Кампания вне охвата ключа дает 404, как несуществующая.",
        "x-permission": "campaigns:read",
        "x-weight": 1,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор кампании.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Campaign"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "campaign",
                      "id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                      "workspace_id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                      "name": "Пример кампании",
                      "status": "active",
                      "first_message_mode": "template",
                      "accepts_api_leads": false,
                      "reason": {
                        "reason_code": "none",
                        "reason_observed_at": null,
                        "next_attempt_at": null,
                        "requires_customer_action": null
                      },
                      "created_at": "2026-10-20T08:00:00.000Z",
                      "observed_at": "2026-10-27T09:15:42.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    },
    "/leads": {
      "get": {
        "operationId": "listLeads",
        "tags": [
          "Лиды"
        ],
        "summary": "Список лидов",
        "description": "Лиды (участия контактов в кампаниях) в охвате ключа, от старых к новым по `created_at`.",
        "x-permission": "leads:read",
        "x-weight": 2,
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Сколько объектов вернуть на странице.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Значение `next_cursor` из предыдущего ответа. Остальные фильтры должны совпадать с первым запросом.",
            "schema": {
              "type": "string",
              "maxLength": 8192
            }
          },
          {
            "name": "workspace_id",
            "in": "query",
            "required": false,
            "description": "Только объекты этого пространства.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "Только объекты этой кампании.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "username",
            "in": "query",
            "required": false,
            "description": "Точный ник Telegram. Знак `@` в начале и регистр не важны.",
            "schema": {
              "type": "string",
              "pattern": "^@?[A-Za-z0-9_]{1,32}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Только лиды с этим статусом.",
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "contacted",
                "completed",
                "replied",
                "blocked",
                "failed",
                "suspended",
                "deleted",
                "opted_out",
                "unknown"
              ]
            }
          },
          {
            "name": "delivery_state",
            "in": "query",
            "required": false,
            "description": "Только лиды с этим состоянием доставки. Значения `waiting_queue` и `failed` сейчас не выдаются, фильтр по ним вернет пустой список.",
            "schema": {
              "type": "string",
              "enum": [
                "waiting_queue",
                "queued",
                "held",
                "sent",
                "failed",
                "unknown"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadList"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "list",
                      "data": [
                        {
                          "object": "lead",
                          "id": "5a7c3e92-1f4b-4d68-9c2e-7b0a6d4f8e31",
                          "workspace_id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                          "campaign_id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                          "username": "example_user",
                          "status": "replied",
                          "external_id": null,
                          "fields": {
                            "record_id": "crm-10482",
                            "first_name": "Анна",
                            "company": "ООО Пример",
                            "position": "Руководитель отдела продаж",
                            "utm_source": "partner"
                          },
                          "fields_truncated": false,
                          "record_id_status": "valid",
                          "first_contact_account": {
                            "id": "1d9f6b28-4c3e-4a75-8b19-5e7a2c0f6d83",
                            "username": "example_sender",
                            "name": "Мария из Примера"
                          },
                          "first_message_sent_at": "2026-10-26T07:30:00.000Z",
                          "first_reply_at": "2026-10-26T09:12:00.000Z",
                          "delivery_state": "sent",
                          "automation_state": "unknown",
                          "reason": {
                            "reason_code": "none",
                            "reason_observed_at": null,
                            "next_attempt_at": null,
                            "requires_customer_action": null
                          },
                          "created_at": "2026-10-25T14:00:00.000Z",
                          "observed_at": "2026-10-27T09:15:42.000Z"
                        },
                        {
                          "object": "lead",
                          "id": "8c1e5a37-9d2f-4b74-a6e8-2f9b3c7d5a40",
                          "workspace_id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                          "campaign_id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                          "username": "sample_contact",
                          "status": "contacted",
                          "external_id": null,
                          "fields": {
                            "record_id": null,
                            "first_name": "Игорь"
                          },
                          "fields_truncated": false,
                          "record_id_status": "missing",
                          "first_contact_account": {
                            "id": "1d9f6b28-4c3e-4a75-8b19-5e7a2c0f6d83",
                            "username": "example_sender",
                            "name": "Мария из Примера"
                          },
                          "first_message_sent_at": "2026-10-26T07:42:00.000Z",
                          "first_reply_at": null,
                          "delivery_state": "queued",
                          "automation_state": "running",
                          "reason": {
                            "reason_code": "queue_pending",
                            "reason_observed_at": "2026-10-27T08:58:10.000Z",
                            "next_attempt_at": "2026-10-27T10:00:00.000Z",
                            "requires_customer_action": false
                          },
                          "created_at": "2026-10-25T14:00:01.000Z",
                          "observed_at": "2026-10-27T09:15:42.000Z"
                        }
                      ],
                      "has_more": true,
                      "next_cursor": "v1.k1.Qm9hcmRfMWZ4.c3RyaWN0bHlfb3BhcXVl.dGFnX2V4YW1wbGU.bWFjX2V4YW1wbGVfdmFsdWU"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`, `cursor_mismatch`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter",
              "cursor_mismatch"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "410": {
            "description": "Ошибка: `cursor_expired`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:cursor_expired",
                  "title": "Cursor expired",
                  "status": 410,
                  "detail": "Курсор истек. Список начните заново без cursor. Для ленты событий отметьте разрыв, получите start=now, сверьте кампании и лиды, затем продолжите ленту",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "cursor_expired",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "cursor_expired"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    },
    "/leads/{id}": {
      "get": {
        "operationId": "getLead",
        "tags": [
          "Лиды"
        ],
        "summary": "Получить лида",
        "description": "Один лид по идентификатору. Лид вне охвата ключа дает 404.",
        "x-permission": "leads:read",
        "x-weight": 1,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор лида.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "lead",
                      "id": "5a7c3e92-1f4b-4d68-9c2e-7b0a6d4f8e31",
                      "workspace_id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                      "campaign_id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                      "username": "example_user",
                      "status": "replied",
                      "external_id": null,
                      "fields": {
                        "record_id": "crm-10482",
                        "first_name": "Анна",
                        "company": "ООО Пример",
                        "position": "Руководитель отдела продаж",
                        "utm_source": "partner"
                      },
                      "fields_truncated": false,
                      "record_id_status": "valid",
                      "first_contact_account": {
                        "id": "1d9f6b28-4c3e-4a75-8b19-5e7a2c0f6d83",
                        "username": "example_sender",
                        "name": "Мария из Примера"
                      },
                      "first_message_sent_at": "2026-10-26T07:30:00.000Z",
                      "first_reply_at": "2026-10-26T09:12:00.000Z",
                      "delivery_state": "sent",
                      "automation_state": "unknown",
                      "reason": {
                        "reason_code": "none",
                        "reason_observed_at": null,
                        "next_attempt_at": null,
                        "requires_customer_action": null
                      },
                      "created_at": "2026-10-25T14:00:00.000Z",
                      "observed_at": "2026-10-27T09:15:42.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    },
    "/leads/{id}/messages": {
      "get": {
        "operationId": "listLeadMessages",
        "tags": [
          "Переписка"
        ],
        "summary": "Переписка с лидом",
        "description": "Сохраненные сообщения переписки с лидом, от ранних к поздним. Нужны право `messages:read` и включенный у ключа «Текст сообщений». Архив может быть неполным: смотрите `meta.completeness`.",
        "x-permission": "messages:read",
        "x-weight": 3,
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор лида.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Сколько объектов вернуть на странице.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Значение `next_cursor` из предыдущего ответа. Остальные фильтры должны совпадать с первым запросом.",
            "schema": {
              "type": "string",
              "maxLength": 8192
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageList"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "list",
                      "data": [
                        {
                          "object": "message",
                          "id": "m_6b2e9f403a7c4d158e921c5a7f3b9d08",
                          "direction": "outbound",
                          "author": "campaign",
                          "sent_at": "2026-10-26T07:30:00.000Z",
                          "state": "sent",
                          "media_kind": "none",
                          "text": "Добрый день, Анна! Пишу из Примера: подскажите, кто у вас отвечает за аутрич?",
                          "text_truncated": false,
                          "text_unavailable": false,
                          "text_unavailable_reason": null
                        },
                        {
                          "object": "message",
                          "id": "m_c7a1d3e59b2f4a68b4d05e8f2a6c1b97",
                          "direction": "inbound",
                          "author": "lead",
                          "sent_at": "2026-10-26T09:12:00.000Z",
                          "state": "received",
                          "media_kind": "none",
                          "text": "Здравствуйте! Это я, давайте созвонимся завтра.",
                          "text_truncated": null,
                          "text_unavailable": false,
                          "text_unavailable_reason": null
                        },
                        {
                          "object": "message",
                          "id": "m_a3f8c6e27d1b4e949c058b2d4f7a6e13",
                          "direction": "inbound",
                          "author": "lead",
                          "sent_at": "2026-10-26T09:13:30.000Z",
                          "state": "received",
                          "media_kind": "photo",
                          "text": null,
                          "text_truncated": null,
                          "text_unavailable": true,
                          "text_unavailable_reason": "not_saved"
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null,
                      "meta": {
                        "completeness": {
                          "overall": "partial",
                          "inbound": "partial",
                          "outbound": "unknown",
                          "available_from": "2026-10-26T07:30:00.000Z",
                          "available_to": "2026-10-27T09:15:42.000Z",
                          "observed_at": "2026-10-27T09:15:42.000Z"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`, `cursor_mismatch`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter",
              "cursor_mismatch"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "410": {
            "description": "Ошибка: `cursor_expired`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:cursor_expired",
                  "title": "Cursor expired",
                  "status": 410,
                  "detail": "Курсор истек. Список начните заново без cursor. Для ленты событий отметьте разрыв, получите start=now, сверьте кампании и лиды, затем продолжите ленту",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "cursor_expired",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "cursor_expired"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "listEvents",
        "tags": [
          "События"
        ],
        "summary": "Лента событий",
        "description": "События в порядке появления: первое сообщение лиду и ответ лида. Опрашивайте ленту по курсору. `next_cursor` есть всегда, даже у пустой страницы. С `include_text=true` вес запроса 3.",
        "x-permission": "events:read",
        "x-weight": 2,
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Сколько объектов вернуть на странице.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Значение `next_cursor` из предыдущего ответа. Остальные фильтры должны совпадать с первым запросом.",
            "schema": {
              "type": "string",
              "maxLength": 8192
            }
          },
          {
            "name": "workspace_id",
            "in": "query",
            "required": false,
            "description": "Только объекты этого пространства.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "Только объекты этой кампании.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "Только события этого типа.",
            "schema": {
              "type": "string",
              "enum": [
                "lead.first_message_sent",
                "lead.replied"
              ]
            }
          },
          {
            "name": "include_text",
            "in": "query",
            "required": false,
            "description": "Добавить тексты сообщений в события. Нужны право `messages:read` и включенный «Текст сообщений» у ключа.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false"
            }
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "description": "`now`: начать ленту с текущего момента. Возвращает пустую страницу и курсор. Нельзя вместе с `cursor`.",
            "schema": {
              "type": "string",
              "enum": [
                "now"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Успешный ответ.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "RateLimit-Policy": {
                "description": "Окна лимитов в весовых единицах, например `\"key_second\";q=5;w=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit": {
                "description": "Остаток и время до сброса по каждому окну, например `\"key_second\";r=4;t=1`.",
                "schema": {
                  "type": "string"
                }
              },
              "RateLimit-Limit": {
                "description": "Лимит самого близкого к исчерпанию окна.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Остаток в этом окне.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Секунд до сброса этого окна.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                },
                "examples": {
                  "default": {
                    "summary": "Ответ",
                    "value": {
                      "object": "list",
                      "data": [
                        {
                          "object": "event",
                          "id": "evt_3b9e2c7a1f4d4e8a9b6c0d2e5f7a8c91",
                          "type": "lead.first_message_sent",
                          "api_version": "2026-10-18",
                          "timestamp": "2026-10-26T07:30:00.000Z",
                          "test": false,
                          "data": {
                            "organization_id": "2c8f4a61-7d3e-4b9a-8f21-6a0d5e9c3b17",
                            "workspace": {
                              "id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                              "name": "Основное пространство"
                            },
                            "campaign": {
                              "id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                              "name": "Пример кампании"
                            },
                            "lead": {
                              "id": "5a7c3e92-1f4b-4d68-9c2e-7b0a6d4f8e31",
                              "username": "example_user",
                              "status": "contacted",
                              "fields": {
                                "record_id": null,
                                "first_name": "Анна",
                                "company": "ООО Пример"
                              },
                              "fields_truncated": false,
                              "record_id_status": "unknown"
                            },
                            "account": {
                              "id": "1d9f6b28-4c3e-4a75-8b19-5e7a2c0f6d83",
                              "username": "example_sender",
                              "name": "Мария из Примера"
                            },
                            "first_message_sent_at": "2026-10-26T07:30:00.000Z"
                          }
                        },
                        {
                          "object": "event",
                          "id": "evt_8d4f1a6c2e9b4c7d8a3e5f0b1c6d9e27",
                          "type": "lead.replied",
                          "api_version": "2026-10-18",
                          "timestamp": "2026-10-26T09:12:00.000Z",
                          "test": false,
                          "data": {
                            "organization_id": "2c8f4a61-7d3e-4b9a-8f21-6a0d5e9c3b17",
                            "workspace": {
                              "id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                              "name": "Основное пространство"
                            },
                            "campaign": {
                              "id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                              "name": "Пример кампании"
                            },
                            "lead": {
                              "id": "5a7c3e92-1f4b-4d68-9c2e-7b0a6d4f8e31",
                              "username": "example_user",
                              "status": "replied",
                              "fields": {
                                "record_id": null,
                                "first_name": "Анна",
                                "company": "ООО Пример"
                              },
                              "fields_truncated": false,
                              "record_id_status": "unknown"
                            },
                            "account": {
                              "id": "1d9f6b28-4c3e-4a75-8b19-5e7a2c0f6d83",
                              "username": "example_sender",
                              "name": "Мария из Примера"
                            },
                            "first_message_sent_at": null,
                            "reply": {
                              "id": "e4b7a2d9-6c1f-4e38-9a5b-0d8c3f7e1a62",
                              "replied_at": "2026-10-26T09:12:00.000Z",
                              "automation_stopped": null
                            }
                          }
                        }
                      ],
                      "has_more": false,
                      "next_cursor": "v1.k1.Qm9hcmRfMWZ4.c3RyaWN0bHlfb3BhcXVl.dGFnX2V4YW1wbGU.bWFjX2V4YW1wbGVfdmFsdWU",
                      "meta": {
                        "available_from": "2026-10-20T08:00:00.000Z",
                        "retention_days": 30,
                        "collection": {
                          "state": "running",
                          "enabled_at": "2026-10-20T08:00:00.000Z",
                          "pause_pending": false
                        },
                        "coverage": {
                          "status": "unknown",
                          "gaps": [],
                          "gaps_truncated": false,
                          "incomplete_from": null
                        },
                        "observed_at": "2026-10-27T09:15:42.000Z"
                      }
                    }
                  },
                  "with_text": {
                    "summary": "С include_text=true",
                    "value": {
                      "object": "list",
                      "data": [
                        {
                          "object": "event",
                          "id": "evt_3b9e2c7a1f4d4e8a9b6c0d2e5f7a8c91",
                          "type": "lead.first_message_sent",
                          "api_version": "2026-10-18",
                          "timestamp": "2026-10-26T07:30:00.000Z",
                          "test": false,
                          "data": {
                            "organization_id": "2c8f4a61-7d3e-4b9a-8f21-6a0d5e9c3b17",
                            "workspace": {
                              "id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                              "name": "Основное пространство"
                            },
                            "campaign": {
                              "id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                              "name": "Пример кампании"
                            },
                            "lead": {
                              "id": "5a7c3e92-1f4b-4d68-9c2e-7b0a6d4f8e31",
                              "username": "example_user",
                              "status": "contacted",
                              "fields": {
                                "record_id": null,
                                "first_name": "Анна",
                                "company": "ООО Пример"
                              },
                              "fields_truncated": false,
                              "record_id_status": "unknown"
                            },
                            "account": {
                              "id": "1d9f6b28-4c3e-4a75-8b19-5e7a2c0f6d83",
                              "username": "example_sender",
                              "name": "Мария из Примера"
                            },
                            "first_message_sent_at": "2026-10-26T07:30:00.000Z",
                            "first_message": {
                              "text": "Добрый день, Анна! Пишу из Примера: подскажите, кто у вас отвечает за аутрич?",
                              "text_truncated": false,
                              "text_unavailable": false,
                              "text_unavailable_reason": null
                            }
                          }
                        },
                        {
                          "object": "event",
                          "id": "evt_8d4f1a6c2e9b4c7d8a3e5f0b1c6d9e27",
                          "type": "lead.replied",
                          "api_version": "2026-10-18",
                          "timestamp": "2026-10-26T09:12:00.000Z",
                          "test": false,
                          "data": {
                            "organization_id": "2c8f4a61-7d3e-4b9a-8f21-6a0d5e9c3b17",
                            "workspace": {
                              "id": "3f6a9d21-8b4c-4e7f-a102-5c9e8d7b6a43",
                              "name": "Основное пространство"
                            },
                            "campaign": {
                              "id": "4d8b2f73-6e1a-4c95-b7d0-8a3f5e2c9b14",
                              "name": "Пример кампании"
                            },
                            "lead": {
                              "id": "5a7c3e92-1f4b-4d68-9c2e-7b0a6d4f8e31",
                              "username": "example_user",
                              "status": "replied",
                              "fields": {
                                "record_id": null,
                                "first_name": "Анна",
                                "company": "ООО Пример"
                              },
                              "fields_truncated": false,
                              "record_id_status": "unknown"
                            },
                            "account": {
                              "id": "1d9f6b28-4c3e-4a75-8b19-5e7a2c0f6d83",
                              "username": "example_sender",
                              "name": "Мария из Примера"
                            },
                            "first_message_sent_at": null,
                            "reply": {
                              "id": "e4b7a2d9-6c1f-4e38-9a5b-0d8c3f7e1a62",
                              "replied_at": "2026-10-26T09:12:00.000Z",
                              "automation_stopped": null,
                              "text": "Здравствуйте! Это я, давайте созвонимся завтра.",
                              "text_truncated": null,
                              "text_unavailable": false,
                              "text_unavailable_reason": null
                            }
                          }
                        }
                      ],
                      "has_more": false,
                      "next_cursor": "v1.k1.Qm9hcmRfMWZ4.c3RyaWN0bHlfb3BhcXVl.dGFnX2V4YW1wbGU.bWFjX2V4YW1wbGVfdmFsdWU",
                      "meta": {
                        "available_from": "2026-10-20T08:00:00.000Z",
                        "retention_days": 30,
                        "collection": {
                          "state": "running",
                          "enabled_at": "2026-10-20T08:00:00.000Z",
                          "pause_pending": false
                        },
                        "coverage": {
                          "status": "unknown",
                          "gaps": [],
                          "gaps_truncated": false,
                          "incomplete_from": null
                        },
                        "observed_at": "2026-10-27T09:15:42.000Z"
                      }
                    }
                  },
                  "start_now": {
                    "summary": "С start=now",
                    "value": {
                      "object": "list",
                      "data": [],
                      "has_more": false,
                      "next_cursor": "v1.k1.Qm9hcmRfMWZ4.c3RyaWN0bHlfb3BhcXVl.dGFnX2V4YW1wbGU.bWFjX2V4YW1wbGVfdmFsdWU",
                      "meta": {
                        "available_from": "2026-10-20T08:00:00.000Z",
                        "retention_days": 30,
                        "collection": {
                          "state": "running",
                          "enabled_at": "2026-10-20T08:00:00.000Z",
                          "pause_pending": false
                        },
                        "coverage": {
                          "status": "unknown",
                          "gaps": [],
                          "gaps_truncated": false,
                          "incomplete_from": null
                        },
                        "observed_at": "2026-10-27T09:15:42.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Ошибка: `invalid_parameter`, `unknown_parameter`, `cursor_mismatch`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_parameter",
                  "title": "Invalid parameter",
                  "status": 400,
                  "detail": "Проверьте значение параметра",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_parameter",
                  "param": "limit",
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_parameter",
              "unknown_parameter",
              "cursor_mismatch"
            ]
          },
          "401": {
            "description": "Ошибка: `invalid_api_key`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:invalid_api_key",
                  "title": "Invalid API key",
                  "status": 401,
                  "detail": "Укажите действующий Bearer-ключ",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "invalid_api_key",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "invalid_api_key"
            ]
          },
          "403": {
            "description": "Ошибка: `scope_required`, `api_disabled`, `api_not_available`, `subscription_inactive`, `module_not_available`, `organization_suspended`, `ip_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:scope_required",
                  "title": "Scope required",
                  "status": 403,
                  "detail": "Ключ не разрешает это чтение",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "scope_required",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "scope_required",
              "api_disabled",
              "api_not_available",
              "subscription_inactive",
              "module_not_available",
              "organization_suspended",
              "ip_not_allowed"
            ]
          },
          "404": {
            "description": "Ошибка: `not_found`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:not_found",
                  "title": "Not found",
                  "status": 404,
                  "detail": "Не найдено",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "not_found",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "not_found"
            ]
          },
          "405": {
            "description": "Ошибка: `method_not_allowed`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:method_not_allowed",
                  "title": "Method not allowed",
                  "status": 405,
                  "detail": "Метод не разрешен",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "method_not_allowed",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "method_not_allowed"
            ]
          },
          "410": {
            "description": "Ошибка: `cursor_expired`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:cursor_expired",
                  "title": "Cursor expired",
                  "status": 410,
                  "detail": "Курсор истек. Список начните заново без cursor. Для ленты событий отметьте разрыв, получите start=now, сверьте кампании и лиды, затем продолжите ленту",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "cursor_expired",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "cursor_expired"
            ]
          },
          "429": {
            "description": "Ошибка: `rate_limit_exceeded`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:rate_limit_exceeded",
                  "title": "Rate limit exceeded",
                  "status": 429,
                  "detail": "Лимит запросов исчерпан. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "rate_limit_exceeded",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "rate_limit_exceeded"
            ]
          },
          "503": {
            "description": "Ошибка: `service_unavailable`, `server_busy`, `integration_initializing`.",
            "headers": {
              "Request-Id": {
                "description": "Идентификатор запроса. Сохраняйте его в журналах и прикладывайте к обращениям в поддержку.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Retry-After": {
                "description": "Через сколько секунд повторить запрос. Приходит с ответами 429 и 503.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                },
                "example": {
                  "type": "urn:meliora:problem:service_unavailable",
                  "title": "Service unavailable",
                  "status": 503,
                  "detail": "Не удалось прочитать данные. Повторите позже",
                  "instance": "urn:request:0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20",
                  "code": "service_unavailable",
                  "param": null,
                  "request_id": "0f3c7a95-2e8b-4d16-b9a4-6c5e1d8f7b20"
                }
              }
            },
            "x-error-codes": [
              "service_unavailable",
              "server_busy",
              "integration_initializing"
            ]
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mel_live_<32 знака>",
        "description": "Ключ организации в заголовке `Authorization: Bearer mel_live_...`."
      }
    },
    "schemas": {
      "ApiContext": {
        "type": "object",
        "properties": {
          "object": {
            "const": "api_context",
            "description": "Тип объекта, всегда `api_context`."
          },
          "key_id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор ключа. Секрет ключа в ответах не возвращается."
          },
          "organization": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "Идентификатор организации."
              },
              "name": {
                "type": "string",
                "description": "Название организации."
              }
            },
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": false,
            "description": "Организация (кабинет), от имени которой действует ключ."
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "campaigns:read",
                "leads:read",
                "messages:read",
                "events:read"
              ]
            },
            "maxItems": 4,
            "description": "Права чтения, выданные ключу."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope",
            "description": "Охват ключа: какие пространства и кампании он видит."
          },
          "api_version": {
            "const": "v1",
            "description": "Версия API, всегда `v1`."
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда ключ перестанет действовать. `null`, если срок не задан."
          },
          "limits": {
            "$ref": "#/components/schemas/Limits",
            "description": "Лимиты запросов, действующие для ключа сейчас."
          },
          "collection": {
            "$ref": "#/components/schemas/Collection",
            "description": "Состояние сбора сохраненной переписки для API."
          }
        },
        "required": [
          "object",
          "key_id",
          "organization",
          "scopes",
          "scope",
          "api_version",
          "expires_at",
          "limits",
          "collection"
        ],
        "additionalProperties": false,
        "description": "Сведения о ключе, которым выполнен запрос: организация, права, охват, лимиты и состояние сбора."
      },
      "Scope": {
        "type": "object",
        "properties": {
          "workspace_mode": {
            "type": "string",
            "enum": [
              "all",
              "selected"
            ],
            "description": "`all`: все пространства кабинета; `selected`: только перечисленные."
          },
          "workspace_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 50,
            "description": "Выбранные пространства. Пустой массив при `workspace_mode=all`."
          },
          "workspace_include_future": {
            "type": "boolean",
            "description": "Попадают ли в охват пространства, созданные после выпуска ключа."
          },
          "campaign_mode": {
            "type": "string",
            "enum": [
              "all",
              "selected"
            ],
            "description": "`all`: все кампании выбранных пространств; `selected`: только перечисленные."
          },
          "campaign_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 500,
            "description": "Выбранные кампании. Пустой массив при `campaign_mode=all`."
          },
          "campaign_include_future": {
            "type": "boolean",
            "description": "Попадают ли в охват кампании, созданные после выпуска ключа."
          },
          "scope_version": {
            "type": "integer",
            "minimum": 1,
            "description": "Номер версии охвата. Растет при каждом изменении охвата или прав ключа."
          }
        },
        "required": [
          "workspace_mode",
          "workspace_ids",
          "workspace_include_future",
          "campaign_mode",
          "campaign_ids",
          "campaign_include_future",
          "scope_version"
        ],
        "additionalProperties": false,
        "description": "Охват ключа. Пространства и кампании за пределами охвата для ключа не существуют: запрос к ним дает 404."
      },
      "Limits": {
        "type": "object",
        "properties": {
          "key_second": {
            "type": "integer",
            "minimum": 0,
            "description": "Весовых единиц в секунду на ключ."
          },
          "key_minute": {
            "type": "integer",
            "minimum": 0,
            "description": "Весовых единиц в минуту на ключ."
          },
          "org_second": {
            "type": "integer",
            "minimum": 0,
            "description": "Весовых единиц в секунду на организацию, по всем ключам вместе."
          },
          "org_minute": {
            "type": "integer",
            "minimum": 0,
            "description": "Весовых единиц в минуту на организацию, по всем ключам вместе."
          },
          "key_concurrent": {
            "type": "integer",
            "minimum": 0,
            "description": "Одновременных запросов на ключ."
          },
          "org_concurrent": {
            "type": "integer",
            "minimum": 0,
            "description": "Одновременных запросов на организацию."
          },
          "max_response_bytes": {
            "const": 1048576,
            "description": "Наибольший размер ответа в байтах (1 МиБ). Длинные страницы сокращаются, данные не теряются."
          },
          "mode": {
            "type": "string",
            "enum": [
              "normal",
              "emergency"
            ],
            "description": "`normal`: обычный режим; `emergency`: временно сниженные лимиты."
          }
        },
        "required": [
          "key_second",
          "key_minute",
          "org_second",
          "org_minute",
          "key_concurrent",
          "org_concurrent",
          "max_response_bytes",
          "mode"
        ],
        "additionalProperties": false,
        "description": "Лимиты в весовых единицах. Вес запроса описан в руководстве «Лимиты и повторы»."
      },
      "Collection": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "running",
              "paused",
              "preparing",
              "degraded"
            ],
            "description": "`running`: сбор идет; `paused`: приостановлен в кабинете; `preparing`: готовится после включения; `degraded`: данные могут быть неполными."
          },
          "enabled_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда сбор был включен. `null`, если еще не включен."
          },
          "pause_pending": {
            "type": "boolean",
            "description": "Пауза или возобновление запрошены в кабинете, но еще не применены."
          }
        },
        "required": [
          "state",
          "enabled_at",
          "pause_pending"
        ],
        "additionalProperties": false,
        "description": "Состояние сбора сохраненной переписки для API."
      },
      "Workspace": {
        "type": "object",
        "properties": {
          "object": {
            "const": "workspace",
            "description": "Тип объекта, всегда `workspace`."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор пространства."
          },
          "name": {
            "type": "string",
            "description": "Название пространства."
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда пространство создано. Может быть `null` у старых пространств."
          }
        },
        "required": [
          "object",
          "id",
          "name",
          "created_at"
        ],
        "additionalProperties": false,
        "description": "Пространство: отдельная рабочая область кабинета со своими кампаниями."
      },
      "Campaign": {
        "type": "object",
        "properties": {
          "object": {
            "const": "campaign",
            "description": "Тип объекта, всегда `campaign`."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор кампании."
          },
          "workspace_id": {
            "type": "string",
            "format": "uuid",
            "description": "Пространство, которому принадлежит кампания."
          },
          "name": {
            "type": "string",
            "description": "Название кампании."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "scheduled",
              "active",
              "paused",
              "stopped",
              "completed",
              "archived",
              "launching",
              "failed",
              "paused_no_credits",
              "unknown"
            ],
            "description": "Статус кампании. Неизвестное значение приходит как `unknown`."
          },
          "first_message_mode": {
            "const": "template",
            "description": "Откуда берется первое сообщение. В v1 всегда `template`: из шаблона кампании."
          },
          "accepts_api_leads": {
            "const": false,
            "description": "Принимает ли кампания контакты через API. В v1 всегда `false`."
          },
          "reason": {
            "$ref": "#/components/schemas/Reason",
            "description": "Почему кампания сейчас не отправляет сообщения, если это известно."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Когда кампания создана."
          },
          "observed_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время чтения данных сервером."
          }
        },
        "required": [
          "object",
          "id",
          "workspace_id",
          "name",
          "status",
          "first_message_mode",
          "accepts_api_leads",
          "reason",
          "created_at",
          "observed_at"
        ],
        "additionalProperties": false,
        "description": "Кампания: цепочка сообщений, которую аккаунты Telegram отправляют контактам."
      },
      "Reason": {
        "type": "object",
        "properties": {
          "reason_code": {
            "type": "string",
            "enum": [
              "none",
              "schedule_window",
              "daily_limit",
              "queue_pending",
              "telegram_wait",
              "account_unavailable",
              "account_restricted",
              "campaign_paused",
              "subscription_inactive",
              "manual_hold",
              "automation_stopped",
              "service_unavailable",
              "unknown"
            ],
            "description": "Код причины."
          },
          "reason_observed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда причина была зафиксирована. `null`, если неизвестно."
          },
          "next_attempt_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда ожидается следующая попытка. `null`, если срок неизвестен."
          },
          "requires_customer_action": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "description": "Нужны ли действия в кабинете, чтобы отправка продолжилась. `null`, если неизвестно."
          }
        },
        "required": [
          "reason_code",
          "reason_observed_at",
          "next_attempt_at",
          "requires_customer_action"
        ],
        "additionalProperties": false,
        "description": "Причина ожидания. Значения описаны в руководстве «Статусы лида и доставки»."
      },
      "Lead": {
        "type": "object",
        "properties": {
          "object": {
            "const": "lead",
            "description": "Тип объекта, всегда `lead`."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор лида (участия в кампании)."
          },
          "workspace_id": {
            "type": "string",
            "format": "uuid",
            "description": "Пространство кампании."
          },
          "campaign_id": {
            "type": "string",
            "format": "uuid",
            "description": "Кампания, в которой участвует контакт."
          },
          "username": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Ник Telegram без `@`. Может быть `null`. Не уникален: используйте `fields.record_id` для связи с CRM."
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "completed",
              "replied",
              "blocked",
              "failed",
              "suspended",
              "deleted",
              "opted_out",
              "unknown"
            ],
            "description": "Статус лида в кампании."
          },
          "external_id": {
            "const": null,
            "description": "Зарезервировано для следующих версий. В v1 всегда `null`."
          },
          "fields": {
            "$ref": "#/components/schemas/Fields",
            "description": "Разрешенные поля карточки контакта."
          },
          "fields_truncated": {
            "type": "boolean",
            "description": "`true`, если часть значений полей сокращена или скрыта из-за ограничений размера."
          },
          "record_id_status": {
            "type": "string",
            "enum": [
              "valid",
              "missing",
              "conflict",
              "unknown"
            ],
            "description": "Насколько надежен `fields.record_id`: `valid`, `missing`, `conflict` или `unknown`."
          },
          "first_contact_account": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Account"
              },
              {
                "type": "null"
              }
            ],
            "description": "Аккаунт, который отправил первое сообщение. `null`, если неизвестно."
          },
          "first_message_sent_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда отправлено первое сообщение. `null`, если отправка не подтверждена."
          },
          "first_reply_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда пришел первый ответ. `null`, если ответа не было."
          },
          "delivery_state": {
            "type": "string",
            "enum": [
              "waiting_queue",
              "queued",
              "held",
              "sent",
              "failed",
              "unknown"
            ],
            "description": "Состояние доставки ближайшего или последнего сообщения цепочки."
          },
          "automation_state": {
            "type": "string",
            "enum": [
              "running",
              "paused",
              "held",
              "stopped",
              "completed",
              "unknown"
            ],
            "description": "Состояние автоматической цепочки для этого лида. У лидов без запланированного сообщения, например ответивших, сейчас часто `unknown`."
          },
          "reason": {
            "$ref": "#/components/schemas/Reason",
            "description": "Почему цепочка ждет, если это известно."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "Когда контакт добавлен в кампанию."
          },
          "observed_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время чтения данных сервером."
          }
        },
        "required": [
          "object",
          "id",
          "workspace_id",
          "campaign_id",
          "username",
          "status",
          "external_id",
          "fields",
          "fields_truncated",
          "record_id_status",
          "first_contact_account",
          "first_message_sent_at",
          "first_reply_at",
          "delivery_state",
          "automation_state",
          "reason",
          "created_at",
          "observed_at"
        ],
        "additionalProperties": false,
        "description": "Лид: участие одного контакта в одной кампании. Один и тот же человек в двух кампаниях дает два разных лида."
      },
      "Fields": {
        "type": "object",
        "properties": {
          "record_id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 128
              },
              {
                "type": "null"
              }
            ],
            "description": "Идентификатор записи во внешней CRM, переданный при загрузке контактов. `null`, если `record_id_status` не `valid`."
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Имя."
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Фамилия."
          },
          "company": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Компания."
          },
          "position": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Должность."
          },
          "website": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Сайт."
          },
          "source": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Источник контакта."
          },
          "utm_source": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Метка `utm_source`."
          },
          "utm_medium": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Метка `utm_medium`."
          },
          "utm_campaign": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1024
              },
              {
                "type": "null"
              }
            ],
            "description": "Метка `utm_campaign`."
          }
        },
        "required": [],
        "additionalProperties": false,
        "description": "Поля карточки контакта. Выдаются только перечисленные ключи; телефон, email и служебные переменные не выдаются. Значения до 1024 знаков, `record_id` до 128, всего до 8 КиБ. Поле, которого нет в карточке, отсутствует в объекте, кроме `record_id`: он есть всегда."
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор аккаунта."
          },
          "username": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Ник аккаунта без `@`. Может быть `null`."
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Отображаемое имя аккаунта. Может быть `null`."
          }
        },
        "required": [
          "id",
          "username",
          "name"
        ],
        "additionalProperties": false,
        "description": "Аккаунт Telegram, от имени которого отправлялись сообщения."
      },
      "Message": {
        "type": "object",
        "properties": {
          "object": {
            "const": "message",
            "description": "Тип объекта, всегда `message`."
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "Непрозрачный устойчивый идентификатор сообщения. Не разбирайте его формат."
          },
          "direction": {
            "type": "string",
            "enum": [
              "outbound",
              "inbound"
            ],
            "description": "`outbound`: от аккаунта к лиду; `inbound`: от лида."
          },
          "author": {
            "type": "string",
            "enum": [
              "campaign",
              "manager",
              "lead",
              "unknown"
            ],
            "description": "`campaign`: шаг цепочки; `manager`: ручное сообщение; `lead`: ответ лида; `unknown`: не определено."
          },
          "sent_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Когда сообщение отправлено или получено. `null`, если неизвестно."
          },
          "state": {
            "type": "string",
            "enum": [
              "sent",
              "received",
              "unknown"
            ],
            "description": "`sent`: отправка подтверждена; `received`: входящее сохранено; `unknown`: исход не подтвержден."
          },
          "media_kind": {
            "type": "string",
            "enum": [
              "none",
              "photo",
              "video",
              "voice",
              "audio",
              "document",
              "sticker",
              "animation",
              "video_note",
              "contact",
              "location",
              "poll",
              "other",
              "unknown"
            ],
            "description": "Вид вложения. Файлы и ссылки на них не выдаются."
          },
          "text": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 4000
              },
              {
                "type": "null"
              }
            ],
            "description": "Сохраненный текст, до 4000 знаков. `null`, если текст недоступен."
          },
          "text_truncated": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "description": "`true`: текст сокращен; `false`: текст полный; `null`: полнота неизвестна."
          },
          "text_unavailable": {
            "type": "boolean",
            "description": "`true`, если текст не выдается. Причина в `text_unavailable_reason`."
          },
          "text_unavailable_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "not_saved",
                  "ownership_unproven",
                  "source_conflict",
                  "purged"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "`not_saved`: текст не сохранен; `ownership_unproven`: принадлежность переписке не доказана; `source_conflict`: источники расходятся; `purged`: текст удален по сроку хранения."
          }
        },
        "required": [
          "object",
          "id",
          "direction",
          "author",
          "sent_at",
          "state",
          "media_kind",
          "text",
          "text_truncated",
          "text_unavailable",
          "text_unavailable_reason"
        ],
        "additionalProperties": false,
        "description": "Сообщение из сохраненной переписки с лидом. Архив может быть неполным: см. `meta.completeness`."
      },
      "Text": {
        "type": "object",
        "properties": {
          "text": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 4000
              },
              {
                "type": "null"
              }
            ],
            "description": "Сохраненный текст, до 4000 знаков. `null`, если текст недоступен."
          },
          "text_truncated": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "description": "`true`: текст сокращен; `false`: текст полный; `null`: полнота неизвестна."
          },
          "text_unavailable": {
            "type": "boolean",
            "description": "`true`, если текст не выдается."
          },
          "text_unavailable_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "not_saved",
                  "ownership_unproven",
                  "source_conflict",
                  "purged"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Причина недоступности текста или `null`."
          }
        },
        "required": [
          "text",
          "text_truncated",
          "text_unavailable",
          "text_unavailable_reason"
        ],
        "additionalProperties": false,
        "description": "Текст сообщения с признаками полноты. Используется в событиях при `include_text=true`."
      },
      "Completeness": {
        "type": "object",
        "properties": {
          "overall": {
            "type": "string",
            "enum": [
              "complete",
              "partial",
              "unknown"
            ],
            "description": "Общая полнота: `complete`, `partial` или `unknown`."
          },
          "inbound": {
            "type": "string",
            "enum": [
              "complete",
              "partial",
              "unknown"
            ],
            "description": "Полнота входящих сообщений."
          },
          "outbound": {
            "type": "string",
            "enum": [
              "complete",
              "partial",
              "unknown"
            ],
            "description": "Полнота исходящих сообщений."
          },
          "available_from": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Начало периода, за который есть данные. `null`, если неизвестно."
          },
          "available_to": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Конец периода, за который есть данные. `null`, если неизвестно."
          },
          "observed_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время чтения данных сервером."
          }
        },
        "required": [
          "overall",
          "inbound",
          "outbound",
          "available_from",
          "available_to",
          "observed_at"
        ],
        "additionalProperties": false,
        "description": "Насколько полон сохраненный архив переписки с лидом. Сейчас полнота не вычисляется: `overall` и `inbound` приходят как `partial`, `outbound` как `unknown`."
      },
      "EventLead": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор лида."
          },
          "username": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Ник Telegram без `@`. Может быть `null`."
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "completed",
              "replied",
              "blocked",
              "failed",
              "suspended",
              "deleted",
              "opted_out",
              "unknown"
            ],
            "description": "Статус лида на момент события."
          },
          "fields": {
            "$ref": "#/components/schemas/Fields",
            "description": "Поля карточки на момент события."
          },
          "fields_truncated": {
            "type": "boolean",
            "description": "`true`, если часть значений сокращена."
          },
          "record_id_status": {
            "type": "string",
            "enum": [
              "valid",
              "missing",
              "conflict",
              "unknown"
            ],
            "description": "Надежность `fields.record_id`. В v1 у событий приходит `unknown`, а `fields.record_id` равен `null`: берите `record_id` из `GET /v1/leads/{id}` по `data.lead.id`."
          }
        },
        "required": [
          "id",
          "username",
          "status",
          "fields",
          "fields_truncated",
          "record_id_status"
        ],
        "additionalProperties": false,
        "description": "Снимок лида на момент события."
      },
      "Gap": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор интервала."
          },
          "from": {
            "type": "string",
            "format": "date-time",
            "description": "Начало интервала."
          },
          "to": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Конец интервала. `null`, если интервал еще не закрыт."
          },
          "state": {
            "type": "string",
            "enum": [
              "open",
              "recovering",
              "recovered",
              "unrecoverable",
              "unknown"
            ],
            "description": "`open`, `recovering`, `recovered`, `unrecoverable` или `unknown`."
          }
        },
        "required": [
          "id",
          "from",
          "to",
          "state"
        ],
        "additionalProperties": false,
        "description": "Интервал, за который события могли собраться не полностью."
      },
      "Coverage": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "complete",
              "partial",
              "unknown"
            ],
            "description": "`complete`, `partial` или `unknown`."
          },
          "gaps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Gap"
            },
            "maxItems": 50,
            "description": "До 50 интервалов возможной неполноты."
          },
          "gaps_truncated": {
            "type": "boolean",
            "description": "`true`, если интервалов больше 50."
          },
          "incomplete_from": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "Самая ранняя граница скрытых неполных интервалов. `null`, если таких нет."
          }
        },
        "required": [
          "status",
          "gaps",
          "gaps_truncated",
          "incomplete_from"
        ],
        "additionalProperties": false,
        "description": "Полнота ленты событий."
      },
      "EventFirstMessageSent": {
        "type": "object",
        "properties": {
          "object": {
            "const": "event",
            "description": "Тип объекта, всегда `event`."
          },
          "id": {
            "type": "string",
            "pattern": "^evt_[a-f0-9]{32}$",
            "description": "Идентификатор события: `evt_` и 32 шестнадцатеричных знака. Ключ дедупликации."
          },
          "api_version": {
            "const": "2026-10-18",
            "description": "Версия формата события."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Когда произошел факт."
          },
          "test": {
            "const": false,
            "description": "Всегда `false`."
          },
          "type": {
            "const": "lead.first_message_sent",
            "description": "Тип события."
          },
          "data": {
            "type": "object",
            "properties": {
              "organization_id": {
                "type": "string",
                "format": "uuid",
                "description": "Организация, в которой произошло событие."
              },
              "workspace": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Идентификатор."
                  },
                  "name": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Название. Может быть `null`."
                  }
                },
                "required": [
                  "id",
                  "name"
                ],
                "additionalProperties": false,
                "description": "Пространство на момент события."
              },
              "campaign": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Идентификатор."
                      },
                      "name": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ],
                        "description": "Название. Может быть `null`."
                      }
                    },
                    "required": [
                      "id",
                      "name"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Кампания на момент события. Может быть `null`."
              },
              "lead": {
                "$ref": "#/components/schemas/EventLead",
                "description": "Снимок лида."
              },
              "account": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Account"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Аккаунт, который вел переписку. `null`, если неизвестно."
              },
              "first_message_sent_at": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Когда отправлено первое сообщение. `null`, если отправка не подтверждена; у события ответа это частый случай."
              },
              "first_message": {
                "$ref": "#/components/schemas/Text",
                "description": "Текст первого сообщения. Только при `include_text=true`."
              }
            },
            "required": [
              "organization_id",
              "workspace",
              "campaign",
              "lead",
              "account",
              "first_message_sent_at"
            ],
            "additionalProperties": false,
            "description": "Данные события."
          }
        },
        "required": [
          "object",
          "id",
          "api_version",
          "timestamp",
          "test",
          "type",
          "data"
        ],
        "additionalProperties": false,
        "description": "Лиду отправлено первое сообщение. `data.first_message` есть только при `include_text=true`."
      },
      "EventLeadReplied": {
        "type": "object",
        "properties": {
          "object": {
            "const": "event",
            "description": "Тип объекта, всегда `event`."
          },
          "id": {
            "type": "string",
            "pattern": "^evt_[a-f0-9]{32}$",
            "description": "Идентификатор события: `evt_` и 32 шестнадцатеричных знака. Ключ дедупликации."
          },
          "api_version": {
            "const": "2026-10-18",
            "description": "Версия формата события."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Когда произошел факт."
          },
          "test": {
            "const": false,
            "description": "Всегда `false`."
          },
          "type": {
            "const": "lead.replied",
            "description": "Тип события."
          },
          "data": {
            "type": "object",
            "properties": {
              "organization_id": {
                "type": "string",
                "format": "uuid",
                "description": "Организация, в которой произошло событие."
              },
              "workspace": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Идентификатор."
                  },
                  "name": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Название. Может быть `null`."
                  }
                },
                "required": [
                  "id",
                  "name"
                ],
                "additionalProperties": false,
                "description": "Пространство на момент события."
              },
              "campaign": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Идентификатор."
                      },
                      "name": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ],
                        "description": "Название. Может быть `null`."
                      }
                    },
                    "required": [
                      "id",
                      "name"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Кампания на момент события. Может быть `null`."
              },
              "lead": {
                "$ref": "#/components/schemas/EventLead",
                "description": "Снимок лида."
              },
              "account": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Account"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Аккаунт, который вел переписку. `null`, если неизвестно."
              },
              "first_message_sent_at": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Когда отправлено первое сообщение. `null`, если отправка не подтверждена; у события ответа это частый случай."
              },
              "reply": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Идентификатор ответа."
                  },
                  "replied_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Когда пришел ответ."
                  },
                  "automation_stopped": {
                    "anyOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Остановлена ли цепочка после ответа. `null`, если остановка не подтверждена. Сейчас всегда `null`."
                  },
                  "is_first_reply": {
                    "type": "boolean",
                    "description": "Первый ли это ответ лида в кампании. Сейчас не передается."
                  },
                  "text": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 4000
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Текст ответа. Только при `include_text=true`."
                  },
                  "text_truncated": {
                    "anyOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Признак сокращения текста. Только при `include_text=true`."
                  },
                  "text_unavailable": {
                    "type": "boolean",
                    "description": "Текст недоступен. Только при `include_text=true`."
                  },
                  "text_unavailable_reason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "not_saved",
                          "ownership_unproven",
                          "source_conflict",
                          "purged"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Причина недоступности текста. Только при `include_text=true`."
                  }
                },
                "required": [
                  "id",
                  "replied_at",
                  "automation_stopped"
                ],
                "additionalProperties": false,
                "description": "Ответ лида."
              }
            },
            "required": [
              "organization_id",
              "workspace",
              "campaign",
              "lead",
              "account",
              "first_message_sent_at",
              "reply"
            ],
            "additionalProperties": false,
            "description": "Данные события."
          }
        },
        "required": [
          "object",
          "id",
          "api_version",
          "timestamp",
          "test",
          "type",
          "data"
        ],
        "additionalProperties": false,
        "description": "Лид ответил. Приходит на каждый засчитанный ответ, у одного лида их может быть несколько. Поля текста в `data.reply` есть только при `include_text=true`."
      },
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "URI типа ошибки: `urn:meliora:problem:<code>`."
          },
          "title": {
            "type": "string",
            "description": "Короткое название ошибки на английском."
          },
          "status": {
            "type": "integer",
            "minimum": 400,
            "maximum": 599,
            "description": "HTTP-статус."
          },
          "detail": {
            "type": "string",
            "description": "Пояснение на русском или английском, по заголовку `Accept-Language`. Не разбирайте этот текст в коде."
          },
          "instance": {
            "type": "string",
            "description": "URI запроса: `urn:request:<request_id>`."
          },
          "code": {
            "type": "string",
            "description": "Машинный код ошибки. Обрабатывайте ошибки по `status` и `code`."
          },
          "param": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Параметр, к которому относится ошибка, или `null`."
          },
          "request_id": {
            "type": "string",
            "format": "uuid",
            "description": "Идентификатор запроса, тот же, что в заголовке `Request-Id`."
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "detail",
          "instance",
          "code",
          "param",
          "request_id"
        ],
        "additionalProperties": false,
        "description": "Ошибка в формате RFC 9457 (`application/problem+json`)."
      },
      "WorkspaceList": {
        "type": "object",
        "description": "Страница пространств.",
        "properties": {
          "object": {
            "const": "list",
            "description": "Тип объекта, всегда `list`."
          },
          "data": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Workspace"
            },
            "description": "Объекты страницы."
          },
          "has_more": {
            "type": "boolean",
            "description": "Есть ли еще данные после этой страницы."
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Курсор следующей страницы или `null`, если страниц больше нет."
          }
        },
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "CampaignList": {
        "type": "object",
        "description": "Страница кампаний.",
        "properties": {
          "object": {
            "const": "list",
            "description": "Тип объекта, всегда `list`."
          },
          "data": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Campaign"
            },
            "description": "Объекты страницы."
          },
          "has_more": {
            "type": "boolean",
            "description": "Есть ли еще данные после этой страницы."
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Курсор следующей страницы или `null`, если страниц больше нет."
          }
        },
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "LeadList": {
        "type": "object",
        "description": "Страница лидов.",
        "properties": {
          "object": {
            "const": "list",
            "description": "Тип объекта, всегда `list`."
          },
          "data": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Lead"
            },
            "description": "Объекты страницы."
          },
          "has_more": {
            "type": "boolean",
            "description": "Есть ли еще данные после этой страницы."
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Курсор следующей страницы или `null`, если страниц больше нет."
          }
        },
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "MessageList": {
        "type": "object",
        "description": "Страница сообщений.",
        "properties": {
          "object": {
            "const": "list",
            "description": "Тип объекта, всегда `list`."
          },
          "data": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "description": "Объекты страницы."
          },
          "has_more": {
            "type": "boolean",
            "description": "Есть ли еще данные после этой страницы."
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Курсор следующей страницы или `null`, если страниц больше нет."
          },
          "meta": {
            "type": "object",
            "description": "Сведения о полноте архива.",
            "properties": {
              "completeness": {
                "$ref": "#/components/schemas/Completeness"
              }
            },
            "required": [
              "completeness"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor",
          "meta"
        ],
        "additionalProperties": false
      },
      "EventsMeta": {
        "type": "object",
        "description": "Сведения о ленте событий.",
        "additionalProperties": false,
        "required": [
          "available_from",
          "retention_days",
          "collection",
          "coverage",
          "observed_at"
        ],
        "properties": {
          "available_from": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "description": "С какого момента в ленте есть события. `null`, если неизвестно."
          },
          "retention_days": {
            "const": 30,
            "description": "Сколько суток лента хранит события."
          },
          "collection": {
            "$ref": "#/components/schemas/Collection"
          },
          "coverage": {
            "$ref": "#/components/schemas/Coverage"
          },
          "observed_at": {
            "type": "string",
            "format": "date-time",
            "description": "Время чтения данных сервером."
          }
        }
      },
      "EventList": {
        "type": "object",
        "description": "Страница ленты событий.",
        "properties": {
          "object": {
            "const": "list",
            "description": "Тип объекта, всегда `list`."
          },
          "data": {
            "type": "array",
            "maxItems": 200,
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/EventFirstMessageSent"
                },
                {
                  "$ref": "#/components/schemas/EventLeadReplied"
                }
              ],
              "discriminator": {
                "propertyName": "type",
                "mapping": {
                  "lead.first_message_sent": "#/components/schemas/EventFirstMessageSent",
                  "lead.replied": "#/components/schemas/EventLeadReplied"
                }
              }
            },
            "description": "Объекты страницы."
          },
          "has_more": {
            "type": "boolean",
            "description": "Есть ли еще данные после этой страницы."
          },
          "next_cursor": {
            "type": "string",
            "description": "Курсор следующего опроса. Есть всегда, даже у пустой страницы."
          },
          "meta": {
            "$ref": "#/components/schemas/EventsMeta"
          }
        },
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor",
          "meta"
        ],
        "additionalProperties": false
      }
    }
  },
  "x-errors": {
    "invalid_parameter": {
      "status": 400,
      "title": "Invalid parameter",
      "detail_ru": "Проверьте значение параметра",
      "detail_en": "Check the parameter value",
      "description": "Значение параметра не подходит по формату, диапазону или сочетанию. Имя параметра в `param`."
    },
    "unknown_parameter": {
      "status": 400,
      "title": "Unknown parameter",
      "detail_ru": "Неизвестный параметр",
      "detail_en": "Unknown parameter",
      "description": "Маршрут не принимает такой параметр. Ключ API в адресе тоже дает эту ошибку."
    },
    "cursor_mismatch": {
      "status": 400,
      "title": "Cursor mismatch",
      "detail_ru": "Курсор не соответствует запросу или доступу",
      "detail_en": "The cursor does not match the request or access policy",
      "description": "Курсор поврежден, выдан для другого маршрута или фильтров, либо права и охват ключа изменились."
    },
    "invalid_api_key": {
      "status": 401,
      "title": "Invalid API key",
      "detail_ru": "Укажите действующий Bearer-ключ",
      "detail_en": "Provide a valid Bearer API key",
      "description": "Ключа нет, он неверен, отозван или истек его срок."
    },
    "scope_required": {
      "status": 403,
      "title": "Scope required",
      "detail_ru": "Ключ не разрешает это чтение",
      "detail_en": "The API key does not permit this read",
      "description": "Ключ не имеет права на это чтение. Для текстов нужен также включенный «Текст сообщений»."
    },
    "api_disabled": {
      "status": 403,
      "title": "API disabled",
      "detail_ru": "Доступ по API выключен",
      "detail_en": "API access is disabled",
      "description": "Доступ по API выключен в настройках кабинета."
    },
    "api_not_available": {
      "status": 403,
      "title": "API not available",
      "detail_ru": "Чтение API доступно с тарифа Pro",
      "detail_en": "API read access requires Pro or higher",
      "description": "Тариф кабинета не включает API. Чтение доступно с тарифа Pro."
    },
    "subscription_inactive": {
      "status": 403,
      "title": "Subscription inactive",
      "detail_ru": "Нужна действующая подписка",
      "detail_en": "An active subscription is required",
      "description": "Подписка кабинета не действует."
    },
    "module_not_available": {
      "status": 403,
      "title": "Module not available",
      "detail_ru": "В кабинете недоступен рассыльщик",
      "detail_en": "Sender is unavailable for this organization",
      "description": "В кабинете недоступен модуль рассылок."
    },
    "organization_suspended": {
      "status": 403,
      "title": "Organization suspended",
      "detail_ru": "Доступ кабинета приостановлен",
      "detail_en": "Organization access is suspended",
      "description": "Доступ кабинета приостановлен."
    },
    "ip_not_allowed": {
      "status": 403,
      "title": "IP not allowed",
      "detail_ru": "Этот IP-адрес не разрешен ключом",
      "detail_en": "This IP address is not allowed by the key",
      "description": "Запрос пришел с IP-адреса, которого нет в списке разрешенных у ключа."
    },
    "not_found": {
      "status": 404,
      "title": "Not found",
      "detail_ru": "Не найдено",
      "detail_en": "Not found",
      "description": "Объект не найден или находится вне охвата ключа. Неизвестный путь тоже дает 404."
    },
    "method_not_allowed": {
      "status": 405,
      "title": "Method not allowed",
      "detail_ru": "Метод не разрешен",
      "detail_en": "Method not allowed",
      "description": "Разрешен только метод GET. Внешний адрес отвечает на другие методы 404 без тела, поэтому этот код снаружи не встречается."
    },
    "cursor_expired": {
      "status": 410,
      "title": "Cursor expired",
      "detail_ru": "Курсор истек. Список начните заново без cursor. Для ленты событий отметьте разрыв, получите start=now, сверьте кампании и лиды, затем продолжите ленту",
      "detail_en": "The cursor expired. Restart a list without cursor. For the event feed, record the gap, request start=now, reconcile campaigns and leads, then resume the feed",
      "description": "Срок курсора истек: 15 минут для списков, 30 суток для ленты событий."
    },
    "rate_limit_exceeded": {
      "status": 429,
      "title": "Rate limit exceeded",
      "detail_ru": "Лимит запросов исчерпан. Повторите позже",
      "detail_en": "Request budget exceeded. Retry later",
      "description": "Исчерпан лимит запросов ключа, организации или IP-адреса. Повторите через `Retry-After` секунд."
    },
    "service_unavailable": {
      "status": 503,
      "title": "Service unavailable",
      "detail_ru": "Не удалось прочитать данные. Повторите позже",
      "detail_en": "Data could not be read. Retry later",
      "description": "Данные временно не прочитаны. Повторите позже."
    },
    "server_busy": {
      "status": 503,
      "title": "Server busy",
      "detail_ru": "Сервис занят. Повторите позже",
      "detail_en": "The service is busy. Retry later",
      "description": "Сервис перегружен. Повторите через `Retry-After` секунд."
    },
    "integration_initializing": {
      "status": 503,
      "title": "Integration initializing",
      "detail_ru": "Доступ еще готовится. Повторите позже",
      "detail_en": "Access is still being prepared. Retry later",
      "description": "Новый ключ еще готовится. Повторите позже."
    }
  },
  "x-limits": {
    "pro": {
      "key_second": 5,
      "key_minute": 300,
      "org_second": 10,
      "org_minute": 600,
      "key_concurrent": 5,
      "org_concurrent": 10,
      "max_response_bytes": 1048576,
      "mode": "normal"
    },
    "premium": {
      "key_second": 10,
      "key_minute": 600,
      "org_second": 25,
      "org_minute": 1500,
      "key_concurrent": 5,
      "org_concurrent": 10,
      "max_response_bytes": 1048576,
      "mode": "normal"
    },
    "enterprise": {
      "key_second": 10,
      "key_minute": 600,
      "org_second": 25,
      "org_minute": 1500,
      "key_concurrent": 5,
      "org_concurrent": 10,
      "max_response_bytes": 1048576,
      "mode": "normal"
    },
    "emergency": {
      "key_second": 1,
      "key_minute": 60,
      "org_second": 2,
      "org_minute": 120,
      "key_concurrent": 1,
      "org_concurrent": 2,
      "max_response_bytes": 1048576,
      "mode": "emergency"
    }
  },
  "x-key": {
    "pattern": "^mel_live_[A-Za-z0-9]{32}$",
    "max_active_keys": 10,
    "permissions": [
      "campaigns:read",
      "leads:read",
      "messages:read",
      "events:read"
    ]
  }
}
