{"openapi":"3.0.3","info":{"title":"Account Transfer Service API","description":"Внутренние переводы между счетами и картами клиентов obank.\n\nКонтракт REST API сервиса `in-house-payments`. Сервис брокерит запросы между\nклиентским API obank и легаси-ядром BAAS, отвечает за идемпотентность,\nдвухфазный процесс create→execute и outbox-публикацию в BAAS.\n","version":"1.0.0"},"servers":[{"url":"http://localhost:8085","description":"Локальный запуск (профиль `local`)"}],"tags":[{"name":"Transfers","description":"Валидация, создание и выполнение переводов"}],"paths":{"/api/v1/transfers/validate":{"post":{"tags":["Transfers"],"summary":"Предварительная валидация перевода","description":"Резолвит счета дебета и кредита, вычисляет тип перевода (`TransferType`)\nи для кросс-валютных операций — параметры конвертации.\nНе создаёт сущностей, может вызываться многократно.\n","operationId":"validateTransfer","parameters":[{"$ref":"#/components/parameters/UserExternalIdHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateTransferRequest"}}}},"responses":{"200":{"description":"Результат валидации (включая случай `valid=false` с кодом/сообщением)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransferValidationResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/v1/transfers":{"post":{"tags":["Transfers"],"summary":"Создать перевод (этап 1)","description":"Создаёт запись `TransferEntity` в статусе `CREATED`. Идемпотентность\nобеспечивается заголовком `Idempotency-Key`: повторный вызов с тем же\nключом вернёт уже существующий перевод.\n","operationId":"createTransfer","parameters":[{"$ref":"#/components/parameters/UserExternalIdHeader"},{"name":"Idempotency-Key","in":"header","required":true,"description":"Уникальный ключ запроса; коллизии возвращают существующую запись.","schema":{"type":"string","minLength":1,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTransferRequest"}}}},"responses":{"201":{"description":"Перевод создан (или возвращён существующий по `Idempotency-Key`)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTransferResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/v1/transfers/{transferId}/execute":{"post":{"tags":["Transfers"],"summary":"Запустить выполнение перевода (этап 2)","description":"Перевод переводится в `PROCESSING`, в той же транзакции пишется\noutbox-событие `TRANSFER_EXECUTE_REQUESTED`. Финальный статус (COMPLETED/FAILED)\nприходит асинхронно из BAAS — клиент должен опрашивать `GET /{transferId}`\nили ждать downstream-уведомление.\n","operationId":"executeTransfer","parameters":[{"$ref":"#/components/parameters/UserExternalIdHeader"},{"name":"transferId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"202":{"description":"Перевод принят к выполнению","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransferResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/v1/transfers/{transferId}":{"get":{"tags":["Transfers"],"summary":"Получить состояние перевода","operationId":"getTransferById","parameters":[{"name":"transferId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Текущее состояние перевода","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransferResponse"}}}},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}}},"components":{"parameters":{"UserExternalIdHeader":{"name":"X-User-External-Id","in":"header","required":true,"description":"Внешний идентификатор текущего пользователя.\nЧитается `SecurityContextCurrentUserProvider`; используется для проверок\n`OWN_ACCOUNTS_TRANSFER` (совпадение `ownerId` кредитуемого счёта).\n","schema":{"type":"string"}}},"responses":{"BadRequest":{"description":"Ошибка валидации или некорректный запрос","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"Ресурс не найден","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalError":{"description":"Внутренняя ошибка","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"schemas":{"ValidateTransferRequest":{"type":"object","required":["accountDebit","accountCredit","amount"],"properties":{"accountDebit":{"type":"string","minLength":1,"description":"Номер счёта/карты-отправителя"},"accountCredit":{"type":"string","minLength":1,"description":"Номер счёта/карты-получателя"},"amount":{"type":"integer","format":"int64","minimum":1,"description":"Сумма в минорных единицах валюты (Long; копейки/тыйыны)"},"description":{"type":"string","maxLength":255}}},"CreateTransferRequest":{"type":"object","required":["accountDebit","accountCredit","amount"],"properties":{"accountDebit":{"type":"string","minLength":1},"accountCredit":{"type":"string","minLength":1},"amount":{"type":"integer","format":"int64","minimum":1,"description":"Сумма в минорных единицах валюты (Long)"},"description":{"type":"string","maxLength":255}}},"TransferValidationResponse":{"type":"object","properties":{"valid":{"type":"boolean"},"code":{"type":"string","nullable":true,"description":"Код ошибки валидации (если `valid=false`)"},"message":{"type":"string","nullable":true},"transferType":{"$ref":"#/components/schemas/TransferType"},"senderName":{"type":"string","nullable":true},"recipientName":{"type":"string","nullable":true},"currency":{"type":"string","nullable":true,"description":"ISO-код валюты дебетуемого счёта"},"amount":{"type":"integer","format":"int64","nullable":true,"description":"Сумма в минорных единицах"},"availableBalance":{"type":"integer","format":"int64","nullable":true,"description":"Доступный остаток на дебетуемом счёте, минорные единицы"}}},"CreateTransferResponse":{"type":"object","required":["transferId","status","createdAt"],"properties":{"transferId":{"type":"string","format":"uuid"},"status":{"$ref":"#/components/schemas/TransferStatus"},"createdAt":{"type":"string","format":"date-time"}}},"TransferResponse":{"type":"object","required":["transferId","status","accountDebit","accountCredit","amount","createdAt"],"properties":{"transferId":{"type":"string","format":"uuid"},"status":{"$ref":"#/components/schemas/TransferStatus"},"accountDebit":{"type":"string"},"accountCredit":{"type":"string"},"amount":{"type":"integer","format":"int64","description":"Сумма в минорных единицах"},"currency":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"createdAt":{"type":"string","format":"date-time"},"executedAt":{"type":"string","format":"date-time","nullable":true},"completedAt":{"type":"string","format":"date-time","nullable":true},"requestId":{"type":"string","nullable":true,"description":"Идентификатор запроса в BAAS (как послан в `transaction.request.queue`)"},"transactionId":{"type":"integer","format":"int64","nullable":true,"description":"Идентификатор транзакции, присвоенный BAAS"},"errorCode":{"type":"string","nullable":true},"errorMessage":{"type":"string","nullable":true}}},"ErrorResponse":{"type":"object","required":["code","message","timestamp"],"properties":{"code":{"type":"string","description":"Бизнес-код ошибки (значение `ErrorCode`), например\n`VALIDATION_ERROR`, `TRANSFER_NOT_FOUND`, `ESB_ERROR`, `INTERNAL_ERROR`.\n"},"message":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"TransferStatus":{"type":"string","description":"Жизненный цикл перевода","enum":["CREATED","PROCESSING","COMPLETED","FAILED"]},"TransferType":{"type":"string","description":"Тип перевода, вычисленный по парам `(debitKind, creditKind, sameOwner?)`.\n","enum":["OWN_ACCOUNTS_TRANSFER","INTERNAL_TRANSFER","ACCOUNT_TOP_UP","ACCOUNT_WITHDRAWAL","CARD_TO_ACCOUNT_TRANSFER","ACCOUNT_TO_CARD_TRANSFER","CARD_TO_CARD_TRANSFER"]}}}}