> ## Documentation Index
> Fetch the complete documentation index at: https://developers.projectcor.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Save Allocation

> Creates a new resource allocation for a user on a project.

**Request Body Requirements:**
All values in the object are required.

**Known Errors:**
- `InvalidAllocationError` — The allocation is invalid:
  - Empty `allocatedHours` field
  - The `from` date is greater than or equal to the `to` date
  - The date range exceeds 12 months
- `AllocationAlreadyExistInDatesRangeError` — An allocation already exists within the specified date range
- `UserNotFoundError` — The specified user cannot be found
- `UserNotHaveWorkDaysError` — The user does not have any work days configured
- `ProjectNotFoundError` — The specified project cannot be found



## OpenAPI

````yaml /api-reference/resource-allocation-openapi.json post /allocation/saveAllocation
openapi: 3.1.0
info:
  title: COR Resource Allocation API
  description: >-
    The Resource Allocation API is a dedicated service for managing the capacity
    of users on the COR platform. This API uses the same authentication as the
    main COR API.
  version: 1.0.0
servers:
  - url: https://planner.svc.v2.projectcor.com
    description: Resource Allocation Service
security:
  - bearerAuth: []
paths:
  /allocation/saveAllocation:
    post:
      tags:
        - Resource Allocation
      summary: Save Allocation
      description: >-
        Creates a new resource allocation for a user on a project.


        **Request Body Requirements:**

        All values in the object are required.


        **Known Errors:**

        - `InvalidAllocationError` — The allocation is invalid:
          - Empty `allocatedHours` field
          - The `from` date is greater than or equal to the `to` date
          - The date range exceeds 12 months
        - `AllocationAlreadyExistInDatesRangeError` — An allocation already
        exists within the specified date range

        - `UserNotFoundError` — The specified user cannot be found

        - `UserNotHaveWorkDaysError` — The user does not have any work days
        configured

        - `ProjectNotFoundError` — The specified project cannot be found
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AllocationInput'
            example:
              userId: 1111
              companyId: 1111
              email: email@email.com
              resource:
                typeId: Project
                entityId: 1111
              from: '2024-06-01'
              to: '2024-10-31'
              assignedByUserId: 11111
              allocatedHours: 20
      responses:
        '200':
          description: Allocation saved successfully
        '400':
          description: Invalid allocation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllocationError'
              examples:
                invalid_allocation:
                  summary: Invalid allocation data
                  value:
                    error: InvalidAllocationError
                    message: Empty allocated hours field
                user_not_found:
                  summary: User not found
                  value:
                    error: UserNotFoundError
                    message: The specified user cannot be found
                allocation_exists:
                  summary: Allocation already exists
                  value:
                    error: AllocationAlreadyExistInDatesRangeError
                    message: >-
                      An allocation already exists within the specified date
                      range
components:
  schemas:
    AllocationInput:
      type: object
      required:
        - userId
        - companyId
        - resource
        - from
        - to
        - assignedByUserId
        - allocatedHours
      properties:
        userId:
          type: integer
          description: ID of the user being allocated
        companyId:
          type: integer
          description: Company ID
        email:
          type: string
          format: email
          description: User email (optional)
        resource:
          $ref: '#/components/schemas/AllocationResource'
        from:
          type: string
          format: date
          description: Start date (YYYY-MM-DD)
        to:
          type: string
          format: date
          description: >-
            End date (YYYY-MM-DD). Must be after 'from' date and within 12
            months.
        assignedByUserId:
          type: integer
          description: ID of the user who assigned the allocation
        allocatedHours:
          type: number
          description: Number of hours allocated
    AllocationError:
      type: object
      properties:
        error:
          type: string
          description: Error type
          enum:
            - InvalidAllocationError
            - AllocationAlreadyExistInDatesRangeError
            - UserNotFoundError
            - UserNotHaveWorkDaysError
            - ProjectNotFoundError
            - AllocationNotFoundError
        message:
          type: string
          description: Error description
    AllocationResource:
      type: object
      required:
        - typeId
        - entityId
      properties:
        typeId:
          type: string
          enum:
            - Project
          description: Type of resource (currently only Project is supported)
        entityId:
          type: integer
          description: Project ID
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Uses the same authentication as the main COR API. Obtain a token from
        https://api.projectcor.com/v1/oauth/token

````