Assign legal hold policy

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

Assign a legal hold to a file, file version, folder, or user.

Request

application/json

Request Body

objectin body

The item to assign the policy to

stringnulloptional
6564564

The ID of item to assign the policy to

stringnulloptional
folder

The type of item to assign the policy to

Value is one of file,file_version,folder,user

stringin bodyrequired
123244

The ID of the policy to assign.

Response

Returns a new legal hold policy assignment.

application/jsonClient error

An unexpected client error.

post
Assign legal hold policy
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -X POST https://api.box.com/2.0/legal_hold_policy_assignments \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
     -H 'Content-Type: application/json" '
     -d '{
       "policy_id": "123244",
       "assign_to": {
         "type": "folder",
         "id": "6564564"
       }
     }'
.NET
var requestParams = new BoxLegalHoldPolicyAssignmentRequest()
{
    PolicyId = "11111",
    AssignTo = new BoxRequestEntity()
    {
        Type = "folder",
        Id = "12345"
    }
};
BoxLegalHoldPolicyAssignment assignment = await client.LegalHoldPoliciesManager
    .CreateAssignmentAsync(requestParams);
Java
BoxLegalHoldPolicy policy = new BoxLegalHoldPolicy(api, policyID);
BoxFolder folder = new BoxFolder(api, folderID);
policy.assignTo(folder);
Python
folder_to_assign = client.folder(folder_id='22222')
assignment = client.legal_hold_policy(policy_id'12345').assign(folder_to_assign)
print('Applied policy "{0}" to {1} {2}'.format(
    assignment.legal_hold_policy.policy_name,
    assignment.assigned_to.type,
    assignment.assigned_to.id,
))
Node
client.legalHoldPolicies.assign('11111', 'folder', '12345')
	.then(assignment => {
		/* assignment -> {
			type: 'legal_hold_policy_assignment',
			id: '22222',
			legal_hold_policy: 
			{ type: 'legal_hold_policy',
				id: '11111',
				policy_name: 'IRS Audit' },
			assigned_to: { type: 'folder', id: '12345' },
			assigned_by: 
			{ type: 'user',
				id: '33333',
				name: 'Example User',
				login: 'user@example.com' },
			assigned_at: '2016-05-18T17:38:03-07:00',
			deleted_at: null }
		*/
	});
iOS
client.legalHolds.forceApply(policyId: "1234", assignToId: "4568" ,assignToType: "file") { (result: Result<LegalHoldPolicyAssignment, BoxSDKError>) in
    guard case let .success(assignment) = result else {
        print("Error assigning legal hold policy")
        return
    }
    print("Assigned a legal hold policy at \"\(assignment.assignedAt)\"")
}