ServiceNow SDK CLI
-
- UpdatedJan 30, 2025
- 7 minutes to read
- Xanadu
- ServiceNow SDK
Use the ServiceNow SDK command-line interface (CLI) to manage changes between a local application and the application on an instance.
From the command-line tool on your system, enter now-sdk
to start the CLI and return a list of available commands or now-sdk [command]
to begin using the ServiceNow SDK.
The CLI includes the following commands and global options:
Option | Description |
---|---|
--version | Return the version of the CLI. |
--help, -h | Return information about commands, subcommands, and parameters. |
--debug, -d | Return the debug logs generated with a command. |
upgrade
Upgrade to the latest version of the ServiceNow SDK for use with instances beginning with the Washington DC release.
Upgrading the ServiceNow SDK doesn't update any applications you have previously created or converted with the ServiceNow SDK.
upgrade
command has the following structure:For more information, see Upgrade the ServiceNow SDK.
auth
Authenticate to an instance and store, update, or view user credentials for accessing an instance on your system.
The auth
command has parameters for adding credentials, deleting credentials, listing credentials, and setting credentials to use by default.
For more information, see Authenticating to a ServiceNow instance with the ServiceNow SDK.
add
Store credentials in the device keychain or credential manager on your system.
auth
command has the following structure with the --add
parameter:npx
command installs the ServiceNow SDK in your application directory instead of globally.Parameter | Type | Description | Default value |
---|---|---|---|
--add | String | The URL of the target instance to access and to which you install applications. The instance must be on the Washington DC release or later. | — |
Parameter | Type | Description | Default value |
---|---|---|---|
--type | String | The method to use to authenticate with the target instance. Specify basic for basic authentication or oauth for OAuth 2.0 authentication. |
basic |
--alias | String | The alias for the instance and user credentials. The alias can be used for authentication with the |
— |
delete
Remove credentials in the device keychain or credential manager on your system.
auth
command has the following structure with the --delete
parameter:Parameter | Type | Description | Default value |
---|---|---|---|
--delete | String |
The alias for the instance and user credentials. To delete all credentials, set this parameter to |
— |
list
View credentials saved in the device keychain or credential manager on your system. Passwords and authentication codes aren't returned.
auth
command has the following structure with the --list
parameter:Parameter | Type | Description | Default value |
---|---|---|---|
--list | String | Lists all available authentication credentials. | — |
use
Set the credentials to be used by commands by default.
auth
command has the following structure with the --use
parameter:Parameter | Type | Description | Default value |
---|---|---|---|
--use | String | The alias for the instance and user credentials. | — |
init
Create a custom scoped application or convert an existing scoped application to support development in source code. The application is added in the current directory.
To create an application with your default credentials, you can run the init
command without any optional parameters. For example, now-sdk init
. To convert an existing application, you must include
the --from
parameter to provide the sys_id of an application on an instance or a path to a local directory that contains an application.
After initializing an application, you must install the required third-party dependencies using your preferred package manager before building the application. For example, if you use Node Package Manager (npm), run npm
install
.
init
command has the following structure:npx
command installs the ServiceNow SDK in your application directory instead of globally.For more information, see Create an application with the ServiceNow SDK or Convert an application with the ServiceNow SDK.
build
Compile source files and generate an installable package. Third-party library dependencies are converted into XML files that can be installed with the application.
build
command has the following structure:Parameter | Type | Description | Default value |
---|---|---|---|
source | String | The path to the package.json file for your application. The package.json should be in the base directory of your application. |
Current working directory |
--frozenKeys | Boolean | Validates that the keys.ts file is up to date for continuous integration (CI) builds. If true and changes were made to the application's ServiceNow Fluent code, the keys.ts file isn't updated and the build fails. The keys.ts file is automatically generated in the src/fluent/generated directory. |
false |
For more information, see Build and install an application with the ServiceNow SDK.
install
Install or update an application on an instance. Before using the install
command, you must use the build
command to generate an installable package.
The install
command has the following structure:
For more information, see Build and install an application with the ServiceNow SDK.
transform
Download application metadata (XML) from the instance and transform the metadata into ServiceNow Fluent source code to synchronize the application changes on the instance into your local application.
After initializing an application, you can run the transform
command without any parameters to
transform
new application metadata from the
instance into source code in the
src/fluent/generated directory and
synchronize changes to metadata into source code in the src/fluent directory. To transform metadata that existed when the application was initialized into source code, use the
--from
parameter to provide the path to a local directory or file that contains XML. If metadata exists in the local
application as both XML and source code, the XML version takes precedence when installed on the instance.
transform
command has the following
structure:For more information, see Convert an application with the ServiceNow SDK or Build and install an application with the ServiceNow SDK.
dependencies
Download the application dependencies configured in the now.config.json file and script dependencies, such as TypeScript type definitions for Glide APIs and script includes, from the instance.
To generate and download any tables on which your application depends, you must configure dependencies in the now.config.json. After downloading script dependencies, you must update your tsconfig.json file to include the type definitions.
The dependencies
command has the following structure:
Parameter | Type | Description | Default value |
---|---|---|---|
--directory | String | The path to the package.json file for your application. The package.json should be in the base directory of your application. |
Current working directory |
--auth, -a | String | An alias for the credentials to use to authenticate to the instance. | If set, the default alias. |
For more information, see Downloading application and script dependencies with the ServiceNow SDK.