{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/raiffeisen-ru/main/json-schema/raiffeisen-ru-create-external-correspondence-request-schema.json",
  "title": "CreateExternalCorrespondenceRequest",
  "x-generated": "2026-10-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/raiffeisen-ru-letters-openapi.yml#/components/schemas/CreateExternalCorrespondenceRequest",
  "type": "object",
  "properties": {
    "docExtId": {
      "type": "string",
      "description": "Идентификатор документа"
    },
    "topicId": {
      "type": "string",
      "format": "uuid",
      "description": "Идентификатор темы письма"
    },
    "text": {
      "type": "string",
      "description": "Текст письма",
      "minLength": 1,
      "maxLength": 4000,
      "pattern": ".*(\\S|\\n).*"
    },
    "docData": {
      "$ref": "#/$defs/ExternalDocData"
    }
  },
  "required": [
    "docData",
    "docExtId",
    "topicId",
    "text"
  ],
  "$defs": {
    "Date": {
      "type": "string",
      "pattern": "([0-9]{4})-([0-9]{2})-([0-9]{2})",
      "description": "yyyy-MM-dd"
    },
    "ExternalDocData": {
      "type": "object",
      "description": "Общие реквизиты платёжного документа ДБО",
      "properties": {
        "orgName": {
          "type": "string",
          "description": "Наименование организации",
          "minLength": 1,
          "maxLength": 160
        },
        "docNumber": {
          "type": "string",
          "description": "Номер документа",
          "pattern": "([1-9][0-9]{0,5})",
          "maxLength": 6
        },
        "docDate": {
          "description": "Дата составления документа",
          "$ref": "#/$defs/Date"
        },
        "account": {
          "type": "string",
          "description": "Номер счёта или корр. счёта, 20 цифр",
          "pattern": "([0-9]{20})",
          "maxLength": 20
        },
        "bic": {
          "type": "string",
          "description": "БИК, 9 цифр",
          "pattern": "([0-9]{9})",
          "maxLength": 9
        },
        "inn": {
          "type": "string",
          "description": "ИНН/КИО юридического или физического лица РФ, для КИО допустимо 5 символов, для ИНН 10 или 12 цифр",
          "pattern": "(0|[0-9]{5})|([0-9]{10})|([0-9]{12})",
          "maxLength": 12
        },
        "kpp": {
          "type": "string",
          "description": "КПП, 9 цифр, 6-я позиция м.б. буква лат. буква 12 цифр",
          "pattern": "(.*\\S.*|)"
        }
      },
      "required": [
        "docNumber",
        "docDate",
        "account",
        "bic",
        "inn"
      ]
    }
  }
}