{
  "openapi": "3.1.1",
  "info": {
    "title": "api/filer",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1/filer/": {
      "post": {
        "tags": [
          "Files"
        ],
        "summary": "Загружает файл в хранилище.",
        "operationId": "post_v1",
        "requestBody": {
          "description": "Форма multipart/form-data с файлом и полями метаданных.",
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "access_type",
                  "business_type",
                  "file"
                ],
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "description": "Файл для загрузки.",
                    "format": "binary"
                  },
                  "access_type": {
                    "enum": [
                      "Public",
                      "Firm",
                      "Contact",
                      "Authorized"
                    ],
                    "type": "string",
                    "description": "Тип доступа к файлу.\n- Public - Доступ всем без ограничений\n- Firm - Доступ в рамках фирмы\n- Contact - Доступ в рамках контакта\n- Authorized - Доступ для авторизованных пользователей",
                    "default": "Public",
                    "example": "Public"
                  },
                  "business_type": {
                    "enum": [
                      "FirmDocument",
                      "Avatar",
                      "Logo",
                      "Load",
                      "Orders",
                      "CatalogsTrucks",
                      "CatalogsDrivers"
                    ],
                    "type": "string",
                    "description": "Бизнес-тип файла (аватар, лого и т.д.), влияет на access_type и ограничения.\n- FirmDocument\n- Avatar\n- Logo\n- Load\n- Orders\n- CatalogsTrucks\n- CatalogsDrivers"
                  },
                  "delete_on": {
                    "type": "string",
                    "description": "Дата автоматического удаления.",
                    "format": "date-time",
                    "example": "2026-12-31T00:00:00Z"
                  },
                  "with_watermark": {
                    "type": "boolean",
                    "description": "Добавить водяной знак.",
                    "example": true
                  },
                  "contact_id": {
                    "type": "integer",
                    "description": "Идентификатор контакта.",
                    "format": "int32",
                    "example": 42
                  },
                  "access_list": {
                    "type": "array",
                    "items": {
                      "description": "Участник доступа к файлу: фирма и/или контакт.",
                      "$ref": "#/components/schemas/UserAccess"
                    },
                    "description": "Список доступа для типа AccessList."
                  },
                  "file_key_2": {
                    "type": "string",
                    "description": "Внешний ключ файла.",
                    "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                  },
                  "binding_tag": {
                    "type": "string",
                    "description": "Тег привязки.",
                    "example": "order-999"
                  }
                },
                "example": {
                  "access_type": "Public",
                  "business_type": "Common",
                  "delete_on": "2026-12-31T00:00:00Z",
                  "with_watermark": true,
                  "contact_id": 42,
                  "access_list": [
                    {
                      "firm_id": 100500,
                      "contact_id": 42
                    }
                  ],
                  "file_key_2": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                  "binding_tag": "order-999"
                }
              },
              "example": {
                "access_type": "Public",
                "business_type": "Common",
                "delete_on": "2026-12-31T00:00:00Z",
                "with_watermark": true,
                "contact_id": 42,
                "access_list": [
                  {
                    "firm_id": 100500,
                    "contact_id": 42
                  }
                ],
                "file_key_2": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                "binding_tag": "order-999"
              },
              "encoding": {
                "file": {
                  "style": "form"
                },
                "access_type": {
                  "style": "form"
                },
                "business_type": {
                  "style": "form"
                },
                "delete_on": {
                  "style": "form"
                },
                "with_watermark": {
                  "style": "form"
                },
                "contact_id": {
                  "style": "form"
                },
                "access_list": {
                  "style": "form"
                },
                "file_key_2": {
                  "style": "form"
                },
                "binding_tag": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Документ файла.",
                  "$ref": "#/components/schemas/FileInfoPublic"
                },
                "example": {
                  "file_key": "firm_100500_logo",
                  "file_key2": "contact_42_avatar_copy",
                  "file_name": "logo.png",
                  "content_type": "image/png",
                  "access_type": "Public",
                  "file_business_type": "Logo",
                  "add_date": "2026-03-31T09:00:00Z",
                  "delete_on": "2026-12-31T00:00:00Z",
                  "firm_id": 100500,
                  "contact_id": 42,
                  "with_watermark": true,
                  "binding_tag": "order-999"
                }
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    },
    "/v1/filer/{fileKey}": {
      "get": {
        "tags": [
          "Files"
        ],
        "summary": "Получает файл по ключу.",
        "operationId": "get_v1__fileKey_",
        "parameters": [
          {
            "name": "fileKey",
            "in": "path",
            "description": "Ключ файла.",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "firm_100500_logo"
          },
          {
            "name": "height",
            "in": "query",
            "description": "Высота для ресайза.",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 201
          },
          {
            "name": "width",
            "in": "query",
            "description": "Ширина для ресайза.",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 302
          },
          {
            "name": "biggest-side",
            "in": "query",
            "description": "Максимальная сторона для ресайза.",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 501
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Files"
        ],
        "summary": "Удаляет файл или привязку по ключу файла.",
        "operationId": "delete_v1__fileKey_",
        "parameters": [
          {
            "name": "fileKey",
            "in": "path",
            "description": "Ключ файла.",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "firm_100500_logo"
          },
          {
            "name": "binding-tag",
            "in": "query",
            "description": "Тег привязки (обязателен при наличии привязок).",
            "schema": {
              "type": "string"
            },
            "example": "order-999"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    },
    "/v1/filer/info": {
      "post": {
        "tags": [
          "Files"
        ],
        "summary": "Получает список метаданных файлов по критериям.",
        "operationId": "post_v1_info",
        "requestBody": {
          "description": "Критерии поиска (FirmId, ContactId, Keys, AtiId и т.д.).",
          "content": {
            "application/json-patch+json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/FileInfoRequestPublic"
                  }
                ],
                "example": {
                  "ati_id": "100500",
                  "contact_id": 42,
                  "business_type": "Avatar",
                  "keys": [
                    "firm_100500_logo",
                    "contact_42_avatar"
                  ],
                  "keys2": [
                    "firm_100500_logo_thumb"
                  ]
                }
              },
              "example": {
                "ati_id": "100500",
                "contact_id": 42,
                "business_type": "Avatar",
                "keys": [
                  "firm_100500_logo",
                  "contact_42_avatar"
                ],
                "keys2": [
                  "firm_100500_logo_thumb"
                ]
              }
            },
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/FileInfoRequestPublic"
                  }
                ],
                "example": {
                  "ati_id": "100500",
                  "contact_id": 42,
                  "business_type": "Avatar",
                  "keys": [
                    "firm_100500_logo",
                    "contact_42_avatar"
                  ],
                  "keys2": [
                    "firm_100500_logo_thumb"
                  ]
                }
              },
              "example": {
                "ati_id": "100500",
                "contact_id": 42,
                "business_type": "Avatar",
                "keys": [
                  "firm_100500_logo",
                  "contact_42_avatar"
                ],
                "keys2": [
                  "firm_100500_logo_thumb"
                ]
              }
            },
            "text/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/FileInfoRequestPublic"
                  }
                ],
                "example": {
                  "ati_id": "100500",
                  "contact_id": 42,
                  "business_type": "Avatar",
                  "keys": [
                    "firm_100500_logo",
                    "contact_42_avatar"
                  ],
                  "keys2": [
                    "firm_100500_logo_thumb"
                  ]
                }
              },
              "example": {
                "ati_id": "100500",
                "contact_id": 42,
                "business_type": "Avatar",
                "keys": [
                  "firm_100500_logo",
                  "contact_42_avatar"
                ],
                "keys2": [
                  "firm_100500_logo_thumb"
                ]
              }
            },
            "application/*+json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/FileInfoRequestPublic"
                  }
                ],
                "example": {
                  "ati_id": "100500",
                  "contact_id": 42,
                  "business_type": "Avatar",
                  "keys": [
                    "firm_100500_logo",
                    "contact_42_avatar"
                  ],
                  "keys2": [
                    "firm_100500_logo_thumb"
                  ]
                }
              },
              "example": {
                "ati_id": "100500",
                "contact_id": 42,
                "business_type": "Avatar",
                "keys": [
                  "firm_100500_logo",
                  "contact_42_avatar"
                ],
                "keys2": [
                  "firm_100500_logo_thumb"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "description": "Документ файла.",
                    "$ref": "#/components/schemas/FileInfoPublic"
                  },
                  "example": [
                    {
                      "file_key": "firm_100500_logo",
                      "file_key2": "contact_42_avatar_copy",
                      "file_name": "logo.png",
                      "content_type": "image/png",
                      "access_type": "Public",
                      "file_business_type": "Logo",
                      "add_date": "2026-03-31T09:00:00Z",
                      "delete_on": "2026-12-31T00:00:00Z",
                      "firm_id": 100500,
                      "contact_id": 42,
                      "with_watermark": true,
                      "binding_tag": "order-999"
                    }
                  ]
                },
                "example": [
                  {
                    "file_key": "firm_100500_logo",
                    "file_key2": "contact_42_avatar_copy",
                    "file_name": "logo.png",
                    "content_type": "image/png",
                    "access_type": "Public",
                    "file_business_type": "Logo",
                    "add_date": "2026-03-31T09:00:00Z",
                    "delete_on": "2026-12-31T00:00:00Z",
                    "firm_id": 100500,
                    "contact_id": 42,
                    "with_watermark": true,
                    "binding_tag": "order-999"
                  }
                ]
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    },
    "/v1/filer/{businessType}/{atiId}/{contactId}": {
      "get": {
        "tags": [
          "Files"
        ],
        "summary": "Получает аватар или логотип по идентификатору atiId и опционально contactId.",
        "operationId": "get_v1__businessType__atiId__contactId_",
        "parameters": [
          {
            "name": "atiId",
            "in": "path",
            "description": "Идентификатор фирмы.",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "100500"
          },
          {
            "name": "businessType",
            "in": "path",
            "description": "Бизнес-тип (Avatar или Logo).",
            "required": true,
            "schema": {
              "enum": [
                "Common",
                "FirmDocument",
                "Avatar",
                "Logo",
                "TrafficLight",
                "DriverChecker",
                "Mercury",
                "Priceline",
                "Rockwool",
                "Beigbeder",
                "Load",
                "RatingCertificate",
                "SecretaryDocumentTemplate",
                "SecretaryDocument",
                "Orders",
                "LoadsStatisticReport",
                "CatalogsTrucks",
                "CatalogsDrivers",
                "BoardApplicationRequirements",
                "Uncertain",
                "MessengerFiles",
                "GuaranteeRequestDocument",
                "ForumFile",
                "ClaimDocument",
                "TicketFile",
                "InsurancePolicy",
                "InsuranceContract",
                "InsuranceFile",
                "InsurerDocument",
                "Facsimile",
                "RecommendedPriceParsing",
                "DocflowPrintForm",
                "MercuryBids",
                "CatalogContracts"
              ],
              "allOf": [
                {
                  "$ref": "#/components/schemas/FileBusinessType"
                }
              ],
              "description": "Бизнес-тип файла (аватар, лого и т.д.), влияет на access_type и ограничения."
            },
            "example": "Logo"
          },
          {
            "name": "contactId",
            "in": "path",
            "description": "Идентификатор контакта (для аватара контакта).",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 42
          },
          {
            "name": "height",
            "in": "query",
            "description": "Высота для ресайза.",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 201
          },
          {
            "name": "width",
            "in": "query",
            "description": "Ширина для ресайза.",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 302
          },
          {
            "name": "biggest-side",
            "in": "query",
            "description": "Максимальная сторона для ресайза.",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 501
          },
          {
            "name": "not-found-type",
            "in": "query",
            "description": "Поведение при отсутствии файла.\n- Default — вернуть дефолтное изображение (лого или аватар по контексту запроса).\n- Status — ответ с кодом 404.",
            "schema": {
              "enum": [
                "Status",
                "Default"
              ],
              "allOf": [
                {
                  "$ref": "#/components/schemas/NotFoundType"
                }
              ],
              "description": "Поведение при отсутствии файла при запросе аватара или логотипа.",
              "default": "Default"
            },
            "example": "Default"
          },
          {
            "name": "fallback-img",
            "in": "query",
            "description": "Резервный тип, если запрошенного файла нет; имеет смысл при not-found-type = Default).\n- Avatar / Logo — сначала попытаться отдать файл этого типа.\n- Параметр не передан (null по умолчанию) — используется тот же тип, что в маршруте (`businessType`).",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/FileBusinessType"
                }
              ]
            },
            "example": "Avatar"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    },
    "/v1/filer/{businessType}/default": {
      "get": {
        "tags": [
          "Files"
        ],
        "summary": "Получает файл по умолчанию для аватара или логотипа.",
        "operationId": "get_v1__businessType__default",
        "parameters": [
          {
            "name": "businessType",
            "in": "path",
            "description": "Бизнес-тип (Avatar или Logo).",
            "required": true,
            "schema": {
              "enum": [
                "Common",
                "FirmDocument",
                "Avatar",
                "Logo",
                "TrafficLight",
                "DriverChecker",
                "Mercury",
                "Priceline",
                "Rockwool",
                "Beigbeder",
                "Load",
                "RatingCertificate",
                "SecretaryDocumentTemplate",
                "SecretaryDocument",
                "Orders",
                "LoadsStatisticReport",
                "CatalogsTrucks",
                "CatalogsDrivers",
                "BoardApplicationRequirements",
                "Uncertain",
                "MessengerFiles",
                "GuaranteeRequestDocument",
                "ForumFile",
                "ClaimDocument",
                "TicketFile",
                "InsurancePolicy",
                "InsuranceContract",
                "InsuranceFile",
                "InsurerDocument",
                "Facsimile",
                "RecommendedPriceParsing",
                "DocflowPrintForm",
                "MercuryBids",
                "CatalogContracts"
              ],
              "allOf": [
                {
                  "$ref": "#/components/schemas/FileBusinessType"
                }
              ],
              "description": "Бизнес-тип файла (аватар, лого и т.д.), влияет на access_type и ограничения."
            },
            "example": "Avatar"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    },
    "/v1/filer/type/{businessType}": {
      "delete": {
        "tags": [
          "Files"
        ],
        "summary": "Удаляет аватар или логотип по бизнес-типу.",
        "operationId": "delete_v1_type__businessType_",
        "parameters": [
          {
            "name": "businessType",
            "in": "path",
            "description": "Бизнес-тип (Avatar или Logo).",
            "required": true,
            "schema": {
              "enum": [
                "Common",
                "FirmDocument",
                "Avatar",
                "Logo",
                "TrafficLight",
                "DriverChecker",
                "Mercury",
                "Priceline",
                "Rockwool",
                "Beigbeder",
                "Load",
                "RatingCertificate",
                "SecretaryDocumentTemplate",
                "SecretaryDocument",
                "Orders",
                "LoadsStatisticReport",
                "CatalogsTrucks",
                "CatalogsDrivers",
                "BoardApplicationRequirements",
                "Uncertain",
                "MessengerFiles",
                "GuaranteeRequestDocument",
                "ForumFile",
                "ClaimDocument",
                "TicketFile",
                "InsurancePolicy",
                "InsuranceContract",
                "InsuranceFile",
                "InsurerDocument",
                "Facsimile",
                "RecommendedPriceParsing",
                "DocflowPrintForm",
                "MercuryBids",
                "CatalogContracts"
              ],
              "allOf": [
                {
                  "description": "Бизнес-тип файла (аватар, лого и т.д.), влияет на access_type и ограничения.\n- Common\n- FirmDocument\n- Avatar\n- Logo\n- TrafficLight\n- DriverChecker\n- Mercury\n- Priceline\n- Rockwool\n- Beigbeder\n- Load\n- RatingCertificate\n- SecretaryDocumentTemplate\n- SecretaryDocument\n- Orders\n- LoadsStatisticReport\n- CatalogsTrucks\n- CatalogsDrivers\n- BoardApplicationRequirements\n- Uncertain\n- MessengerFiles\n- GuaranteeRequestDocument\n- ForumFile\n- ClaimDocument\n- TicketFile\n- InsurancePolicy\n- InsuranceContract\n- InsuranceFile\n- InsurerDocument\n- Facsimile\n- RecommendedPriceParsing\n- DocflowPrintForm\n- MercuryBids\n- CatalogContracts",
                  "$ref": "#/components/schemas/FileBusinessType"
                }
              ],
              "description": "Бизнес-тип файла (аватар, лого и т.д.), влияет на access_type и ограничения."
            },
            "example": "Avatar"
          },
          {
            "name": "contact-id",
            "in": "query",
            "description": "Идентификатор контакта (для аватара контакта).",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 42
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Стандартный ответ с описанием ошибки",
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "UserAccess": {
        "type": "object",
        "properties": {
          "firm_id": {
            "type": [
              "null",
              "integer"
            ],
            "description": "Идентификатор фирмы.",
            "format": "int32",
            "example": 100500
          },
          "contact_id": {
            "type": [
              "null",
              "integer"
            ],
            "description": "Идентификатор контакта.",
            "format": "int32",
            "example": 42
          }
        },
        "additionalProperties": false,
        "description": "Участник доступа к файлу: фирма и/или контакт.",
        "example": {
          "firm_id": 100500,
          "contact_id": 42
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": [
              "null",
              "string"
            ],
            "description": "Код ошибки",
            "example": "invalid_input_data"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Описание ошибки",
            "example": "Неверные входные данные."
          }
        },
        "additionalProperties": false,
        "description": "Стандартный ответ с описанием ошибки",
        "example": {
          "error": "invalid_input_data",
          "reason": "Неверные входные данные."
        }
      },
      "FileInfoPublic": {
        "type": "object",
        "properties": {
          "file_key": {
            "type": [
              "null",
              "string"
            ],
            "description": "Уникальный ключ файла, генерируется сам. Ключ файла будет начинаться с его типа business_type.",
            "example": "firm_100500_logo"
          },
          "file_key2": {
            "type": [
              "null",
              "string"
            ],
            "description": "Дополнительный ключ файла (связь с другим ключом или дубликат).",
            "example": "contact_42_avatar_copy"
          },
          "file_name": {
            "type": [
              "null",
              "string"
            ],
            "description": "Имя файла.",
            "example": "logo.png"
          },
          "content_type": {
            "type": [
              "null",
              "string"
            ],
            "description": "MIME-тип содержимого.",
            "example": "image/png"
          },
          "access_type": {
            "enum": [
              "Public",
              "Firm",
              "Contact",
              "Authorized"
            ],
            "type": "string",
            "description": "Тип доступа к файлу.\n- Public - Доступ всем без ограничений\n- Firm - Доступ в рамках фирмы\n- Contact - Доступ в рамках контакта\n- Authorized - Доступ для авторизованных пользователей",
            "example": "Public"
          },
          "file_business_type": {
            "enum": [
              "FirmDocument",
              "Avatar",
              "Logo",
              "Load",
              "Orders",
              "CatalogsTrucks",
              "CatalogsDrivers"
            ],
            "type": "string",
            "description": "Бизнес-тип файла (аватар, лого и т.д.), влияет на access_type и ограничения.\n- FirmDocument\n- Avatar\n- Logo\n- Load\n- Orders\n- CatalogsTrucks\n- CatalogsDrivers",
            "example": "Logo"
          },
          "add_date": {
            "type": "string",
            "description": "Дата и время добавления записи.",
            "format": "date-time",
            "example": "2026-03-31T09:00:00Z"
          },
          "delete_on": {
            "type": [
              "null",
              "string"
            ],
            "description": "Планируемая дата удаления (отложенное удаление).",
            "format": "date-time",
            "example": "2026-12-31T00:00:00Z"
          },
          "firm_id": {
            "type": [
              "null",
              "integer"
            ],
            "description": "Идентификатор фирмы-владельца.",
            "format": "int32",
            "example": 100500
          },
          "contact_id": {
            "type": [
              "null",
              "integer"
            ],
            "description": "Идентификатор контакта-владельца.",
            "format": "int32",
            "example": 42
          },
          "access_list": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "description": "Участник доступа к файлу: фирма и/или контакт.",
              "$ref": "#/components/schemas/UserAccess"
            },
            "description": "Список дополнительных участников доступа.",
            "example": [
              {
                "firm_id": 100500,
                "contact_id": 42
              }
            ]
          },
          "with_watermark": {
            "type": [
              "null",
              "boolean"
            ],
            "description": "Признак необходимости водяного знака при отдаче.",
            "example": true
          },
          "binding_tag": {
            "type": [
              "null",
              "string"
            ],
            "description": "Тег привязки (контекст использования файла).",
            "example": "order-999"
          }
        },
        "additionalProperties": false,
        "description": "Документ файла.",
        "example": {
          "file_key": "firm_100500_logo",
          "file_key2": "contact_42_avatar_copy",
          "file_name": "logo.png",
          "content_type": "image/png",
          "access_type": "Public",
          "file_business_type": "Logo",
          "add_date": "2026-03-31T09:00:00Z",
          "delete_on": "2026-12-31T00:00:00Z",
          "firm_id": 100500,
          "contact_id": 42,
          "with_watermark": true,
          "binding_tag": "order-999",
          "access_list": [
            {
              "firm_id": 100500,
              "contact_id": 42
            }
          ]
        }
      },
      "FileInfoRequestPublic": {
        "type": "object",
        "properties": {
          "ati_id": {
            "type": [
              "null",
              "string"
            ],
            "description": "Идентификатор пользователя ATI.",
            "example": "100500"
          },
          "contact_id": {
            "type": [
              "null",
              "integer"
            ],
            "description": "Идентификатор контакта для фильтрации файлов.",
            "format": "int32",
            "example": 42
          },
          "business_type": {
            "enum": [
              "FirmDocument",
              "Avatar",
              "Logo",
              "Load",
              "Orders",
              "CatalogsTrucks",
              "CatalogsDrivers"
            ],
            "type": "string",
            "description": "Бизнес-тип запрашиваемых файлов.\n- FirmDocument\n- Avatar\n- Logo\n- Load\n- Orders\n- CatalogsTrucks\n- CatalogsDrivers",
            "example": "Avatar"
          },
          "keys": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "Список ключей файлов (основной набор).",
            "example": [
              "firm_100500_logo",
              "contact_42_avatar"
            ]
          },
          "keys2": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "Дополнительный список ключей файлов.",
            "example": [
              "firm_100500_logo_thumb"
            ]
          }
        },
        "additionalProperties": false,
        "example": {
          "firm_id": 100500,
          "ati_id": "100500",
          "contact_id": 42,
          "business_type": "Avatar",
          "keys": [
            "firm_100500_logo",
            "contact_42_avatar"
          ],
          "request_firm_id": 100500,
          "request_contact_id": 42,
          "keys2": [
            "firm_100500_logo_thumb"
          ]
        }
      },
      "FileBusinessType": {
        "enum": [
          "Common",
          "FirmDocument",
          "Avatar",
          "Logo",
          "TrafficLight",
          "DriverChecker",
          "Mercury",
          "Priceline",
          "Rockwool",
          "Beigbeder",
          "Load",
          "RatingCertificate",
          "SecretaryDocumentTemplate",
          "SecretaryDocument",
          "Orders",
          "LoadsStatisticReport",
          "CatalogsTrucks",
          "CatalogsDrivers",
          "BoardApplicationRequirements",
          "Uncertain",
          "MessengerFiles",
          "GuaranteeRequestDocument",
          "ForumFile",
          "ClaimDocument",
          "TicketFile",
          "InsurancePolicy",
          "InsuranceContract",
          "InsuranceFile",
          "InsurerDocument",
          "Facsimile",
          "RecommendedPriceParsing",
          "DocflowPrintForm",
          "MercuryBids",
          "CatalogContracts"
        ],
        "type": "string",
        "description": "Бизнес-тип файла (аватар, лого и т.д.), влияет на access_type и ограничения.\n- Common\n- FirmDocument\n- Avatar\n- Logo\n- TrafficLight\n- DriverChecker\n- Mercury\n- Priceline\n- Rockwool\n- Beigbeder\n- Load\n- RatingCertificate\n- SecretaryDocumentTemplate\n- SecretaryDocument\n- Orders\n- LoadsStatisticReport\n- CatalogsTrucks\n- CatalogsDrivers\n- BoardApplicationRequirements\n- Uncertain\n- MessengerFiles\n- GuaranteeRequestDocument\n- ForumFile\n- ClaimDocument\n- TicketFile\n- InsurancePolicy\n- InsuranceContract\n- InsuranceFile\n- InsurerDocument\n- Facsimile\n- RecommendedPriceParsing\n- DocflowPrintForm\n- MercuryBids\n- CatalogContracts",
        "x-ms-enum-flags": {
          "isFlags": false
        }
      },
      "NotFoundType": {
        "enum": [
          "Status",
          "Default"
        ],
        "type": "string",
        "description": "Поведение при отсутствии файла при запросе аватара или логотипа.\n- Status (Вернуть статус «не найдено»)\n- Default (Подставить изображение по умолчанию)",
        "x-ms-enum-flags": {
          "isFlags": false
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}