Skip to main content
When starting your integration you need to initialize the K42 SDK. This is done by calling the initialize api exposed by the SDK. Calling initialize allows our SDK to authenticate with the K42 platform and start background heartbeating processes which allow you to monitor the health of your POS.

initialize

Params

platform_endpoint
string
required
The address of the K42 mesh to make requests through
scanner_endpoint
string
The endpoint to use for the scanner. This is optional and defaults to http://192.168.249.100:80
auth_token
string
required
The auth token to use to speak to the K42 transactions platform.
network_id
string
The K42 network-id to connect under. This is optional as the network may be automatically determined.
pos_id
string
required
The auth token to use to speak to the K42 transactions platform.
location_id
string
required
An id for the store location.
store_name
string
An optional name for the store.
data_dir
string
An optional path to store internal long-lived state. Defaults to %USER%/APPDATA/k42sdk on Windows and $HOME/.local/share/k42sdk/ on MacOS and Linux

Response

success
boolean
required
Whether or not the intialize call was successful
message
string
A failure message present if the initialization call failed.
import * as sdk from "k42-sdk"

const initResult = sdk.initialize({
  platform_endpoint: "https://mesh.transit.dev",
  auth_token: "atu_abc123",

  pos_id: "pos-1",
  location_id: "loc-1"
});
if (!initResult.success) {
  console.log(`Failed to intiialize - ${initResult.message}`);
  return;
}

console.log("Intiialized successfully");