openapi: 3.0.1
info:
  title: ЭДО Счет на оплату
  description: API для создание счета на оплату.
  version: 01.00.000
servers:
  - url: https://fintech-test.sberbank.ru:9443/fintech/api
    description: Песочница
  - url: https://fintech.sberbank.ru:9443/fintech/api
    description: Промышленный контур
paths:
  /v1/payment-invoice:
    post:
      summary: Создание счёта на оплату
      description: Для доступа к этому методу в параметре `scope` ссылки авторизации пользователя должен быть указан сервис `BILL_INVOICE`.
      operationId: autocreateExternal
      parameters:
        - name: X-Rq-Uid
          in: header
          description: Уникальный идентификатор запроса (сквозной корреляционный ID)
          required: true
          schema:
            type: string
            format: uuid
        - name: Authorization
          in: header
          description: Bearer access token организации-клиента, полученный через SSO
          example: "Bearer eyJhbGciOi..."
          required: true
          schema:
            type: string
            minLength: 1
            pattern: '.*\S.*'
      requestBody:
        description: Запрос на автоматическое создание и отправку счёта на оплату
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceAutoCreateRequest'
      responses:
        '201':
          description: Счёт успешно создан
          headers:
            X-Rq-Uid:
              description: Эхо сквозного корреляционного ID запроса (из заголовка X-Rq-Uid запроса). Используется для учёта потребления.
              schema:
                type: string
                format: uuid
            X-Request-Statistics-External-Id:
              description: Идентификатор созданного счёта (paymentInvoiceId). Используется для учёта потребления.
              schema:
                type: string
                format: uuid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceAutoCreateResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '403':
          $ref: '#/components/responses/ErrorResponse'
        '500':
          $ref: '#/components/responses/ErrorResponse'
  /v1/payment-invoice/{paymentInvoiceId}/state:
    get:
      summary: Получение статуса счёта на оплату
        
      description: |
        Возвращает только статус документа по идентификатору счёта.

        Для доступа к этому методу в параметре `scope` ссылки авторизации пользователя должен быть указан сервис `BILL_INVOICE`.
      operationId: getPaymentInvoiceStatus
      parameters:
        - in: path
          name: paymentInvoiceId
          schema:
            type: string
            format: uuid
          required: true
          example: "2c01e846-25b2-4a35-a49a-b1968836be7d"
          description: Идентификатор счёта на оплату
        - in: header
          name: X-Rq-Uid
          schema:
            type: string
            format: uuid
          required: true
          example: "95fc1390-bb33-5b34-b16e-9274c46443e7"
          description: Уникальный идентификатор запроса
        - in: header
          name: Authorization
          schema:
            type: string
          required: true
          example: "Bearer eyJhbGciOi..."
          description: Токен авторизации, полученный через SSO
      responses:
        "200":
          description: Успех
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentInvoiceStatusResponse'
        "400":
          $ref: '#/components/responses/ErrorResponse'
        "401":
          $ref: '#/components/responses/ErrorResponse'
        "403":
          $ref: '#/components/responses/ErrorResponse'
        "404":
          $ref: '#/components/responses/ErrorResponse'
        "500":
          $ref: '#/components/responses/ErrorResponse'
  /v1/payment-invoice/{paymentInvoiceId}:
    get:
      summary: Получение счёта на оплату
      description: |
        Возвращает полный перечень реквизитов документа по идентификатору счёта.

        Для доступа к этому методу в параметре `scope` ссылки авторизации пользователя должен быть указан сервис `BILL_INVOICE`.
      operationId: getPaymentInvoice
      parameters:
        - in: path
          name: paymentInvoiceId
          schema:
            type: string
            format: uuid
          required: true
          example: "2c01e846-25b2-4a35-a49a-b1968836be7d"
          description: Идентификатор счёта на оплату
        - in: header
          name: X-Rq-Uid
          schema:
            type: string
            format: uuid
          required: true
          example: "95fc1390-bb33-5b34-b16e-9274c46443e7"
          description: Уникальный идентификатор запроса
        - in: header
          name: Authorization
          schema:
            type: string
          required: true
          example: "Bearer eyJhbGciOi..."
          description: Токен авторизации, полученный через SSO
      responses:
        "200":
          description: Успех
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentInvoiceResponse'
        "400":
          $ref: '#/components/responses/ErrorResponse'
        "401":
          $ref: '#/components/responses/ErrorResponse'
        "403":
          $ref: '#/components/responses/ErrorResponse'
        "404":
          $ref: '#/components/responses/ErrorResponse'
        "500":
          $ref: '#/components/responses/ErrorResponse'
