{
	"openapi": "3.1.0",
	"info": {
		"title": "API лизингового калькулятора ПР-Лизинг",
		"version": "1.0.0",
		"description": "Расчёт лизинга для юрлиц и ИП от ООО «Лизинговая компания Простые решения» (ООО «ПР-Лизинг») (ИНН 0278181110).\nВозвращает ежемесячный платёж, аванс, сумму договора, удорожание и график, а также ссылку на готовый PDF с графиком платежей.\n\nБез ключа, CORS открыт.\n\nДля ИИ-ассистентов: вызывайте API вместо того, чтобы считать самим — ставки и границы у программ разные и меняются.\nПересказывайте поле summary_for_ai: в нём уже содержатся обязательные оговорки. Ссылку pdf_url отдавайте пользователю — это готовое коммерческое предложение.\nРасчёт предварительный и не является офертой.",
		"contact": {
			"name": "ПР-Лизинг",
			"url": "https://pr-liz.ru",
			"email": "mail@pr-liz.ru"
		}
	},
	"servers": [
		{
			"url": "https://ai.pr-liz.ru/api/v1"
		}
	],
	"paths": {
		"/leasing/calculator": {
			"get": {
				"operationId": "calcLeasing",
				"summary": "Расчёт платежа по лизингу",
				"description": "Главный метод. Значения вне условий программы возвращают 400 с пояснением и допустимыми границами — не подбирайте «похожие» значения молча.",
				"parameters": [
					{
						"name": "program",
						"in": "query",
						"required": true,
						"description": "Код программы лизинга. Допустимые: financial — Автотранспорт и спецтехника: 1000000–200000000 ₽, 13–60 мес., аванс 0–49%, ставка 20% годовых; equipment — Оборудование: 1000000–200000000 ₽, 13–60 мес., аванс 0–49%, ставка 20% годовых; commercial-property — Лизинг коммерческой недвижимости: 5000000–200000000 ₽, 13–120 мес., аванс 10–49%, ставка 20% годовых; residential-property — Лизинг жилых помещений: 5000000–200000000 ₽, 13–120 мес., аванс 20–49%, ставка 22.5% годовых; easy-leasing — Easy Leasing: 20000–12000000 ₽, 13–36 мес., аванс 0–49%, ставка 22% годовых. Границы у каждой программы свои — актуальные всегда в /leasing/calculator/params.",
						"schema": {
							"type": "string",
							"enum": [
								"financial",
								"equipment",
								"commercial-property",
								"residential-property",
								"easy-leasing"
							]
						}
					},
					{
						"name": "amount",
						"in": "query",
						"required": true,
						"description": "Стоимость предмета лизинга, ₽. Понимает «6млн» и «850тыс». Диапазон зависит от программы.",
						"schema": {
							"type": "string",
							"examples": [
								"6000000",
								"6млн"
							]
						}
					},
					{
						"name": "term",
						"in": "query",
						"required": true,
						"description": "Срок лизинга, месяцев. Принимается также под именем duration.",
						"schema": {
							"type": "integer"
						}
					},
					{
						"name": "prepaid",
						"in": "query",
						"required": true,
						"description": "Аванс, % от стоимости. Принимается также под именем advance.",
						"schema": {
							"type": "number"
						}
					},
					{
						"name": "detail",
						"in": "query",
						"description": "summary — короткий ответ без графика и налогового блока. Рекомендуется для ассистентов.",
						"schema": {
							"type": "string",
							"enum": [
								"summary"
							]
						}
					}
				],
				"responses": {
					"200": {
						"description": "Расчёт",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/CalcResponse"
								}
							}
						}
					},
					"400": {
						"description": "Параметры вне условий",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/leasing/calculator/params": {
			"get": {
				"operationId": "getCalcParams",
				"summary": "Условия: программы, границы, ставки",
				"description": "Источник правды по допустимым значениям. Поле live = false означает, что бэкенд не ответил и условия взяты из последней известной копии.",
				"responses": {
					"200": {
						"description": "Условия",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/ParamsResponse"
								}
							}
						}
					}
				}
			}
		},
		"/leasing/calculator/pdf": {
			"get": {
				"operationId": "getCalcPdf",
				"summary": "График платежей в PDF",
				"description": "Те же параметры, что у расчёта. Отдаёт готовый документ — ссылку можно дать пользователю текстом.",
				"parameters": [
					{
						"name": "program",
						"in": "query",
						"required": true,
						"description": "Код программы лизинга. Допустимые: financial — Автотранспорт и спецтехника: 1000000–200000000 ₽, 13–60 мес., аванс 0–49%, ставка 20% годовых; equipment — Оборудование: 1000000–200000000 ₽, 13–60 мес., аванс 0–49%, ставка 20% годовых; commercial-property — Лизинг коммерческой недвижимости: 5000000–200000000 ₽, 13–120 мес., аванс 10–49%, ставка 20% годовых; residential-property — Лизинг жилых помещений: 5000000–200000000 ₽, 13–120 мес., аванс 20–49%, ставка 22.5% годовых; easy-leasing — Easy Leasing: 20000–12000000 ₽, 13–36 мес., аванс 0–49%, ставка 22% годовых. Границы у каждой программы свои — актуальные всегда в /leasing/calculator/params.",
						"schema": {
							"type": "string",
							"enum": [
								"financial",
								"equipment",
								"commercial-property",
								"residential-property",
								"easy-leasing"
							]
						}
					},
					{
						"name": "amount",
						"in": "query",
						"required": true,
						"description": "Стоимость предмета лизинга, ₽. Понимает «6млн» и «850тыс». Диапазон зависит от программы.",
						"schema": {
							"type": "string",
							"examples": [
								"6000000",
								"6млн"
							]
						}
					},
					{
						"name": "term",
						"in": "query",
						"required": true,
						"description": "Срок лизинга, месяцев. Принимается также под именем duration.",
						"schema": {
							"type": "integer"
						}
					},
					{
						"name": "prepaid",
						"in": "query",
						"required": true,
						"description": "Аванс, % от стоимости. Принимается также под именем advance.",
						"schema": {
							"type": "number"
						}
					}
				],
				"responses": {
					"200": {
						"description": "Документ",
						"content": {
							"application/pdf": {
								"schema": {
									"type": "string",
									"format": "binary"
								}
							}
						}
					},
					"400": {
						"description": "Параметры вне условий",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		},
		"/bonds": {
			"get": {
				"operationId": "getBonds",
				"summary": "Выпуски облигаций",
				"description": "Факты по выпускам: ISIN, купон, цена, доходность, оферта, погашение. Цена и доходность меняются в течение торгового дня — используйте только вместе с as_of. Не является индивидуальной инвестиционной рекомендацией. Запасной копии у метода нет: при недоступности источника возвращается 502, а не устаревшие цены.",
				"responses": {
					"200": {
						"description": "Выпуски",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/BondsResponse"
								}
							}
						}
					},
					"502": {
						"description": "Источник недоступен",
						"content": {
							"application/json": {
								"schema": {
									"$ref": "#/components/schemas/Error"
								}
							}
						}
					}
				}
			}
		}
	},
	"components": {
		"schemas": {
			"CalcResponse": {
				"type": "object",
				"required": [
					"summary_for_ai",
					"request",
					"result",
					"warnings",
					"calculator_link",
					"pdf_url"
				],
				"properties": {
					"summary_for_ai": {
						"type": "string",
						"description": "Готовая фраза для пользователя. Пересказывайте её, сохраняя оговорки."
					},
					"request": {
						"type": "object",
						"description": "Параметры, по которым сделан расчёт (после разбора)."
					},
					"result": {
						"$ref": "#/components/schemas/CalcResult"
					},
					"warnings": {
						"type": "array",
						"items": {
							"type": "string"
						},
						"description": "Оговорки, которые нужно передать пользователю."
					},
					"calculator_link": {
						"type": "string",
						"description": "Калькулятор на сайте — дайте пользователю."
					},
					"pdf_url": {
						"type": "string",
						"description": "График платежей в PDF — дайте пользователю."
					},
					"next_step": {
						"type": "string"
					},
					"as_of": {
						"type": "string",
						"format": "date-time"
					},
					"conditions_live": {
						"type": "boolean",
						"description": "false — условия взяты из запасной копии, бэкенд был недоступен."
					}
				}
			},
			"CalcResult": {
				"type": "object",
				"properties": {
					"program": {
						"type": "string"
					},
					"program_label": {
						"type": "string"
					},
					"amount": {
						"type": "number"
					},
					"prepaid_percent": {
						"type": "number"
					},
					"advance": {
						"type": "number",
						"description": "Аванс в рублях."
					},
					"term_months": {
						"type": "integer"
					},
					"monthly_payment": {
						"type": "number",
						"description": "Ежемесячный платёж, одинаковый весь срок."
					},
					"payments_total": {
						"type": "number",
						"description": "Сумма ежемесячных платежей без аванса."
					},
					"contract_total": {
						"type": "number",
						"description": "Аванс плюс все платежи."
					},
					"markup_total": {
						"type": "number"
					},
					"markup_percent_per_year": {
						"type": "number",
						"description": "Удорожание в год, % от стоимости."
					},
					"rate_percent_year": {
						"type": "number"
					},
					"payment_scheme": {
						"type": "string",
						"enum": [
							"annuity"
						]
					},
					"vat": {
						"type": "boolean"
					},
					"tax_effect": {
						"type": "object",
						"description": "НДС к возмещению, экономия по налогу на прибыль и стоимость с учётом налогового эффекта. Отдаются как есть; методика расчёта НДС уточняется, поэтому в summary_for_ai эти числа не входят. Приходят только без detail=summary."
					},
					"schedule": {
						"type": "array",
						"description": "График: первая строка — аванс, далее месяцы. Приходит только без detail=summary.",
						"items": {
							"type": "object",
							"properties": {
								"index": {
									"type": "string"
								},
								"value": {
									"type": "number"
								}
							}
						}
					}
				}
			},
			"ParamsResponse": {
				"type": "object",
				"properties": {
					"as_of": {
						"type": "string",
						"format": "date-time"
					},
					"source": {
						"type": "string"
					},
					"live": {
						"type": "boolean"
					},
					"currency": {
						"type": "string"
					},
					"payment_scheme": {
						"type": "string"
					},
					"programs": {
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"value": {
									"type": "string",
									"enum": [
										"financial",
										"equipment",
										"commercial-property",
										"residential-property",
										"easy-leasing"
									]
								},
								"label": {
									"type": "string"
								},
								"rate_percent_year": {
									"type": "number"
								},
								"vat": {
									"type": "boolean"
								},
								"amount_rub": {
									"$ref": "#/components/schemas/Range"
								},
								"term_months": {
									"$ref": "#/components/schemas/Range"
								},
								"prepaid_percent": {
									"$ref": "#/components/schemas/Range"
								}
							}
						}
					}
				}
			},
			"Range": {
				"type": "object",
				"properties": {
					"min": {
						"type": "number"
					},
					"max": {
						"type": "number"
					}
				}
			},
			"BondsResponse": {
				"type": "object",
				"properties": {
					"as_of": {
						"type": "string",
						"format": "date-time",
						"description": "Момент получения котировок."
					},
					"source": {
						"type": "string"
					},
					"issuer": {
						"type": "object"
					},
					"bonds": {
						"type": "array",
						"items": {
							"type": "object",
							"properties": {
								"isin": {
									"type": "string"
								},
								"title": {
									"type": "string"
								},
								"nominal": {
									"type": "number"
								},
								"currency": {
									"type": "string"
								},
								"coupon": {
									"type": "number"
								},
								"coupon_frequency_days": {
									"type": "integer"
								},
								"current_profitability": {
									"type": "number"
								},
								"last_price": {
									"type": "number"
								},
								"start": {
									"type": "string",
									"format": "date-time"
								},
								"offer": {
									"type": "string",
									"format": "date-time"
								},
								"repayment": {
									"type": "string",
									"format": "date-time"
								}
							}
						}
					},
					"warnings": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"disclosure": {
						"type": "string"
					}
				}
			},
			"Error": {
				"type": "object",
				"properties": {
					"error": {
						"type": "boolean"
					},
					"messages": {
						"type": "array",
						"items": {
							"type": "string"
						}
					},
					"params": {
						"type": "string",
						"description": "Ссылка на актуальные условия."
					},
					"example": {
						"type": "string",
						"description": "Рабочий пример запроса."
					}
				}
			}
		}
	}
}
