This is a client SDK to simplify connecting to the Smartsheet API from Node.js applications.
The SDK supports Node.js versions 6.x or later.
To install this SDK, simply run the following command in a terminal window:
npm install smartsheet
The Smartsheet API documentation with corresponding SDK example code can be found here.
To call the API, you must have an access token, which looks something like this example: ll352u9jujauoqz4gstvsae05. You can find the access token in the Smartsheet UI at Account > Personal Settings > API Access.
The following is a brief sample using promises that shows you how to:
- Initialize the client
- List all sheets
- Load one sheet
// Initialize the clientvar client = ;var smartsheet = client;// The `smartsheet` variable now contains access to all of the APIs// Set queryParameters for `include` and paginationvar options =queryParameters:include: "attachments"includeAll: true;// List all sheetssmartsheetsheets;
Although the example above is using promises and the API documentation samples use promises, you could also access the APIs in this SDK by using callbacks.
// List all sheets using callbackssmartsheetsheets;
See the node-read-write-sheet project for a code example that shows how to call methods to read and write to a sheet using this SDK.
Each endpoint takes two arguments: a set of options, and an optional callback function. If the callback is not specified, the SDK will return a promise instead.
The options argument is an object that contains any number of parameters specific to the endpoint, and may optionally require a
body field that will be placed in the body of the request when applicable.
Each endpoint also permits an optional parameter in the options object:
queryParameters- This option is common for specifying enhancements or additional features for an API call. It specifies the query string for the call's URL.
This must be an object mapping URL query string fields to their values. For example, to make a call with the query string
?include=comments&includeAll=true, an API call would look like the following:...
When creating the client object, pass an object with any of the following properties to tune its behavior.
maxRetryDurationSeconds- The maximum time in seconds to retry intermittent errors. (Defaults to 15 seconds.)
logLevel- Set to
'info'to log each call and return value to the console.
Advanced Configuration Options
This library leverages winston for logging.
Supported log levels are:
|Level||What is logged|
||Failures and retries|
||Each call URL and response code|
||Payloads, truncated to 1024 characters|
||Full payloads and HTTP headers|
You may create your own winston container or configure the default
winston.loggers container, adding a logger named 'smartsheet'. Specify this container using the configuration option
loggerContainer. (winston documentation on configuring loggers.)
If you want to use your own logger, pass a logger object as the configuration option
logger that implements the following methods:
error- Standard logging methods
log- Similar to the above, but accepting the logging level string as its initial parameter; the log level is guaranteed be one of the above options.
For additional customization, you can specify a
calcRetryBackoff function. This function is called with two arguments:
- The first accepts the index of the retry being attempted (0 for the first retry, 1 for the second, etc.)
- The second accepts the Error Object that caused the retry.
The function must return the number of milliseconds to wait before making the subsequent retry call, or a negative number if no more retries should be made.
The default implementation performs exponential backoff with jitter.
Base URL Configuration
The SDK can be directed to point at a different base URL, which can be helpful for testing against mock APIs or connecting to specialized Smartsheet environments.
When creating the Smartsheet client, set the base URL by passing it into the constructor arguments:
var smartsheet =;
Working With Smartsheetgov.com Accounts
If you need to access Smartsheetgov you will need to specify the Smartsheetgov API URI as the
baseUrl during creation of the Smartsheet client object. SmartsheetGov uses a base URI of
https://api.smartsheetgov.com/2.0/. The Smartsheetgov URI is defined as a constant (
Invoke the SmartsheetBuilder with the base URI pointing to Smartsheetgov:
var smartsheet =;
The source code comes with several scripts for running tests:
||Runs all tests. Note, the mock API tests will fail unless the mock server is running|
||Runs only functional tests|
||Runs only mock API tests. Clone the Smartsheet SDK tests repo and follow the instructions from the README to start the mock server|
||Runs functional tests and reports on code coverage|
||Runs JSHint against the codebase|
||Watches the codebase and runs JSHint whenever changes are made|
Note that a successful test run will currently output some unhandled rejection messages in the body of the logs. This is expected, and does not indicate test failure.
To invoke the passthrough, your code can call one of the following methods:
response = smartsheet.request.get(getOptions, callback)
response = smartsheet.request.post(postOptions, callback)
response = smartsheet.request.postFile(postOptions, callback)
response = smartsheet.request.put(putOptions, callback)
response = smartsheet.request.deleteRequest(deleteOptions, callback)
...Options parameter takes the normal set of parameters taken by other similar SDK calls, but also requires a
url parameter that tells it the relative path of the endpoint to call.
The following example shows how to POST data to
https://api.smartsheet.com/2.0/sheets using the passthrough method:
var payload =name: 'my new sheet'columns:title: 'Favorite'type: 'CHECKBOX'symbol: 'STAR'title: 'Primary Column'primary: truetype: 'TEXT_NUMBER';var responsePromise = smartsheetrequest;
For details about more advanced features, see Advanced Topics.
If you would like to contribute a change to the SDK, please fork a branch and then submit a pull request. More info here.
Starting from the v2.77.0 release, Smartsheet SDKs will use a new versioning strategy. Since all users are on the Smartsheet API 2.0, the SDK version numbers will start with 2. The 2nd number will be an internal reference number. The 3rd number is for incremental changes.
For example, v2.77.0 means that you are using our 2.0 version of the API, the API is synched internally to a tag of 77, and then if there are numbers after the last decimal, that will indicate a minor change.
Each specific release is available documented here: GitHub