components:
  responses:
    ErrorResponse:
      description: Неуспешный ответ
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    PaymentInvoiceStatus:
      type: string
      description: Список статусов документа
      enum:
        - CREATED
        - ERROR
        - PARTSIGNED
        - SIGNED
        - SENT
        - DELETED
        - PENDING
        - EXPIRED
        - PAID
        - CONFIRMED
        - REJECTED
        - APPROVED
        - WAITING
        - DELIVERED
        - NOT_DELIVERED
        - RECEIPT_NOTIFICATION_WAITING
        - CLARIFICATION_WAITING
        - CANCEL_REQUEST_RECEIVED
        - CANCEL_REQUEST_SENT
        - CANCELLED
        - COMPLETED
        - RECIPIENT_ACTION_WAITING
    PaymentInvoiceStatusResponse:
      type: object
      properties:
        bankStatus:
          $ref: '#/components/schemas/PaymentInvoiceStatus'
      description: Ответ получения статуса счёта на оплату
    PaymentInvoiceResponse:
      type: object
      properties:
        paymentInvoice:
          $ref: '#/components/schemas/PaymentInvoice'
      description: Модель ответа Счёта на оплату
    PaymentInvoice:
      type: object
      properties:
        id:
          type: string
          description: Идентификатор документа в БД
          format: uuid
          example: 4763ed99-1825-4897-8c16-03cdceaf7f30
        docNumber:
          type: string
          description: Номер документа
          example: "1"
        docVersion:
          type: number
          description: Версия документа
          example: 1
        createDateTime:
          type: string
          description: Дата создания документа
          format: date-time
          example: 2026-10-21T10:56:42.003665Z
        updateDateTime:
          type: string
          description: Дата последнего обновления документа
          format: date-time
          example: 2026-10-21T10:56:42.003665Z
        issueDate:
          type: string
          description: Дата выставления Счета на оплату
          format: date-time
          example: 2023-01-30T08:30:00Z
        bankStatus:
          $ref: '#/components/schemas/PaymentInvoiceStatus'
        ground:
          type: string
          description: Основание выставления Счета на оплату
          example: По договору №55575
        comment:
          type: string
          description: Комментарий к документу
          example: Комментарий к документу
        payDate:
          type: string
          description: Дата оплаты по Счету
          format: date-time
          example: 2023-01-30T08:30:00Z
        email:
          type: string
          description: Почта получателя счета (можно указать до 3 штук)
          example: "test1@test.ru, test2@test.ru"
        payerRequisites:
          $ref: '#/components/schemas/PayerRequisites'
        payeeRequisites:
          $ref: '#/components/schemas/PayeeRequisites'
        services:
          type: array
          description: Список услуг/товаров
          items:
            $ref: '#/components/schemas/Service'
        totalAmount:
          type: number
          description: Полная сумма документа без учёта НДС
          format: decimal
          example: 1.1234
        currency:
          type: string
          description: Валюта документа
          example: RUB
        totalVatAmount:
          type: number
          description: Полная сумма налога документа
          format: decimal
          example: 1.1234
        costToPay:
          type: number
          description: Остаток суммы оплаты
          format: decimal
          example: 100.12
        direction:
          type: string
          description: Тип документа по направлению (Входящий или Исходящий)
          enum:
            - INCOMING
            - OUTGOING
        sendSms:
          type: boolean
          description: Признак отправки счета через СМС
          example: false
        sendEmail:
          type: boolean
          description: Признак отправки счета по email
          example: true
        phoneNumber:
          type: string
          description: Номер телефона для отправки счета через СМС
          example: "79991234567"
        externalPrintLink:
          $ref: '#/components/schemas/Link'
        uploadedDocId:
          type: string
          description: Идентификатор загруженного документа
          format: uuid
      description: Счёт на оплату
    PayerRequisites:
      type: object
      properties:
        account:
          type: string
          description: Номер счета
          example: "4080281000000000001"
        bankName:
          type: string
          description: Наименование банка
          example: ПАО Сбербанк
        bankAccount:
          type: string
          description: Корр счет банка
          example: "4080281000000000002"
        inn:
          type: string
          minLength: 5
          maxLength: 12
          description: ИНН
          example: "1234567890"
        kpp:
          type: string
          minLength: 9
          maxLength: 9
          description: КПП
          example: "123456789"
        bic:
          type: string
          minLength: 9
          maxLength: 9
          description: БИК банка
          example: "123456789"
        legalName:
          type: string
          description: Наименование (для ИП или юр. лица)
          example: ООО Открытие
        legalAddress:
          $ref: '#/components/schemas/LegalAddress'
        type:
          type: string
          description: Тип контрагента на фабрике Партнеры
          enum:
            - PHYSICAL_PERSON
            - LEGAL_ENTITY
            - ENTREPRENEUR
            - FOREIGN_LEGAL_ENTITY
            - FOREIGN_CITIZEN
        externalUuid:
          type: string
          description: Идентификатор контрагента на фабрике Партнеры
          format: uuid
          example: 4763ed99-1825-4897-8c16-03cdceaf7f30
        firstName:
          type: string
          description: Имя (для физ. лица)
          example: Иван
        middleName:
          type: string
          description: Отчество (для физ. лица)
          example: Иванович
        lastName:
          type: string
          description: Фамилия (для физ. лица)
          example: Иванов
      description: Реквизиты плательщика
    PayeeRequisites:
      type: object
      properties:
        account:
          type: string
          description: Номер счета
          example: "4080281000000000001"
        bankName:
          type: string
          description: Наименование банка
          example: ПАО Сбербанк
        bankAccount:
          type: string
          description: Корр счет банка
          example: "4080281000000000002"
        inn:
          type: string
          minLength: 5
          maxLength: 12
          description: ИНН
          example: "1234567890"
        kpp:
          type: string
          minLength: 9
          maxLength: 9
          description: КПП
          example: "123456789"
        bic:
          type: string
          minLength: 9
          maxLength: 9
          description: БИК банка
          example: "123456789"
        legalName:
          type: string
          description: Наименование (для ИП или юр. лица)
          example: ООО Открытие
        legalAddress:
          $ref: '#/components/schemas/LegalAddress'
      description: Реквизиты отправителя Счета
    Service:
      type: object
      properties:
        id:
          type: string
          description: Идентификатор товара/услуги
          format: uuid
          example: 4763ed99-1825-4897-8c16-03cdceaf7f30
        index:
          type: integer
          description: Порядковый номер в списке товаров/услуг
          format: int32
        unit:
          $ref: '#/components/schemas/Unit'
        name:
          type: string
          description: Название товара/услуги
          example: Дрова
        pricePerExemplar:
          type: number
          description: Стоимость экземпляра товара/услуги
          format: decimal
          example: 1.1234
        amount:
          type: number
          description: Стоимость полного количества товара/услуги
          format: decimal
          example: 1.1234
        currency:
          type: string
          description: Валюта документа
          example: RUB
        quantity:
          type: number
          description: Количество товара/услуги
          format: decimal
          example: 1.1
        vatAmount:
          type: number
          description: Сумма НДС на полное количество товара/услуги
          format: decimal
          example: 0
        vat:
          type: number
          description: Показатель НДС из справочника
          format: decimal
          example: 20
        externalUuid:
          type: string
          description: Внешний идентификатор услуги/товара
          example: 1163ed99-1825-4897-8c16-03cdceaf7f30
        version:
          type: number
          description: Версия документа
          example: 2
      description: Товар/услуга
    Link:
      type: object
      properties:
        link:
          type: string
          description: Ссылка на печатную форму
          example: https://efs-sbbol-ift-web.testsbi.sberbank.ru:9443/ic/ufs/sbbol-ddm-web/07.000/rest/external/print-email/47620abf-afb0-42e1-8b1f-db77c2921a33
        lifeTime:
          type: integer
          description: Время жизни ссылки
          format: int64
          example: 72
        lifeTimeUnit:
          type: string
          description: Единица измерения времени жизни
          example: hour
      description: Ссылка на печатную форму
    Unit:
      type: object
      properties:
        code:
          type: integer
          description: Код
          format: int32
          example: 12
        description:
          type: string
          description: Полное наименование
          example: Штука
        name:
          type: string
          description: Условное наименование
          example: шт.
      description: Единица измерения
    LegalAddress:
      type: object
      properties:
        common:
          type: string
          description: Полный юридический адрес плательщика
          example: "121108, Москва, Кутузовский проспект, д.1"
        zipCode:
          type: string
          description: Почтовый индекс плательщика
          example: "121108"
        regionCode:
          type: string
          description: Код региона плательщика
          example: "77"
        region:
          type: string
          description: Регион плательщика
          example: Дорогомилово
        city:
          type: string
          description: Город плательщика
          example: Москва
        locality:
          type: string
          description: Населенный пункт плательщика
          example: Зеленоград
        street:
          type: string
          description: Улица плательщика
          example: Кутузовский проспект
        building:
          type: string
          description: Здание плательщика
          example: "3"
        buildingBlock:
          type: string
          description: Корпус плательщика
          example: "2"
        flat:
          type: string
          description: Квартира плательщика
          example: "32"
      description: Юридический адрес плательщика
    InvoiceAutoCreateResponse:
      type: object
      properties:
        paymentInvoiceId:
          type: string
          description: Идентификатор документа в БД
          format: uuid
          example: 4763ed99-1825-4897-8c16-03cdceaf7f30
        docNumber:
          type: string
          description: Номер документа
          example: "1"
        issueDate:
          type: string
          description: Дата выставления Счета на оплату
          format: date-time
          example: 2023-01-30T08:30:00Z
        bankStatus:
          type: string
          description: Статус счёта
          example: "SENT"
        bankComment:
          type: string
          description: >-
            Сообщение по результатам проверки счёта. Заполняется при
            bankStatus = ERROR, при остальных статусах значение пустое.
          example: Некорректные реквизиты плательщика
        ground:
          type: string
          description: Основание выставления Счета на оплату
          example: По договору №55575
        comment:
          type: string
          description: Комментарий к документу
          example: Комментарий к документу
        payDate:
          type: string
          description: Дата оплаты по Счету
          format: date-time
          example: 2023-01-30T08:30:00Z
        email:
          type: string
          description: Почта получателя счета (можно указать до 3 штук)
          example: "test1@test.ru, test2@test.ru"
        payerRequisites:
          $ref: '#/components/schemas/PayerRequisites'
        payeeRequisites:
          $ref: '#/components/schemas/PayeeRequisites'
        services:
          type: array
          description: Список услуг/товаров
          items:
            $ref: '#/components/schemas/Service'
        totalAmount:
          type: number
          description: Полная сумма документа без учёта НДС
          format: decimal
          example: 1.1234
        currency:
          type: string
          description: Валюта документа
          example: RUB
        totalVatAmount:
          type: number
          description: Полная сумма налога документа
          format: decimal
          example: 1.1234
        costToPay:
          type: number
          description: Остаток суммы оплаты
          format: decimal
          example: 100.12
        sendSms:
          type: boolean
          description: Признак отправки счета через СМС
          example: false
        sendEmail:
          type: boolean
          description: Признак отправки счета по email
          example: true
        phoneNumber:
          type: string
          description: Номер телефона для отправки счета через СМС
          example: "79991234567"
        externalPrintLink:
          $ref: '#/components/schemas/Link'
      description: Счёт на оплату
    ErrorResponse:
      required:
        - cause
        - message
        - referenceId
        - internalErrorCode
      type: object
      properties:
        cause:
          type: string
          description: Код группы ошибки
          enum:
            - VALIDATION_FAULT
            - UNAUTHORIZED
            - WORKFLOW_FAULT
            - ACTION_ACCESS_EXCEPTION
            - UNKNOWN_EXCEPTION
            - DATA_NOT_FOUND_EXCEPTION
          example: VALIDATION_FAULT
        message:
          type: string
          description: Описание ошибки
          example: Ошибка валидации, проверьте обязательные поля запроса.
        referenceId:
          type: string
          format: uuid
          description: Идентификатор инцидента
          example: 95fc1390-bb33-5b34-b16e-9274c46443e7
        internalErrorCode:
          type: string
          description: Внутренний код ошибки
          example: 433.1.1000
      description: Неуспешный ответ
    InvoiceAutoCreateRequest:
      type: object
      description: Запрос на автоматическое создание и отправку счёта на оплату
      required:
        - payeeRequisites
        - issueDate
        - services
        - totalAmount
        - currency
        - payerRequisites
      properties:
        payeeRequisites:
          $ref: '#/components/schemas/PayeeBlock'
        issueDate:
          type: string
          description: Дата выставления Счета на оплату
          format: date-time
          example: 2023-01-30T08:30:00Z
        payDate:
          type: string
          description: Дата оплаты по Счету
          format: date-time
          example: 2023-01-30T08:30:00Z
        ground:
          type: string
          description: Основание выставления Счета на оплату
          example: По договору №55575
        comment:
          type: string
          description: Комментарий к документу
          example: Комментарий к документу
        email:
          type: string
          description: >-
            Почта получателя счета (можно указать до 3 штук). Обязательна при sendEmail=true
          example: "test1@test.ru, test2@test.ru"
        services:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ServiceItem'
        totalAmount:
          type: number
          description: Полная сумма документа без учёта НДС
          format: decimal
          example: 1.1234
        currency:
          type: string
          description: Валюта документа
          example: RUB
        totalVatAmount:
          type: number
          description: Полная сумма налога документа
          format: decimal
          example: 1.1234
        payerRequisites:
          $ref: '#/components/schemas/PayerBlock'
        sendEmail:
          type: boolean
          description: Признак отправки счета по email.
          example: true
        sendSms:
          type: boolean
          description: >-
            Признак отправки счета через СМС. Требует phoneNumber
          example: false
        phoneNumber:
          type: string
          description: Номер телефона для отправки счета через СМС (обязателен при sendSms=true)
          example: "79991234567"
    PayeeBlock:
      type: object
      description: Блок реквизитов получателя средств
      required:
        - account
        - bic
      properties:
        account:
          type: string
          description: Номер расчётного счёта получателя
          minLength: 1
          pattern: '.*\S.*'
          example: "4080281000000000001"
        bic:
          type: string
          description: БИК банка получателя
          minLength: 1
        bankAccount:
          type: string
          description: Корреспондентский счёт банка получателя (необязательный)
          example: "4080281000000000001"
    ServiceItem:
      type: object
      description: Позиция товара/услуги
      properties:
        name:
          type: string
          description: Наименование товара/услуги
          example: Дрова
        quantity:
          type: number
          description: Количество товара/услуги
          format: decimal
          example: 1.1
        price:
          type: number
          description: Стоимость экземпляра товара/услуги
          format: decimal
          example: 1.1234
        amount:
          type: number
          description: Сумма на полное количество товара/услуги
          format: decimal
          example: 0
        vatAmount:
          type: number
          description: Сумма НДС на полное количество товара/услуги
          format: decimal
          example: 0
        vat:
          type: number
          description: Показатель НДС из справочника.
          enum:
            - 0
            - 5
            - 7
            - 10
            - 20
            - 22
          example: 20
        unit:
          $ref: '#/components/schemas/UnitItem'
    UnitItem:
      type: object
      description: Единица измерения товара/услуги. 
      required:
        - code
        - name
      properties:
        code:
          type: integer
          description: Код единицы измерения из справочника ОКЕИ
          format: int32
          maximum: 99999
          example: 12
        name:
          type: string
          description: Условное наименование
          example: шт.
        description:
          type: string
          description: Полное наименование
          example: Штука
    PayerBlock:
      type: object
      description: Реквизиты плательщика
      required:
        - type
      properties:
        account:
          type: string
          description: Номер расчётного счёта плательщика (необязательный)
          example: "4080281000000000001"
        bankAccount:
          type: string
          description: Корреспондентский счёт банка плательщика (необязательный)
          example: "4080281000000000001"
        legalName:
          type: string
          description: Наименование (для ИП или юр. лица)
          example: ООО Открытие
        inn:
          type: string
          minLength: 5
          maxLength: 12
          description: ИНН
          example: "1234567890"
        kpp:
          type: string
          minLength: 9
          maxLength: 9
          description: КПП
          example: "123456789"
        lastName:
          type: string
          description: Фамилия (для физ. лица)
          example: Иванов
        firstName:
          type: string
          description: Имя (для физ. лица)
          example: Иван
        middleName:
          type: string
          description: Отчество (для физ. лица)
          example: Иванович
        type:
          type: string
          description: Тип плательщика
          enum:
            - PHYSICAL_PERSON
            - LEGAL_ENTITY
            - ENTREPRENEUR
            - FOREIGN_LEGAL_ENTITY
            - FOREIGN_CITIZEN
