Smartsheet JavaScript SDK

4.7.2 · active · verified Sun Apr 19

The Smartsheet JavaScript SDK, currently at version 4.7.2, provides an official client library for interacting with the Smartsheet API from Node.js applications. It ships with comprehensive TypeScript types, facilitating development in type-safe environments. The SDK maintains an active and consistent release cadence, frequently introducing minor versions with new features, API endpoint support, and critical bug fixes, as evidenced by recent updates adding new sharing, workspace, and folder endpoints, alongside improvements to retry mechanisms and pagination. It differentiates itself as the directly supported client, offering extensive coverage of the Smartsheet API's functionalities. Developers can initialize the client using an access token obtained from the Smartsheet UI and leverage promise-based methods for operations such as listing and loading sheets, managing users, and handling attachments. The SDK requires actively supported Node.js versions 14.x or later for optimal compatibility and robust operation.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Smartsheet client, list all available sheets, and then load the details of the first sheet found using asynchronous `await` syntax.

import { createClient } from 'smartsheet';

const accessToken = process.env.SMARTSHEET_ACCESS_TOKEN ?? ''; // Load from environment variable for security

if (!accessToken) {
  console.error('Error: SMARTSHEET_ACCESS_TOKEN environment variable is not set.');
  process.exit(1);
}

// Initialize the client
const smartsheet = createClient({
  accessToken: accessToken,
  logLevel: 'info' // Can be 'info', 'warn', 'error', 'debug'
});

// Set queryParameters for `include` and pagination
const options = {
  queryParameters: {
    include: 'attachments',
    includeAll: true
  }
};

async function listAndLoadSheets() {
  try {
    // List all sheets
    const result = await smartsheet.sheets.listSheets(options);
    if (result.data && result.data.length > 0) {
      const sheetId = result.data[0].id; // Choose the first sheet

      // Load one sheet
      const sheetInfo = await smartsheet.sheets.getSheet({ sheetId: sheetId });
      console.log('Successfully loaded sheet:', sheetInfo.name, 'with ID:', sheetInfo.id);
      // console.log(JSON.stringify(sheetInfo, null, 2)); // Uncomment to see full sheet data
    } else {
      console.log('No sheets found in your Smartsheet account.');
    }
  } catch (error) {
    console.error('An error occurred:', error);
  }
}

listAndLoadSheets();

view raw JSON →