Building Commands and Help Feature
Building Commands and Help Feature
A full list of CLI commands can be found in the GitHub repository.
If you do not see a command for an endpoint you need, you can build a custom request.
Creating a folder with help
Every CLI command begins with box
. Add the option --help
to any
command for help building it. For example, executing box --help
will bring you
to a list of all possible object commands. Options are discussed more in
step 4.
Then, for example, use the folder object and execute the command
box folders --help
. This provides a list of all eligible actions for this
object.
Discover the required arguments for creating a folder: box folders:create --help
Execute the command box folders:create 0 "My CLI Folder"
and note the folder
ID returned in the response.
Log into your Box account. Can you see this folder in your folder tree?
You cannot see this folder in your own Box account because you do not own, nor are you collaborated in on the folder. You are executing commands as the Service Account and therefore the created folder lives in the Service Account's folder tree rather than your own.
Now, execute the command:
box folders:collaborations:add folder_id_created_above --role=editor --user-id=YOUR_USER_ID
Return to your All Files page. Can you see the folder now?
The second command used the Service Account, which owns the folder, to add your user as an Editor-level collaborator on the folder. This surfaces the folder in your own folder tree.
Summary
- You used the help feature to create a folder
- You added a collaboration to the created folder and viewed it in Box