# Creating Allocations from Scheduled Hours for Resources

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/Response-Format) section for more information.

Endpoint: POST /workspace_resources/allocations_matching_scheduled_hours
Version: 1.0.0

## Request fields (application/json):

  - `data` (array)
    An array of objects representing allocations to create for the specified resources.

  - `data.resource_ids` (array, required)
    An array of IDs of the resources to create allocations for. NOTE: This is only applicable when updating multiple resources via
                        `workspace_resources/allocations_matching_scheduled_hours`.

  - `data.hard` (boolean, required)
    Whether the allocation is a Hard Allocation (“true”) or Soft (“false”). This value must be set to `false` if you are including any unnamed resources in your request.

  - `data.occurrence` (object, required)
    The timeframe of scheduled hours in which to create allocations for.

  - `data.occurrence.type` (string, required)
    The timeframe in which to allocate the scheduled hours. Accepted values are `anytime`, `after`, `before`, and `between`.
    Enum: "anytime", "after", "before", "between"

  - `data.occurrence.after_date` (string)
    Sets the date on and after which the scheduled hours will be distributed as allocations. This value must be provided when the `type` is `after`. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `data.occurrence.before_date` (string)
    Sets the date on and before which the scheduled hours will be distributed as allocations. This value must be provided when the `type` is `before`. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `data.occurrence.start_date` (string)
    Sets the start of the date range which the scheduled hours will be distributed as allocations. This value must be provided when the `type` is `between`. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

  - `data.occurrence.end_date` (string)
    Sets the end of the date range which the scheduled hours will be distributed as allocations. This value must be provided when the `type` is `between`. The datetime must be in [ISO 8601](https://www.w3.org/TR/NOTE-datetime) format.

## Response 200 fields (application/json):

  - `success` (boolean)
    Indicates if workspace allocations were created.

## Response 400 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 401 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 403 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 404 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 422 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

## Response 503 fields (application/json):

  - `errors` (array)

  - `errors.type` (string)

  - `errors.message` (string)

