Box Developer Documentation

Join BoxWorks 2024 to discover what's possible with content and AI!

Register now!

Create folder lock

post
https://api.box.com/2.0
/folder_locks

Creates a folder lock on a folder, preventing it from being moved and/or deleted.

You must be authenticated as the owner or co-owner of the folder to use this endpoint.

Request

bearer [ACCESS_TOKEN]
application/json

Request Body

objectin body

The folder to apply the lock to.

stringin bodyrequired
"1234567890"

The ID of the folder.

stringin bodyrequired
"folder"

The content type the lock is being applied to. Only folder is supported.

objectin body

The operations to lock for the folder. If locked_operations is included in the request, both move and delete must also be included and both set to true.

booleanin bodyoptional
true

Whether deleting the folder should be locked.

booleanin bodyoptional
true

Whether moving the folder should be locked.

Response

application/jsonFolder Lock

Returns the instance of the folder lock that was applied to the folder, including the user that applied the lock and the operations set.

application/jsonClient error

Returns an error when the request body is not valid.

  • schema_validation_failed - The request body contains a value for a field that either does not exist, or for which the value or type does not match the expected field type. An example might be an unknown option for an enum or multiSelect field.
application/jsonClient error

Returns an error when the folder was not found.

  • not_found - The folder could not be found, the user does not have access to the folder, or the user making call is not an owner or co-owner of folder.
application/jsonClient error

An unexpected client error.

post
Create folder lock
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -i -X POST "https://api.box.com/2.0/folder_locks" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "folder": {
         "type": "folder",
         "id": "33552487093"
       },
       "locked_operations": {
         "move": true,
         "delete": true
       }
     }'
TypeScript Gen
await client.folderLocks.createFolderLock({
  folder: {
    id: folder.id,
    type: 'folder',
  } satisfies CreateFolderLockRequestBodyFolderField,
  lockedOperations: {
    move: true,
    delete: true,
  } satisfies CreateFolderLockRequestBodyLockedOperationsField,
} satisfies CreateFolderLockRequestBody);
Python Gen
client.folder_locks.create_folder_lock(
    CreateFolderLockFolder(id=folder.id, type="folder"),
    locked_operations=CreateFolderLockLockedOperations(move=True, delete=True),
)
.NET Gen
await client.FolderLocks.CreateFolderLockAsync(requestBody: new CreateFolderLockRequestBody(folder: new CreateFolderLockRequestBodyFolderField(id: folder.Id, type: "folder")) { LockedOperations = new CreateFolderLockRequestBodyLockedOperationsField(move: true, delete: true) });
Swift Gen (Beta)
try await client.folderLocks.createFolderLock(requestBody: CreateFolderLockRequestBody(folder: CreateFolderLockRequestBodyFolderField(id: folder.id, type: "folder"), lockedOperations: CreateFolderLockRequestBodyLockedOperationsField(move: true, delete: true)))
iOS
client.folders.createLock(folderId: "22222") { (result: Result<FolderLock, BoxSDKError>) in
    guard case let .success(folderLock) = result else {
        print("Error creating folder lock")
        return
    }

    print("Created folder lock with id \"\(folderLock.id)\" inside of folder with id \"\(folderLock.folder?.id)\"")
}

Response Example

{
  "id": "12345678",
  "type": "folder_lock",
  "created_at": "2020-09-14T23:12:53Z",
  "created_by": {
    "id": "11446498",
    "type": "user"
  },
  "folder": {
    "id": "12345",
    "type": "folder",
    "etag": "1",
    "name": "Contracts",
    "sequence_id": "3"
  },
  "lock_type": "freeze",
  "locked_operations": {
    "delete": true,
    "move": true
  }
}