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

# Updating Samples

In general, samples should be considered an immutable resource, but how they are shared may be updated by changing their `visibility` and `project` properties and the tags associated with them may also be changed. All other sample attributes are read-only, and the associated metadata record should be used for storing additional (mutable) structured information about a sample.

<Note>
  **Additional authorization checks:** Note that `PATCH`ing to update the sample's visibility triggers additional account- and organization-level checks. For certain accounts (e.g., those in which PII is deposited), it may not be possible to make samples `shared` or `public`. Please [contact us](mailto:support@onecodex.com) to discuss setting additional restrictions on sample-sharing for your or your organization's account. Similarly, users may only add their samples to projects for which they have appropriate project-level permissions.
</Note>


## OpenAPI

````yaml Patch /api/v1/samples/{id}
openapi: 3.0.0
info:
  title: One Codex API (v1)
  description: >-
    The One Codex API (v1) -- programmatic access to One Codex's suite of
    microbial genomics data storage, analysis, and query tools.
  version: v1
servers:
  - url: https://app.onecodex.com
security:
  - apiKeyAuth: []
paths:
  /api/v1/samples/{id}:
    patch:
      summary: PATCH samples update
      operationId: patch_samples_update
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                project:
                  type: object
                  description: The project the sample belongs to (optional).
                  anyOf:
                    - type: object
                      properties:
                        $ref: 5c1e5594-ef80-45a5-8202-08f6859d3230
                    - type: string
                      nullable: true
                      maxLength: 16
                tags:
                  type: array
                  default: []
                  description: >-
                    An (optionally empty) array of references to Tags describing
                    the sample. Tags are an additional unstructured
                    organizational tool that complement Projects and Metadata
                    records.
                  items:
                    type: object
                    anyOf:
                      - type: object
                        properties:
                          $ref: 801c748b-7fe7-4937-a8b2-7564e055a8ba
                      - type: string
                        nullable: true
                        maxLength: 16
                visibility:
                  type: string
                  enum:
                    - public
                    - shared
                    - private
                    - importing
                    - awaiting data
                  description: >-
                    The visibility of the sample (affects who can view the
                    sample and its analyses).
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/samples'
components:
  schemas:
    samples:
      type: object
      properties:
        $uri:
          type: string
          pattern: ^/api/v1/samples\/[^/]+$
          example: /api/v1/samples/a1b2c3d4e5f67890
        created_at:
          type: string
          format: date-time
          description: >-
            Timestamp for when the object was created on the One Codex platform,
            encoded as a [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt)
            timestamp.
        error_msg:
          type: string
          nullable: true
          description: >-
            An error message if the sample failed to upload, import, or
            validate.
        filename:
          type: string
          nullable: true
          description: The sample filename.
        metadata:
          type: object
          description: A metadata object.
          properties:
            $ref: 2672f6a1-5ad8-4dd6-ac2b-57c8607658fb
        owner:
          type: object
          description: The owner of the sample.
          properties:
            $ref: 8adfa129-afb0-4cff-9408-1091c444fa3d
        primary_classification:
          type: object
          description: >-
            A reference to a Classification for the sample. This will typically
            be the [One Codex
            Database](https://docs.onecodex.com/en/articles/3761205-one-codex-database)
            or [Targeted Loci
            Database](https://docs.onecodex.com/en/articles/3754219-targeted-loci-database)
            results as appropriate. Note that samples will not have a
            `primary_classification` while they are still importing or being
            uploaded.
          properties:
            $ref: 424f8740-9815-4b0e-9597-f3a279a56e69
        project:
          type: object
          description: The project the sample belongs to (optional).
          properties:
            $ref: c5740b1b-2693-4b6f-99fa-97870c31d9d8
        size:
          type: integer
          nullable: true
          description: The size of the uploaded file in bytes.
        status:
          type: string
          enum:
            - awaiting_data
            - importing
            - validating
            - failed_validation
            - available
            - deleted
          description: The status of the sample.
        tags:
          type: array
          default: []
          description: >-
            An (optionally empty) array of references to Tags describing the
            sample. Tags are an additional unstructured organizational tool that
            complement Projects and Metadata records.
          items:
            type: object
            properties:
              $ref: 50a9c3a8-6984-49c9-9d9d-77271fc13ea8
        updated_at:
          type: string
          format: date-time
          description: >-
            Timestamp for when the object was last updated, encoded as a [RFC
            3339](https://www.ietf.org/rfc/rfc3339.txt) timestamp.
        visibility:
          type: string
          enum:
            - public
            - shared
            - private
            - importing
            - awaiting data
          description: >-
            The visibility of the sample (affects who can view the sample and
            its analyses).
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````