Add the power of the Box AI API to your custom apps at Content Cloud Summit on May 15

Learn more and register!

Assign storage policy


Creates a storage policy assignment for an enterprise or user.



Request Body

objectin body

The user or enterprise to assign the storage policy to.

stringin bodyrequired

The ID of the user or enterprise

stringin bodyrequired

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

stringin bodyrequired

The ID of the storage policy to assign.

stringin bodyrequired

The type to assign.

Value is always storage_policy


Returns the new storage policy assignment created.

application/jsonClient error

An unexpected client error.

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

Request Example

curl -i -X POST "" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "storage_policy": {
         "type": "storage_policy",
         "id": "1434325"
       "assigned_to": {
         "type": "user",
         "id": "9987987"
BoxStoragePolicyAssignment assignment = client.StoragePoliciesManager
    .CreateAssignmentAsync(userId: "22222", policyId: "6");
BoxStoragePolicyAssignment.Info assignmentInfo = BoxStoragePolicyAssignment.assign(api, "1234", "5678");
user = client.user(user_id='12345')
assignment = client.storage_policy(policy_id='56781').assign(user)
print(f'Assignment ID is {} and the assignee id is {}')
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' } }
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")
    print("Created storage policy assignment ID is \( The ID of the user it is assigned to \(assignment.assignedTo?.id)")
TypeScript (Beta)
await client.storagePolicyAssignments.createStoragePolicyAssignment({
  storagePolicy: new CreateStoragePolicyAssignmentRequestBodyStoragePolicyField(
    { id: policyId }
  assignedTo: {
    id: userId,
    type: 'user' as CreateStoragePolicyAssignmentRequestBodyAssignedToTypeField,
  } satisfies CreateStoragePolicyAssignmentRequestBodyAssignedToField,
} satisfies CreateStoragePolicyAssignmentRequestBody);
Python (Beta)
client.storage_policy_assignments.create_storage_policy_assignment(CreateStoragePolicyAssignmentStoragePolicy(id=policy_id), CreateStoragePolicyAssignmentAssignedTo(id=user_id, type=CreateStoragePolicyAssignmentAssignedToTypeField.USER.value))
.NET (Beta)
await client.StoragePolicyAssignments.CreateStoragePolicyAssignmentAsync(requestBody: new CreateStoragePolicyAssignmentRequestBody(storagePolicy: new CreateStoragePolicyAssignmentRequestBodyStoragePolicyField(id: policyId), assignedTo: new CreateStoragePolicyAssignmentRequestBodyAssignedToField(id: userId, type: CreateStoragePolicyAssignmentRequestBodyAssignedToTypeField.User)));

Response Example

  "id": "ZW50ZXJwcmlzZV8xMjM0NTY3ODkw",
  "type": "storage_policy_assignment",
  "assigned_to": {
    "id": "11446498",
    "type": "file"
  "storage_policy": {
    "id": "11446498",
    "type": "storage_policy"