KSC Open API
Kaspersky Security Center API description
wstring LicenseKeys::InstallKey ( params  pKeyInfo)

Add a license to license storage of administration server.

Due to the requirement to use licenses from activation 2.0 servers in priority use the following algorithm:

  1. Call InstallKey specifying an activation code;
  2. If the method returns error KLOLA::KLOLA_ERR_SERVER and subcode KLOLAEL_ERR_LICENSE_NOT_FOUND or subcode KLOLAEL_ERR_SERVER_1_REQUIRED, then download key files from activation servers 1.0 using the DownloadKeyFiles method, otherwise do not download key files (see Some error definitions);
  3. Call InstallKey for each downloaded key file (if they were downloaded)
Parameters:
pKeyInfo(params) input data container, mandatory:
Add a license by specifying contents of a key file:
  • - "KLLICSRV_KEYDATA" - key data container, mandatory (paramParams)
    • - "KLLIC_IFKEYFILE" - set to true in this case, mandatory (paramBool)
    • - "KLLIC_LICFILE" - keyfile body, mandatory (paramBinary)
Add a license by specifying just an activation code (license information will be requested from the activation server 2.0):
  • - "KLLICSRV_KEYDATA" - key data container, mandatory (paramParams)
    • - "KLLIC_IFKEYFILE" - set to false in this case (paramBool)
    • - "KLLIC_LICFILE" - ASCII-encoded string with activation code in format of XXXXX-XXXXX-XXXXX-XXXXX (exactly 23 characters long buffer) (paramBinary)
Returns:
(wstring) serial number of the installed license.
Exceptions:
Throwsexception in case of error.
See also:
UninstallKey

See also Python code with use of KlAkOAPI Python package below:

        server = KlAkOAPI.AdmServer.KlAkAdmServer.Create("https://ksc.example.com:13299", "username", "password", verify = False)
        oLicenseKeys = KlAkOAPI.LicenseKeys.KlAkLicenseKeys(server)
        wstrActivationCode = "XXXXX-XXXXX-XXXXX-XXXXX"
        try:
            wstrSerial = oLicenseKeys.InstallKey(KlAkOAPI.Params.KlAkParams({"KLLICSRV_KEYDATA": {"KLLIC_LICFILE": wstrActivationCode.encode('ascii'), "KLLIC_IFKEYFILE": False} })).RetVal()        
        except KlAkOAPI.Error.KlAkError as err:
            if err.code == 2351 and (err.subcode == 3 or err.subcode == 34):  # code KLOLA::KLOLA_ERR_SERVER (2351), subcode KLOLAEL_ERR_SERVER_1_REQUIRED (3) or KLOLAEL_ERR_LICENSE_NOT_FOUND (34)
                arrKeys = oLicenseKeys.DownloadKeyFiles(wstrActivationCode).RetVal()
                for arrKey in arrKeys:
                    oLicenseKeys.InstallKey(KlAkOAPI.Params.KlAkParams({"KLLICSRV_KEYDATA": {"KLLIC_LICFILE": arrKey, "KLLIC_IFKEYFILE": False} }))
            else:
                raise
        
See also:
Sample. Enumerating license keys.