# Copy a case order's cases as skeleton (no sample files) into a new order

Creates a new case order containing skeleton clones of every analysis in the source order.
Each clone reuses the source analysis's structure (single or family, patient details, labels,
assay) but is created with renamed sample/analysis names (via `prefix` or `suffix`) and no
sample files attached, so it can be repopulated later.
Standalone single analyses are copied first (in id order), then family analyses. Family
members are auto-created as part of family copy and are skipped from the standalone pass to
avoid duplicate sample creation.
Exactly one of `source_case_order_id` or `source_case_order_name` identifies the source.
Exactly one of `prefix` or `suffix` is required for renaming.

Endpoint: POST /v1/case_order/copy_as_skeleton
Version: 96
Security: bearerAuth

## Security:

  - `bearerAuth` (unknown)
    http bearer JWT

## Request fields (application/json):

  - `source_case_order_id` (integer)
    ID of the source case order to copy. Mutually exclusive with `source_case_order_name`.
    Example: 12345

  - `source_case_order_name` (string)
    Current name of the source case order. Mutually exclusive with `source_case_order_id`.
    Example: Order_2024

  - `new_case_order_name` (string, required)
    Name for the new case order to create.
    Example: Order_2024_skeleton

  - `prefix` (string)
    Prefix to prepend to cloned analysis/sample/subject names. Mutually exclusive with `suffix`.
    Example: SKEL_

  - `suffix` (string)
    Suffix to append to cloned analysis/sample/subject names. Mutually exclusive with `prefix`.
    Example: _skeleton

## Response 200:

  - `200` (unknown)
    Copy completed (check `success` and `error` for outcome)

## Response 200 fields (application/json):

  - `success` (boolean, required)
    Whether the copy succeeded.
    Example: true

  - `error` (string)
    Error message when `success` is false.
    Example: null

  - `new_case_order_id` (integer)
    ID of the newly created case order (when success).
    Example: 67890

  - `new_case_order_name` (string)
    Name of the newly created case order.
    Example: Order_2024_skeleton

  - `copied_analyses` (array)
    Per-analysis source-to-new mappings.

  - `copied_analyses.source_analysis_id` (integer, required)
    ID of the source analysis that was copied.
    Example: 9001

  - `copied_analyses.source_analysis_name` (string, required)
    Name of the source analysis.
    Example: Case_2024

  - `copied_analyses.new_analysis_id` (integer, required)
    ID of the newly created skeleton analysis.
    Example: 9002

  - `copied_analyses.new_analysis_name` (string, required)
    Name of the newly created skeleton analysis.
    Example: SKEL_Case_2024

  - `copied_analyses.analysis_type` (string, required)
    Source analysis type (e.g., SAMPLE, TUMOR, FAMILY).
    Example: SAMPLE

## Response 400:

  - `400` (unknown)
    Bad request - invalid input

## Response 400 fields (application/json):

  - `error` (string, required)
    Error type
    Example: Not Found

  - `message` (string, required)
    Human-readable error description
    Example: Analysis with ID 12345 was not found

## Response 401:

  - `401` (unknown)
    Authentication failed - invalid or missing token

## Response 401 fields (application/json):

  - `error` (string, required)
    Error type
    Example: Not Found

  - `message` (string, required)
    Human-readable error description
    Example: Analysis with ID 12345 was not found

## Response 404:

  - `404` (unknown)
    Resource not found

## Response 404 fields (application/json):

  - `error` (string, required)
    Error type
    Example: Not Found

  - `message` (string, required)
    Human-readable error description
    Example: Analysis with ID 12345 was not found

## Response 429:

  - `429` (unknown)
    Rate limit exceeded

## Response 429 fields (application/json):

  - `error` (string, required)
    Error type
    Example: Not Found

  - `message` (string, required)
    Human-readable error description
    Example: Analysis with ID 12345 was not found

## Response 429 headers (application/json):

  - `Retry-After` (integer)
    Number of seconds to wait before retrying

