Skip to main content

OKM Config API

At a regular interval (see pollingInterval below), OKMs send a request to the /config endpoint of the OKM Service.

This page describes the behaviour of the /config endpoint for OKM Service v1.2.20 and above. To support a lot more OKMs, the handling of config requests was reworked: which parameters are taken into account, and the order in which they are taken into account, both changed. The request format itself stays the same, as it is controlled by the OKM firmware.

For the earlier behaviour, see OKM Config API (before v1.2.20).

Verb and URL​

The URL for the config endpoint that the OKM calls is configurable, though it is hard-coded in the OKM as embeddedv1/config/kas. Because of this, it is the first URL the OKM will call. At this endpoint, the OKM Service will check what is the configured endpoint for config and return that to the OKM. From then on, the OKM will call this configured endpoint.

By default, the configured endpoint is /api/v1/config .

GET /embeddedv1/config/kas/{serialNumber}?kasFirmware={okmFirmwareVersion}&kasDateTime={okmDateTime}&retailCfg={retailConfigType}&pollingInterval={pollingInterval}&configUrl={configURL}&auditUrl={auditURL}&assetList={assetListDigest}&usersAssets={userAssetsDigest}&batchKeyFirmware={batchKeyFirmwareVersion}&wirelessKeyFirmware={loRaKeyFirmwareVersion}&keyCheckoutWindowTime={keyCheckoutWindowTime}&keyCheckoutWindowContact={keyCheckoutWindowContact}&installCode={installerCode}&cacheMode={cacheMode}

Note: For the detailed understanding of a digest, please visit the page: Asset List and Digests

Parameters and Query Parameters​

Param / Query ParamTypeData TypeDescriptionAction
serialNumberInVue Serial NumberstringSerial number of the OKM making the call. This is used to retrieve the OKM’s info and digest(s) from the database. If it is not found, a 404 is returned. If it is found but it has no store, no other parameters are parsed.None
kasFirmwareVersion NumberstringVersion of the f/w of the calling OKM. If there is a more recent version available, the service returns a URL to fetch the most recent firmware.Check if the latest firmware is more recent that this value, if it is, a URL is returned to the OKM where it can fetch the latest f/w version.
kasDateTimeTimestampnumber (epoch seconds)OKM time as a timestamp in seconds, to synchronize date and time with the service.If the current time minus the time received from the OKM is greater than the date_time_threshold configured for this OKM, or greater than 1 minute, the service replies with the current time.
retailCfgNumbernumberRetail Config Type supported by the OKM. 2 = retailCfg_IR3ZonePlusAudit_eN/A
pollingIntervalNumbernumber (seconds)Number of seconds between each request of the OKM to /config .A number of seconds between 5 and 3600.
configURLURLstring (URL)The URL that the OKM calls for this endpoint.Currently always returns api/v1/config if the configURL value is different.
auditURLURLstring (URL)The URL that the OKM calls to send audit messages.Currently always returns api/v1/audit if the auditURL value is different.
assetListSHA256 Hashstring (SHA-256 hash)Hash of the asset list of this OKM. If it doesn’t match what the service has, the service replies with its asset list.Compare the value received with the value in the database, and if different, return the value in the database.
usersAssetsSHA256 Hashstring (SHA-256 hash)Hash of the user asset list of this OKM. If it doesn’t match what the service has, the service replies with its user asset list.Compare the value received with the value in the database, and if different, return the value in the database.
batchKeyFirmwareVersion NumberstringVersion number of the batch key f/w this OKM contains. If the latest version of the f/w known is more recent than this value, returns a URL to fetch the most recent firmware.Check if the latest firmware is more recent that this value, if it is, a URL is returned to the OKM where it can fetch the latest f/w version.
wirelessKeyFirmwareVersion NumberstringVersion number of the LoRA key f/w this OKM contains.Ignored.
keyCheckoutWindowTimeNumbernumber (seconds)Number of seconds someone has to check out a key. This is not authorization time.Ignored.
keyCheckoutWindowContactStringstring (enum)Type of contact: ”open” = normally open ”closed” = normally closedIgnored.
installerCodeNumbernumberInstaller code of the OKM. Number between 5 and 20 digits.Not used by the service.
cacheModeNumbernumber (enum)Tell the service the currently configured cacheMode of this OKM. 0 : unknown 1 : disabled 2 : enabledIgnored.

