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

# Assign devices to allocation

> Assign devices selected by UUID, rack name, or an explicit all_devices flag. Non-conflicting devices are still assigned when overlaps are found; those partial-success responses use HTTP 409 and include every conflict. Dry runs with conflicts also return 409 without assigning anything.



## OpenAPI

````yaml /openapi/fleet-manager-openapi.yaml post /api/v1/allocations/{id}/assign/
openapi: 3.0.3
info:
  title: Fleet Manager API
  version: 1.0.0
  description: API for the Nscale Fleet Manager
servers: []
security: []
paths:
  /api/v1/allocations/{id}/assign/:
    post:
      tags:
        - Allocations
      summary: Assign devices to allocation
      description: >-
        Assign devices selected by UUID, rack name, or an explicit all_devices
        flag. Non-conflicting devices are still assigned when overlaps are
        found; those partial-success responses use HTTP 409 and include every
        conflict. Dry runs with conflicts also return 409 without assigning
        anything.
      operationId: api_v1_allocations_assign_create
      parameters:
        - in: path
          name: id
          schema:
            type: string
            format: uuid
          description: A UUID string identifying this allocation.
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AllocationAssignmentRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/AllocationAssignmentRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/AllocationAssignmentRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllocationAssignmentResult'
          description: ''
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication credentials were not provided or are invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: You do not have permission to perform this action.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllocationAssignmentResult'
          description: ''
      security:
        - oauth2:
            - allocation:update
        - cookieAuth: []
components:
  schemas:
    AllocationAssignmentRequest:
      type: object
      description: Selectors for assigning a device cohort to an existing allocation.
      properties:
        device_ids:
          type: array
          items:
            type: string
            format: uuid
          description: Device UUIDs to select. Mutually exclusive with rack_names.
          maxItems: 2000
          minItems: 1
        rack_names:
          type: array
          items:
            type: string
            minLength: 1
          description: >-
            Rack names in the allocation's site whose devices should be
            selected.
          maxItems: 100
          minItems: 1
        device_role_slugs:
          type: array
          items:
            type: string
            minLength: 1
          description: >-
            Optional device-role slugs applied after the device or rack
            selector.
          maxItems: 100
          minItems: 1
        all_devices:
          type: boolean
          default: false
          description: >-
            Explicitly select every device in the allocation's site. Required
            when device_ids and rack_names are both omitted.
        dry_run:
          type: boolean
          default: false
          description: Return the planned outcome without changing allocation memberships.
    AllocationAssignmentResult:
      type: object
      description: Typed result for a live allocation assignment or dry run.
      properties:
        allocation_id:
          type: string
          format: uuid
          readOnly: true
        dry_run:
          type: boolean
          readOnly: true
        matched_device_count:
          type: integer
          readOnly: true
        filtered_out_device_count:
          type: integer
          readOnly: true
        assigned_devices:
          type: array
          items:
            $ref: '#/components/schemas/AllocationAssignmentDevice'
          readOnly: true
        already_member_devices:
          type: array
          items:
            $ref: '#/components/schemas/AllocationAssignmentDevice'
          readOnly: true
        conflicts:
          type: array
          items:
            $ref: '#/components/schemas/AllocationAssignmentConflict'
          readOnly: true
      required:
        - allocation_id
        - already_member_devices
        - assigned_devices
        - conflicts
        - dry_run
        - filtered_out_device_count
        - matched_device_count
    ErrorResponse:
      type: object
      description: >-
        Uniform error body for every 4xx/5xx response. `detail` is a
        human-readable message, always present, safe to display to end users.
        `code` is the machine-readable identifier. `field_errors` lists
        per-input-field validation messages and is empty for non-field errors
        (auth, permission, not-found, conflict, server).
      required:
        - detail
        - code
        - field_errors
      properties:
        detail:
          type: string
        code:
          $ref: '#/components/schemas/ErrorCodeEnum'
        field_errors:
          type: array
          items:
            $ref: '#/components/schemas/FieldError'
    AllocationAssignmentDevice:
      type: object
      description: Compact device reference in an allocation-assignment result.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
          readOnly: true
      required:
        - id
        - name
    AllocationAssignmentConflict:
      type: object
      description: Overlapping allocation that prevented one device assignment.
      properties:
        device_id:
          type: string
          format: uuid
          readOnly: true
        device_name:
          type: string
          readOnly: true
        allocation_id:
          type: string
          format: uuid
          readOnly: true
        tenant_name:
          type: string
          readOnly: true
      required:
        - allocation_id
        - device_id
        - device_name
        - tenant_name
    ErrorCodeEnum:
      type: string
      description: >-
        Stable machine-readable error identifier. New members may be added
        within this API version; clients must tolerate unknown values.
      enum:
        - error
        - invalid
        - parse_error
        - authentication_failed
        - not_authenticated
        - permission_denied
        - not_found
        - method_not_allowed
        - not_acceptable
        - unsupported_media_type
        - conflict
        - enrollment_infrastructure_reference_pending
        - enrollment_infrastructure_reference_changed
        - unprocessable_entity
        - throttled
        - service_unavailable
    FieldError:
      type: object
      description: One input field's validation messages.
      required:
        - field
        - messages
      properties:
        field:
          type: string
          description: >-
            Dotted path to the offending input field, or to the collection row
            when the whole row is invalid (e.g. `filters.end_date`,
            `memberships.0.role`, `memberships.0`).
        messages:
          type: array
          minItems: 1
          items:
            type: string
  securitySchemes:
    oauth2:
      type: oauth2
      flows: {}
    cookieAuth:
      type: apiKey
      in: cookie
      name: sessionid

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.