Assign storage policy

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

Creates a storage policy assignment for an enterprise or user.

Request

Bearer [ACCESS_TOKEN]
application/json

Request Body

objectin body

The user or enterprise to assign the storage policy to.

stringnulloptional
9987987

The ID of the user or enterprise

stringnulloptional
user

The type to assign the policy to.

Value is one of user,enterprise

objectin body

The storage policy to assign to the user or enterprise

stringnulloptional
1434325

The ID of the storage policy to assign.

stringnulloptional
storage_policy

Value is always storage_policy

Response

Returns the new storage policy assignment created.

application/jsonClient error

An unexpected client error.

post
Assign storage 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/storage_policy_assignments \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
     -H 'Content-Type: application/json" '
     -d '{
       "storage_policy": {
         "type": "storage_policy",
         "id": "1434325"
       },
       "assigned_to": {
         "type": "user",
         "id": "9987987"
       }
     }'
.NET
BoxStoragePolicyAssignment assignment = client.StoragePoliciesManager
    .CreateAssignmentAsync(userId: "22222", policyId: "6");
Java
BoxStoragePolicyAssignment.Info assignmentInfo = BoxStoragePolicyAssignment.assign(api, "1234", "5678");
Python
user = client.user(user_id='12345')
assignment = client.storage_policy(policy_id='56781').assign(user)
print('Assignment ID is {0} and the assignee id is {1}'.format(assignment.id,assignment.assigned_to.id))
Node
client.storagePolicies.createAssignment('7', '22222')
    .then(assignment => {
        /* assignment -> {
            type: 'storage_policy_assignment',
            id: 'dXNlcl8yMjIyMg==',
            storage_policy: 'storage_policy', id: '7' },
            assigned_to: { type: 'user', id: '22222' } }
        */
    });
iOS
client.storagePolicy.assign(storagePolicyId: "1234", assignedToType: "user", assignedToId: "123") { (result: Result<StoragePolicyAssignment, BoxSDKError>) in
    guard case let .success(assignment) = result else {
        print("Error assigning a storage policy")
        return
    }
    print("Created storage policy assignment ID is \(assignment.id). The ID of the user it is assigned to \(assignment.assignedTo?.id)")
}

Response Example

{
  "assigned_to": {
    "id": 11446498,
    "type": "file"
  },
  "storage_policy": {
    "id": 11446498,
    "type": "storage_policy"
  }
}