Settings​

To reduce the number of database connections the config request handler needs to make, two settings control how often an OKM is allowed to call.

SettingDescription
POLLING_INTERVALNumber of seconds allowed between each call to the /config endpoint. Defaults to 180.
CALLED_TOO_SOON_RATIOThe ratio used to check if the OKM has called too soon, meaning the time elapsed since the last call is greater than this percentage of the OKM’s polling interval. Defaults to 0.8.

Details of the /config Endpoint Parsing​

When a config request from an OKM is received, the request is handled as follows. Each reply has an HTTP code 200, unless noted otherwise.

  1. Check if the serial number starts with 0203. If not, the service replies with a 204.

  2. Check if the pollingInterval received from the OKM is the default of 5 seconds, or if it is equal to the configured interval (POLLING_INTERVAL). If so, reply to the OKM with the POLLING_INTERVAL value plus a random number of seconds between 1 and 30% of that value.

    For example, if POLLING_INTERVAL is 60 seconds, then a random number between 1 and 18 (30% of 60) seconds is added to the polling interval, meaning the range will be between [61, 79] seconds.

  3. If both of these checks pass, fetch the OKM and the digest(s) for its store from the database.

  4. If the OKM is not found, add it to the database and reply with a 404.

  5. If the call is coming from an OKM assigned to a store, check if the OKM has called too soon, meaning the time elapsed since the last call is greater than 80% of the OKM’s polling interval. This ratio can be configured by changing the calledTooSoonRatio value in the tenant configs. If the OKM has called too soon, then the service replies with a 204.

  6. Update last IP, last sync time, and firmware version of the OKM.

  7. If the OKM has no ACL, return a 204. At this time, the service is waiting for someone to assign things to the OKM.

  8. Check if there’s a buffered command. If so, return the command to the OKM.

  9. Check if the OKM firmware is up to date. If kasFirmware is older, then the service replies with the URL where it can download the latest firmware file.

  10. Check that retailCfg is equal to retailCfg_IR3ZonePlusAudit_e. If not, reply with a msgTkn_RetailCfg_e with that value.

  11. Check if the OKM clock has a 5 minute difference with the server. If so, reply with a msgTkn_DateTime_e with the current server time.

  12. Check if the OKM assets and users are synchronized, by comparing assetList and usersAssets with the assetList value the service calculates and the usersAssets value the service has in its database for the OKM.

    If the usersAssets value is different, then the service replies to the OKM with a 200 and the combination of the following messages: msgTkn_deleteAssetsAndUsers_e, msgTkn_putAssetList_e, n * msgTkn_putUser_e . That is: a delete assets and users message, a message with the list of assets that should be in the OKM, and a put user message for each user that should be in the OKM.

  13. If there is no configUrl, or if it’s not /api/v1/config, return a msgTkn_configURL_e with /api/v1/config and a 200.

    While this step doesn’t seem to do anything useful because the return value is pre-defined for now, it allows us to return a different config URL if needed.

  14. If there is no auditUrl, or if it’s not /api/v1/audit, return a msgTkn_AuditURL_e with /api/v1/audit.

  15. Check if the key firmware is up to date by comparing the batchKeyFirmware value. If batchKeyFirmware is older, then the service replies with the URL where it can download the latest firmware file.

Each reply has an HTTP code 200, unless noted otherwise.

Note: If an OKM gets a 200 reply, it will call back the service immediately after its done.

Note: If an OKM gets a 204 reply, it will wait its configured polling interval before calling the service back.

Note: If the OKM encounters an error downloading the key firmware file, the OKM will call back with a request that does not include the bathcKeyFirmware parameter for the next 15 minutes.