One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
arjoriesotelo
6 years agoExplorer | Level 3
Business API Node
I researched for the past 2 days and I can't find any tutorial or examples on how to access, create folder, share those folders to other team using DropboxTeam in node. I subscribed for a 30 day trial Business account so I can do the project, is there any resource with examples or tutorials out there? Can you please give me a hand? The documentation is confusing without example param values and how it look when applied.
What I have so far is to show the team info.
Thank you for those who can help.
From your screenshot, I see that you are a member of a Business team named "Sapphire" using the "team space" configuration and you're looking at the file/folder listing for your team's team space.
In that team space, you have your own private member folder, as well as a number of team folders with varying levels of access control set on them.
I recommend reviewing the Namespace Guide and Content Access Guide as they have go into more detail on how to manage these.
For example, to create a new folder in the team space, you would use the 'pathRoot' option to set the path root to the team space, and then use the filesCreateFolder method to make the new folder. That would look like this:
// get a client for a specific member, defaulting to the member folder const dbxUser = new Dropbox({accessToken: ACCESSTOKEN, fetch: myFetch, selectUser: memberId}); dbxUser.usersGetCurrentAccount() .then(function(response) { // figure out the root rootNamespaceID = response.root_info.root_namespace_id; var teamSpaceRoot = JSON.stringify({".tag": "root", "root": rootNamespaceID}); // get a client for a specific member, setting the root to the team space const dbxUserWithRoot = new Dropbox({accessToken: ACCESSTOKEN, fetch: myFetch, selectUser: memberId, pathRoot: teamSpaceRoot}); // create a new folder: var folderPath = "/test_348388"; dbxUserWithRoot.filesCreateFolder({path: folderPath}) .then(function(response) { console.log(response); }) .catch(function(error) { console.log(error); }); }) .catch(function(error) { console.log(error); });
Note that all members of the team automatically have access to the new folder, since it's in the team space. You can change that though, like this:
var folderPath = "/test_348388"; var sharedFolderId = null; dbxUserWithRoot.filesGetMetadata({path: folderPath}) .then(function(response) { console.log(response); sharedFolderId = response.shared_folder_id; dbxUserWithRoot.sharingSetAccessInheritance({shared_folder_id: sharedFolderId, access_inheritance: 'no_inherit'}) .then(function(response) { console.log(response); }) .catch(function(error) { console.log(error); }); }) .catch(function(error) { console.log(error); });
And then you can add specific members with whatever access level you want, using sharingAddFolderMember.
- Greg-DB
Dropbox Staff
If you're working in Node, we recommend using the official Dropbox API v2 JavaScript SDK:
https://github.com/dropbox/dropbox-sdk-js
There's some example code here:
https://github.com/dropbox/dropbox-sdk-js/tree/master/examples/javascript
That includes some written specifically for Node here:
https://github.com/dropbox/dropbox-sdk-js/tree/master/examples/javascript/node
If you want to use the Dropbox Business API to connect to entire teams and also access the files and folders in the connected teams, you'll need to use the "team member file access" permission/feature:
https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access
For instance, that would look like:
const myFetch = require('isomorphic-fetch'); const DropboxTeam = require('dropbox').DropboxTeam; const ACCESSTOKEN = '<TEAM_MEMBER_FILES_ACCESS_ACCESS_TOKEN>' const dbx = new DropboxTeam({accessToken: ACCESSTOKEN, fetch: myFetch}); var memberId = "<MEMBER_ID>"; // e.g., from `teamMembersList`/`teamMembersListContinue` var dbxUser = dbx.actAsUser(memberId); // start listing root: dbxUser.filesListFolder({path: ""}) .then(function(response) { console.log(response); }) .catch(function(error) { console.log(error); }); // create a new shared folder: var folderPath = "/test_348388"; dbxUser.sharingShareFolder({path: folderPath}) .then(function(response) { console.log(response); }) .catch(function(error) { console.log(error); });
Hope this helps!
- arjoriesoteloExplorer | Level 3
Thank you @Greg!
What I did :Correct me if I'm wrong, I created a Team Folder using Admin Console. Now I can see my personal dropbox in Purple with additional folders that are auto generated by your system. Which means I successfully created a team folder, in my case its name is Sapphire. Using the Dropbox JS API, I am able to list groups, list members, get Info but I can't create another folder.
What I understand:
To be able to create folders and add files to folders, I need to use a member id and act as a member to be able to do these.
What I want to do:
create a folder for the team, share it to a specific member so he/she can sync it to his/her computer all the files I will put on it, but the member will be restricted to add files into it, edit, delete but can download it or sync to the computer. Using the Node Business API.
- Greg-DB
Dropbox Staff
From your screenshot, I see that you are a member of a Business team named "Sapphire" using the "team space" configuration and you're looking at the file/folder listing for your team's team space.
In that team space, you have your own private member folder, as well as a number of team folders with varying levels of access control set on them.
I recommend reviewing the Namespace Guide and Content Access Guide as they have go into more detail on how to manage these.
For example, to create a new folder in the team space, you would use the 'pathRoot' option to set the path root to the team space, and then use the filesCreateFolder method to make the new folder. That would look like this:
// get a client for a specific member, defaulting to the member folder const dbxUser = new Dropbox({accessToken: ACCESSTOKEN, fetch: myFetch, selectUser: memberId}); dbxUser.usersGetCurrentAccount() .then(function(response) { // figure out the root rootNamespaceID = response.root_info.root_namespace_id; var teamSpaceRoot = JSON.stringify({".tag": "root", "root": rootNamespaceID}); // get a client for a specific member, setting the root to the team space const dbxUserWithRoot = new Dropbox({accessToken: ACCESSTOKEN, fetch: myFetch, selectUser: memberId, pathRoot: teamSpaceRoot}); // create a new folder: var folderPath = "/test_348388"; dbxUserWithRoot.filesCreateFolder({path: folderPath}) .then(function(response) { console.log(response); }) .catch(function(error) { console.log(error); }); }) .catch(function(error) { console.log(error); });
Note that all members of the team automatically have access to the new folder, since it's in the team space. You can change that though, like this:
var folderPath = "/test_348388"; var sharedFolderId = null; dbxUserWithRoot.filesGetMetadata({path: folderPath}) .then(function(response) { console.log(response); sharedFolderId = response.shared_folder_id; dbxUserWithRoot.sharingSetAccessInheritance({shared_folder_id: sharedFolderId, access_inheritance: 'no_inherit'}) .then(function(response) { console.log(response); }) .catch(function(error) { console.log(error); }); }) .catch(function(error) { console.log(error); });
And then you can add specific members with whatever access level you want, using sharingAddFolderMember.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,948 PostsLatest Activity: 4 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!