I am trying to setup a pre-configured folder for users in the Enterprise where the share options are limited to collaborators only.
This feature is available in the web interface in the folder properties form under the security tab: "Restrict shared links to collaborators only"
The box content API (v2) allows for the creation and modification of shared links, this works as expected; but it is not clear whether/how we can restrict the shared link options.
The API docs for folder update: developers.box.com/docs/#folders-update-information-about-a-folder appears to indicate that there is an access attribute on the folder in addition to the shared_link attribute:
access: Can be open or collaborators. Type: object
I am not sure what the object value would be if not the "collaborators" String.
I have tried:
curl https://api.box.com/2.0/folders/FOLDER_ID \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "As-User: USER_ID" \
-d '{"access": "collaborators"}' -X PUT
and
curl https://api.box.com/2.0/folders/FOLDER_ID \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "As-User: USER_ID" \
-d '{"access": {"access": "collaborators"}}' -X PUT
both return a status 200, though they do not appear to do anything.
The access
field is actually a sub-field of the shared_link
field, which is why it's slightly indented in the documentation (this is kind of hard to see). If you want to create a shared link to a folder and restrict the access to collaborators, you can do so with a request like:
curl https://api.box.com/2.0/folders/FOLDER_ID \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "As-User: USER_ID" \
-d '{"shared_link": {"access": "collaborators"}}' -X PUT