{
    "openapi": "3.0.3",
    "info": {
        "title": "Unmark API",
        "version": "1.0.0",
        "description": "Удаление логотипа доски объявлений с фотографии. Запрос ставит задачу в очередь и возвращает task_id. Результат запрашивается отдельно. Стоимость одного шага задаётся для пользователя и по умолчанию равна 0.20 ₽. Если меньшая сторона меньше 640 px и в запросе передан enlarge=1, сначала фото увеличивается, затем с него снимается логотип: два списания. Без enlarge такое фото сразу получает ошибку, деньги не списываются. Готовое фото сохраняется на CDN."
    },
    "servers": [
        {
            "url": "https:\/\/unmark.bpmtop.ru"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer"
            },
            "apiToken": {
                "type": "apiKey",
                "in": "query",
                "name": "api_token"
            }
        }
    },
    "security": [
        {
            "bearerAuth": []
        },
        {
            "apiToken": []
        }
    ],
    "paths": {
        "\/api\/v1\/watermark": {
            "post": {
                "summary": "Поставить задачу на удаление логотипа",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart\/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "picture"
                                ],
                                "properties": {
                                    "picture": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "JPEG, PNG или WebP до 4 МБ"
                                    },
                                    "enlarge": {
                                        "type": "string",
                                        "description": "1 — если сторона меньше 640 px, сначала увеличить фото. Без этого параметра маленькое фото отклоняется без списания.",
                                        "example": "1"
                                    },
                                    "api_token": {
                                        "type": "string",
                                        "description": "Токен, если он не передан в Authorization"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Задача поставлена в очередь. В теле success, task_id (хэш, не числовой id) и status=queued. Готового JPEG здесь нет: результат запрашивается GET \/api\/v1\/tasks\/{task_id}.",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "task_id": {
                                            "type": "string",
                                            "example": "a1b2c3d4e5f6789012345678abcdef01a1b2c3d4e5f6789012345678abcdef01"
                                        },
                                        "status": {
                                            "type": "string",
                                            "example": "queued"
                                        },
                                        "balance": {
                                            "type": "string",
                                            "example": "10.00",
                                            "description": "Текущий баланс, ₽. Есть в каждом ответе с верным токеном."
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Файл не подходит"
                    },
                    "401": {
                        "description": "Нет токена"
                    },
                    "402": {
                        "description": "Недостаточно средств"
                    },
                    "502": {
                        "description": "Не удалось принять фото"
                    }
                }
            }
        },
        "\/api\/v1\/tasks\/{id}": {
            "get": {
                "summary": "Статус задачи и ссылка на готовое фото",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "pattern": "^[a-fA-F0-9]{64}$"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Проверка результата. queued и processing — повторите запрос позже, url пустой. success — в url ссылка на JPEG, в charged списание. error — текст в error, charged равен 0. Чужой хэш даёт 404.",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "task_id": {
                                            "type": "string"
                                        },
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "enlarge": {
                                            "type": "boolean"
                                        },
                                        "charged": {
                                            "type": "string",
                                            "example": "0.20"
                                        },
                                        "balance": {
                                            "type": "string",
                                            "example": "9.80"
                                        },
                                        "width": {
                                            "type": "integer",
                                            "nullable": true
                                        },
                                        "height": {
                                            "type": "integer",
                                            "nullable": true
                                        },
                                        "url": {
                                            "type": "string",
                                            "nullable": true
                                        },
                                        "error": {
                                            "type": "string",
                                            "nullable": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Нет токена"
                    },
                    "404": {
                        "description": "Задача не найдена"
                    }
                }
            }
        },
        "\/api\/v1\/account": {
            "get": {
                "summary": "Баланс, цена запроса и токен",
                "responses": {
                    "200": {
                        "description": "Счёт пользователя",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "balance": {
                                            "type": "string",
                                            "example": "10.00"
                                        },
                                        "currency": {
                                            "type": "string",
                                            "example": "RUB"
                                        },
                                        "request_price": {
                                            "type": "string",
                                            "example": "0.20"
                                        },
                                        "token": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Нет токена"
                    }
                }
            }
        }
    }
}