Member: Onboarding (JavaScript)

View as Markdown

This master script executes several methods required to use the API to add new members to Sigma with the necessary assets and permissions.

Each section of the script has inline comments provided.

Refer to the Sigma REST API Recipes QuickStart for step-by-step instructions.

Example script

JavaScript
1// masterOnboardingProcess.js
2// This script creates a new member by using the manually update memberId from .env and then calling each other script in order
3// You must create the new member first, manually using the script in members/create-new.js and paste the returned memberId in .env
4
5// Import necessary scripts
6const addMemberToTeam = require('./add-member-to-team');
7const grantWorkspacePermission = require('./create-workspace-permission');
8const addNewConnectionPermission = require('./create-workspace-permission'); // This line seems incorrect, it should import a different script
9const addNewWorkspace = require('./create-workspace');
10
11// Define an asynchronous function to handle the onboarding process
12async function onboardNewMember() {
13 console.log('Starting the automated part of the onboarding process.');
14
15 try {
16 // Assuming addMemberToTeam.js and other scripts use MEMBERID from .env internally
17 console.log('Adding member to team...');
18 await addMemberToTeam();
19 console.log('Member successfully added to team.');
20
21 console.log('Creating a new workspace...');
22 await addNewWorkspace();
23 console.log('New workspace created successfully.');
24
25 console.log('Granting workspace permission...');
26 await grantWorkspacePermission();
27 console.log('Workspace permissions granted successfully.');
28
29 console.log('Granting connection permission...');
30 await addNewConnectionPermission(); // This line seems incorrect, it should call a different function
31 console.log('Connection permissions granted successfully.');
32
33 // Include other steps as necessary
34
35 console.log('Onboarding process completed successfully.');
36 } catch (error) {
37 console.error('An error occurred during the onboarding process:', error);
38 }
39}
40
41// Execute the function to start the onboarding process
42onboardNewMember();

Endpoints used

  1. Get authentication token: ${baseURL}/authURL
  2. List recent documents: ${baseURL}/members/${memberId}/files/recents
  3. Get all workbooks: ${baseURL}/workbooks?page=${nextPage}
  4. List users: ${baseURL}/members?page=${page}
  5. Add a new user: ${baseURL}/members
  6. Add a user to a team: addMemberToTeam function
  7. Grant workspace permission: grantWorkspacePermission function
  8. Add new workspace: addNewWorkspace function
  9. Add new connection permission: addNewConnectionPermission function