> ## 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.

# Update Allocation

> Updates an existing resource allocation. Requires both the old allocation data and the new allocation data.

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

**Note:** You can use this endpoint to change a project allocation, as long as there isn't an existing allocation for the same user in the target project for any date within the range of the new allocation.



## OpenAPI

````yaml /api-reference/resource-allocation-openapi.json put /allocation/updateAllocation
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/updateAllocation:
    put:
      tags:
        - Resource Allocation
      summary: Update Allocation
      description: >-
        Updates an existing resource allocation. Requires both the old
        allocation data and the new allocation data.


        **Known Errors:**

        - `InvalidAllocationError` — The new allocation is invalid:
          - Empty `allocatedHours` field
          - The `from` date is greater than or equal to the `to` date
          - The date range exceeds 12 months
        - `AllocationNotFoundError` — The specified old allocation cannot be
        found

        - `AllocationAlreadyExistInDatesRangeError` — The new allocation already
        exists within the specified date range

        - `UserNotFoundError` — The specified user in new allocation cannot be
        found

        - `UserNotHaveWorkDaysError` — The user does not have any work days in
        the new allocation dates range

        - `ProjectNotFoundError` — The specified project in new allocation
        cannot be found


        **Note:** You can use this endpoint to change a project allocation, as
        long as there isn't an existing allocation for the same user in the
        target project for any date within the range of the new allocation.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AllocationUpdateInput'
            example:
              oldAllocation:
                userId: 1111
                companyId: 11
                resource:
                  entityId: 11111
                  typeId: Project
                from: '2024-01-01'
                to: '2024-03-31'
                assignedByUserId: 1111
                allocatedHours: 0
              newAllocation:
                userId: 1111
                companyId: 11
                resource:
                  entityId: 11111
                  typeId: Project
                from: '2024-01-01'
                to: '2024-03-31'
                assignedByUserId: 1111
                allocatedHours: 10
      responses:
        '200':
          description: Allocation updated successfully
        '400':
          description: Invalid allocation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllocationError'
              examples:
                allocation_not_found:
                  summary: Old allocation not found
                  value:
                    error: AllocationNotFoundError
                    message: The specified allocation cannot be found
components:
  schemas:
    AllocationUpdateInput:
      type: object
      required:
        - oldAllocation
        - newAllocation
      properties:
        oldAllocation:
          $ref: '#/components/schemas/AllocationInput'
          description: The existing allocation to be updated
        newAllocation:
          $ref: '#/components/schemas/AllocationInput'
          description: The new allocation data
    AllocationError:
      type: object
      properties:
        error:
          type: string
          description: Error type
          enum:
            - InvalidAllocationError
            - AllocationAlreadyExistInDatesRangeError
            - UserNotFoundError
            - UserNotHaveWorkDaysError
            - ProjectNotFoundError
            - AllocationNotFoundError
        message:
          type: string
          description: Error description
    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
    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

````