# Workspace Resources

A workspace resource is the object that is tied to assignments and allocations within a Workspace.

Workspace Resources can be:
  - Named Resources: Resources with a user_id.
  - Unnamed Resources: Resources with no user_id.

With workspace resources it is possible for a user to have many resources with different roles
within a single workspace.
Workspace resources can be assigned to tasks via Assignments.

e.g. In an example workspace, 'the Accounting Project', we could have 3 workspace resources:
  1. Alice as an Engineer in the Accounting Project
  2. Alice as an Designer in the Accounting Project
  3. Bob as a Designer in the Accounting Project

With workspace resources, Alice could be assigned to one task as an Engineer and use the
Engineer rate for that task, and another task be assigned as a Designer and thus the designer
rate would be used there.

When a named workspace resource is created, if role_id is not specified, it will default to
the user's primary role within the project (see primary role definition below). When the
workspace resource is created, label with be generated based on the user's primary role.



## Fetching a list of Workspace Resources

 - [GET /workspace_resources](https://developer.kantata.com/kantata/specification/workspace-resources/get-workspace-resources.md): This endpoint returns structured Workspace Resource objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the workspace_resources top-level JSON key.
Please see our Response Format section for more information.

## Creating a new Workspace Resource

 - [POST /workspace_resources](https://developer.kantata.com/kantata/specification/workspace-resources/create-workspace-resource.md): Adds a named or unnamed resource to a project (workspace).

Bulk Create

This endpoint supports bulk creating up to 200 objects. In the request body, set the top-level key to its plural form and place the objects in an array. Example:


{
  "workspace_resources": [
    {
      "workspace_id": 123,
      "user_id": 111,
      "role_id": 555
    },
    {
      "workspace_id": 123,
      "user_id": 222,
      "role_id": 666
    }
  ]
}



This endpoint returns structured Workspace Resource objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the workspace_resources top-level JSON key.
Please see our Response Format section for more information.

## Creating Allocations from Scheduled Hours for Resources

 - [POST /workspace_resources/allocations_matching_scheduled_hours](https://developer.kantata.com/kantata/specification/workspace-resources/create-workspace-resource-allocations-from-scheduled-hours.md): This will create allocations for workspace resources based on their scheduled hours.
This endpoint is only usable for Account Administrators and users with Users can edit
allocations for unnamed resources or Users can edit allocations for named resources
access in the Edit Allocations section of the Resource Management Access Group Set.


This endpoint returns structured Workspace Resource objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the workspace_resources top-level JSON key.
Please see our Response Format section for more information.

## Fetching a single Workspace Resource

 - [GET /workspace_resources/{id}](https://developer.kantata.com/kantata/specification/workspace-resources/get-workspace-resource.md): This endpoint returns structured Workspace Resource objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the workspace_resources top-level JSON key.
Please see our Response Format section for more information.

## Updating an existing Workspace Resource

 - [PUT /workspace_resources/{id}](https://developer.kantata.com/kantata/specification/workspace-resources/update-workspace-resource.md): This endpoint returns structured Workspace Resource objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the workspace_resources top-level JSON key.
Please see our Response Format section for more information.

## Deleting an existing Workspace Resource

 - [DELETE /workspace_resources/{id}](https://developer.kantata.com/kantata/specification/workspace-resources/delete-workspace-resource.md): This will delete a workspace resource and their assignments if the resource is deletable.
A workspace resource is not deletable if it is the last resource for a user's primary
role within a workspace.


The response will contain no content and an HTTP 204 status code if the request was
successful, or a standard Kantata OX error message explaining why the object could not be deleted.

## Creating Allocations from Scheduled Hours for Resources

 - [POST /workspace_resources/{id}/allocations_matching_scheduled_hours](https://developer.kantata.com/kantata/specification/workspace-resources/create-workspace-resource-allocations-from-scheduled-hours-by-id.md): This will create allocations for workspace resources based on their scheduled hours.
This endpoint is only usable for Account Administrators and users with Users can edit
allocations for unnamed resources or Users can edit allocations for named resources
access in the Edit Allocations section of the Resource Management Access Group Set.


This endpoint returns structured Workspace Resource objects.
As with all Kantata OX API endpoints, the returned data will be referenced in sorted order in the results array
and will be indexed by ID in the workspace_resources top-level JSON key.
Please see our Response Format section for more information.

