sasjs add¶
The sasjs add command provides a series of prompts used to define a SAS target along with the relevant connection details (if SAS Viya).
Syntax¶
| Option | Alias | Used by | Description |
|---|---|---|---|
--target |
-t |
sasjs add cred |
The existing target to add credentials for. |
--insecure |
-i |
both | Accept a TLS certificate that cannot be verified - see Insecure connections. |

Insecure connections¶
The CLI validates the TLS certificate of the server it connects to. On an estate with a self-signed certificate, or a chain that is missing its intermediate certificate, the connection fails with:
Adding --insecure (alias -i) makes the requests of this command accept the certificate anyway:
The flag applies to the requests the command makes - the token request, and the server-mode check on a SASjs Server target - and it is not written to sasjsconfig.json. Later commands still validate the certificate: to make the setting permanent, put it in the target's httpsAgentOptions, and preferably fix the certificate chain as described in TLS Config.
Note
--insecure is applied from CLI 6.4.6. Earlier releases accept the flag and ignore it.
Description¶
Local or Global Config¶
The first prompt requests scope. If Local is chosen, the target configuration will be added in the /sasjs/sasjsconfig.json file, and any credentials (eg tokens) will be saved in a .env.[targetName] file in the current SASjs project directory.
If Global is chosen, the target configuration will be added to a .sasjsrc file in the users home directory. The sasjs command will look for a target here if executed outside of a SASjs project.
Server Type¶
The second prompt requests a server type. Options:
- SAS Viya - works on 3.5 and 4
- SAS 9 - to execute code on SAS 9
- SASjs - for deploying to SASjs Server
Target Name¶
Choose a name for your target. Nearly every SASjs command will take this as input, so you might want to keep it short.
Target Server URL¶
This is the protocol / servername / port of your target, for instance: https://sas.sasjs.com:8080
SAS Viya Specific¶
If SAS Viya was chosen as the server type you will be prompted for a Viya Client ID and secret - this is used for connecting to the SAS Viya REST APIs. To autogenerate these you can also check out the Viya Token Generator.
Tip
No client/secret? If you just need to run code as yourself on a dev/demo estate, you can skip this entirely and use sasjs auth login instead - it authenticates with your regular SAS username and password.
Once you have entered the client and secret, you will be given a link - click this to generate the authorisation code (one time step).
The token will eventually expire - the majority of commands will show the link again at this point to refresh the token. To avoid this happening in batch, be sure your token remains valid, eg by setting a longer expiry period.
SAS 9 Specific¶
If SAS 9 was chosen as the serverType then the server name should be chosen (eg SASApp) and the metadata repository in which to deploy the SAS Web Services. Default is Foundation.