Use the InStore device CLI to bulk-load locations and devices into a new environment.
InStore device CLI overview
- Create multiple locations and devices from a JSON or YAML configuration file.
- Avoid conflicting device dependencies and ordering.
- Securely access APIs.
- Receive console feedback and error logs.
- Verify that locations are added and devices are registered.
- Integrate with deployment scripts to automate store setup.
Prerequisites
Before you begin, ensure your environment includes the following:
- Node.js 22 or higher
- npm 10 or higher
Set up your local repository
To set up your local repository for the InStore device CLI, follow these steps:
-
Clone the repository:
git clone https://github.com/NebulaTerra/instore-device-cli.git cd instore-device-cli
-
Install dependencies:
npm install
-
Make the script executable:
chmod +x index.js
-
Create a
.env
file with the following variables:Variable Description API_BASE_URL
Base URL of your REST API. Default: http://localhost:5000
.USER_ID
User ID for authentication. TENANT_ID
Tenant ID for authentication. CONNECTION_KEY
Environment connection key for authentication. SCOPES
(Optional) Comma-separated list of scopes for your API Client for InStore. TOKEN_EXPIRATION
(Optional) Token expiration in seconds. Default: 3600
.You can use the sample file as a starting point:cp .env.example .env nano .env
-
Test your authentication credentials:
node index.js auth # Or ./index.js auth
Create the configuration file
sample-location.json
. You can use JSON or YAML format. Not all fields in the sample are required. For details on which values are validated, see the constants.mjs
(pre-checks) and locations.mjs
(post-checks) files in the GitHub src
folder.name
in the file. If a device you plan to use is not supported, contact the InStore support team. To check supported devices, follow these steps:- Log in to the InStore colleague app.
- Go to Manage Devices.
- Select a device type or add a new device.
- In the Supported Devices field, view the available options.
- Enter the device name in the
name
field of your configuration file. Use the exact spelling from the Supported Devices field.
Configuration components
Most retail locations include the following device types:
- Safe
- Receipt or label printers
- Cash drawers
- Barcode scanners
- Payment terminals or PEDs
- Workstations
The CLI creates devices in the following order to manage dependencies:
- Standard devices, such as safes, PEDs, printers, scanners.
- Cash drawers are created next, but only after any devices they rely on have already been created. For example, if a printer is required for a cash drawer, the printer must be created before the cash drawer itself.
- Workstations are created last, as they reference other device types.
Alias references
Use alias fields to reference devices in your configuration. For example, when registering a workstation, specify at least a default printer and cash drawer:
{
"name": "iPad Pro",
"type": "Workstation",
"default_PED": "PED-Flagship-01",
"default_cashdrawer": "CASH-Flagship-01",
"default_printer": "PRINT-Flagship-01",
"default_scanner": "SCAN-Flagship-01"
}
PED-Flagship-01
is a locally unique alias that temporarily stands in for the device ID until the device is created. You can look up the device ID later in the InStore Center.Run and validate the configuration file
sample-location.json
is the name of your configuration file:node index.js batch sample-location.json
After the batch completes, confirm success by checking for the created objects:
-
List all locations:
node index.js list-locations
-
Validate a specific location exists:
node index.js validate-location LOCATION_ID
-
Validate a specific workstation exists:
node index.js validate-location LOCATION_ID WORKSTATION_ID
-
List all devices for a location:
node index.js list-devices LOCATION_ID
JsonData
.InStore device CLI logging
The InStore device CLI writes errors to the console and generates detailed logs for each batch operation. Logs are saved as timestamped JSON files in the current directory. Review these files for error details about failed operations.
For example, errors are logged for incorrect safe or cash drawer configurations and for missing or incorrect references. Warnings are logged for missing but non-required data.
Troubleshooting
If you encounter authentication errors, do the following:
- Check that your
.env
credentials are correct. - Ensure your user account has the required permissions and scopes.
- Verify the API endpoint is correct and accessible.
If you encounter issues during device creation, do the following:
- Confirm all required fields are present.
- Ensure referenced devices have been created.
- Check that enum values match for device types, statuses, and other fields.
- Review the log file for details about failed attempts.