# Update a shell case (v2 - improved error handling)

Updates an existing shell case with new metadata.
**Version 2 Improvements:**
This endpoint provides enhanced error handling with clear, actionable error messages:
- **Panel validation**: If specified panel names don't exist, returns a 400 error listing the invalid panel names
- **Assay validation**: If the assay ID is invalid or doesn't exist, returns a specific error message
- **Subject validation**: If the analysis doesn't have a subject configured, returns a clear error
- **Assigned user validation**: If the `assigned_to` email does not belong to a user in the organization, returns a 400 error

Can update:
- Patient details (name, DOB, sex, phenotypes, ethnicities)
- Virtual panels
- Labels
- Assay
- Batch
- Custom fields

**Common Error Responses:**
- `"Panel(s) not found: PanelX, PanelY"` - One or more specified virtual panels don't exist
- `"Analysis 12345 does not have a subject configured"` - The analysis lacks subject data
- `"Invalid assay id: not a valid UUID"` - The assay ID format is invalid
- `"Assay assay-id does not exist"` - The specified assay doesn't exist
- `"Invalid assignedTo email: user@example.com"` - The assigned_to email does not belong to a user in the organization

Endpoint: POST /v2/shell_case/update
Version: 96
Security: bearerAuth

## Security:

  - `bearerAuth` (unknown)
    http bearer JWT

## Request fields (application/json):

  - `analysis_id` (integer, required)
    Analysis ID to update
    Example: 12345

  - `case_type` (string, required)
    Case type
    Enum: "single"

  - `samples_data` (array, required)
    Updated sample data

  - `samples_data.sample_name` (string, required)
    Sample name
    Example: Sample_001

  - `samples_data.patient_details` (object)
    Patient/subject details

  - `samples_data.patient_details.name` (string)
    Patient name
    Example: John Doe

  - `samples_data.patient_details.dob` (string)
    Date of birth (formats are dd-MM-yyyy, yyyy-MM-dd, dd/MM/yyyy)
    Example: 1990-05-15

  - `samples_data.patient_details.ethnicity` (string)
    Primary ethnicity (deprecated - use ethnicities)
    Example: European

  - `samples_data.patient_details.sex` (string)
    Biological sex
    Enum: "male", "female", "unknown"

  - `samples_data.patient_details.phenotypes` (array)
    HPO terms or phenotype descriptions
    Example: ["HP:0001250","Seizures"]

  - `samples_data.patient_details.major_phenotypes` (array)
    Subset of phenotypes considered major/primary. Must be a subset of phenotypes.
    Example: ["HP:0001250"]

  - `samples_data.patient_details.patient_id` (string)
    External patient identifier (e.g., MRN)
    Example: PAT-001

  - `samples_data.patient_details.ethnicities` (array)
    List of ethnic backgrounds
    Example: ["European","Ashkenazi Jewish"]

  - `samples_data.patient_details.description` (string)
    Clinical description
    Example: History of epilepsy

  - `samples_data.patient_details.cancer_type` (string)
    Cancer type (for oncology)
    Example: Breast Cancer

  - `samples_data.family_relation` (string)
    Family relation (for family cases)
    Example: proband

  - `samples_data.description` (string)
    Sample description
    Example: Primary sample

  - `samples_data.hard_panels` (array)
    Hard panel names
    Example: []

  - `samples_data.hard_panel_single_genes` (array)
    Individual genes for hard filter
    Example: []

  - `samples_data.sample_files_location` (object)
    Location configuration for sample files. Specifies where to fetch sample files from.
**Location Types:**
- `AWS` or `S3`: Files are fetched from AWS S3. Requires organization to have `caseFilesRootFolder` configured.
The final S3 path is constructed as: `{caseFilesRootFolder}/{folder_name}/`
where `folder_name` is either `s3_sample_files_folder_name_override` (if provided) or the sample name.
- `BASESPACE`: Files are fetched from Illumina BaseSpace. Requires `basespace_project` and `basespace_sample`.
If `basespace_rna_sample` is also provided, creates a tumor sample with RNA data.

  - `samples_data.sample_files_location.location` (string, required)
    The storage location type. Case insensitive.
- `AWS` or `S3`: Amazon S3 storage
- `BASESPACE`: Illumina BaseSpace
    Enum: "AWS", "S3", "BASESPACE"

  - `samples_data.sample_files_location.basespace_project` (string)
    BaseSpace project ID. Required when location is `BASESPACE`.
    Example: project-123

  - `samples_data.sample_files_location.basespace_sample` (string)
    BaseSpace biosample ID. Required when location is `BASESPACE`.
    Example: sample-456

  - `samples_data.sample_files_location.basespace_rna_sample` (string)
    BaseSpace RNA biosample ID. Optional for `BASESPACE` location.
When provided, creates a tumor sample with associated RNA data.
    Example: rna-sample-789

  - `samples_data.sample_files_location.s3_sample_files_folder_name_override` (string)
    Override the folder name used in the S3 path. Only applicable when location is `AWS` or `S3` and implicit linking is configured.
If not provided, the sample name is used as the folder name, following the root case files folder configured by Franklin PS.
Special characters are URL-encoded. Trailing slashes are stripped.
    Example: custom_folder_name

  - `samples_data.create_analysis` (boolean)
    Whether to create analysis record

  - `samples_data.affected` (boolean)
    Whether affected (for family)
    Example: true

  - `samples_data.sample_name_in_multi_sample_vcf` (string)
    Name in multi-sample VCF
    Example: SAMPLE001

  - `samples_data.consanguinity` (boolean)
    Whether there is known consanguinity in the family
    Example: false

  - `samples_data.include_secondary_findings` (boolean)
    Whether to include secondary findings for this sample.
Priority hierarchy (highest to lowest):
1. This sample-level setting
2. Case-level `include_secondary_findings` in the request
3. Organization's default setting
For family cases, the family analysis uses: case-level setting,
then proband's sample-level setting, then org default.
    Example: true

  - `assay_id` (string)
    New assay UUID
    Example: assay-uuid-456

  - `batch_name` (string)
    New batch name
    Example: Batch_2024_02

  - `virtual_panels` (array)
    Updated virtual panels

  - `labels` (array)
    Updated labels

  - `extra_case_details` (object)
    Updated custom fields

  - `assigned_to` (string)
    Email of user to assign to. Fails with an error if the user does not exist in the organization.
    Example: analyst@example.com

## Response 200:

  - `200` (unknown)
    Shell case updated successfully

## Response 200 fields (application/json):

  - `success` (boolean, required)
    Whether update was successful
    Example: true

## Response 400:

  - `400` (unknown)
    Bad request - invalid parameters. Common causes:
- Invalid panel names (panels don't exist)
- Invalid assay ID (not a UUID or doesn't exist)
- Analysis has no subject configured

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

## Response 400 examples:

  - `Panel not found` (unknown)

  - `No subject configured` (unknown)

  - `Invalid assay` (unknown)

  - `Invalid assigned_to email` (unknown)

