Box Developer Documentation

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

Register now!

List storage policy assignments

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

Fetches all the storage policy assignment for an enterprise or user.

Request

bearer [ACCESS_TOKEN]
application/json

Query Parameters

stringin queryoptional
JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii

Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination.

This requires usemarker to be set to true.

stringin queryrequired
984322

The ID of the user or enterprise to return assignments for

stringin queryrequired
user

The target type to return assignments for

Value is one of user,enterprise

Response

Returns a collection of storage policies for the enterprise or user.

application/jsonClient error

An unexpected client error.

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

Request Example

cURL
curl -i -X GET "https://api.box.com/2.0/storage_policy_assignments?resolved_for_type=userresolved_for_id=984322" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
TypeScript Gen
await client.storagePolicyAssignments.getStoragePolicyAssignments({
  resolvedForType:
    'user' as GetStoragePolicyAssignmentsQueryParamsResolvedForTypeField,
  resolvedForId: userId,
} satisfies GetStoragePolicyAssignmentsQueryParams);
Python Gen
client.storage_policy_assignments.get_storage_policy_assignments(
    GetStoragePolicyAssignmentsResolvedForType.USER.value, user_id
)
.NET Gen
await client.StoragePolicyAssignments.GetStoragePolicyAssignmentsAsync(queryParams: new GetStoragePolicyAssignmentsQueryParams(resolvedForType: GetStoragePolicyAssignmentsQueryParamsResolvedForTypeField.User, resolvedForId: userId));
Swift Gen (Beta)
try await client.storagePolicyAssignments.getStoragePolicyAssignments(queryParams: GetStoragePolicyAssignmentsQueryParams(resolvedForType: GetStoragePolicyAssignmentsQueryParamsResolvedForTypeField.user, resolvedForId: userId))
Java
BoxStoragePolicyAssignment.Info assignmentInfo = BoxStoragePolicyAssignment.getAssignmentForTarget(api, "user", "1234")
Python
assignment = client.user(user_id='12345').get_storage_policy_assignment()
print(f'Assignment ID is {assignment.id} and the storage policy ID is {assignment.storage_policy.id}')
.NET
BoxStoragePolicyAssignment assignment = client.StoragePoliciesManager
    .GetAssignmentForTargetAsync("22222");
Node
client.storagePolicies.getAssignmentForTarget('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.listAssignments(resolvedForType: "user", resolvedForId: "1234") { (result: Result<StoragePolicyAssignment, BoxSDKError>) in
    guard case let .success(assignment) = result else {
        print("Error getting storage policy assignment")
        return
    }
    print("Storage policy assignment for user \(assignment.assignedTo?.id) is \(assignment.id)")
}

Response Example

{
  "entries": [
    {
      "id": "ZW50ZXJwcmlzZV8xMjM0NTY3ODkw",
      "type": "storage_policy_assignment",
      "storage_policy": {
        "id": "11446498",
        "type": "storage_policy"
      },
      "assigned_to": {
        "id": "11446498",
        "type": "file"
      }
    }
  ],
  "limit": 1000,
  "next_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVii",
  "prev_marker": "JV9IRGZmieiBasejOG9yDCRNgd2ymoZIbjsxbJMjIs3kioVih"
}